text:
Q: Error running ensime-source-buffer-loaded-hook - OSX with ENSIME and Emacs I get the following error when trying to start ENSIME on OSX through Emacs
Error running ensime-source-buffer-loaded-hook

I am following the instructions from the github source page

*

*Scala Mode is Working

*ENSIME Server appears to be installed, is there any way to verify this?

*The sbt plugin is installed and I have a .ensime config file generated

Starting Emacs gives me the above error. When I manually try M-x ensime I get the following:
Failed to connect to Swank: server process exited.

A: Okay, here's how I solved it:
Locate the ensime folder and run bin/server /tmp/ensime.port.
I got the error:
java -classpath ... org.ensime.server.Server ./port
Unrecognized VM option '+DoEscapeAnalysis'
Could not create the Java virtual machine.

I have no idea what DoEscapeAnalysis is for, but I tried deleting it from bin/server and now everything seems to work.
See here: https://gist.github.com/2300737

A: For my case on Windows 7, with the same error message, but the root cause was the original  setting for the maximum heap size -Xmx1512M was too large, I had to change to -Xmx768M to get over the error message.
I had also removed the byte compiled elisp code, and restart to avoid another error of
"call time out".

A: I also had this error on linux with emacs 24.3.1 and resolved it by specifying the full path to java in bin/server.


text:
Q: Why do freedesktop .desktop files not allow relative paths? The .desktop files have become the de-facto standard to easily access applications on Linux desktops, with executables not being easily startable from the GUI otherwise and many launchers not using the app icon but only the icon specified in the .desktop file.
Why then, does it not seem possible to use .desktop files that specify a relative path to their executable and is there a way around this?
When shipping software that one does not want to force users to install, relative paths are the only way to enable this.
AppImage seems to work around this by installing a .desktop file when being run for the first time by the user, which seems like a kludgy way to enable icons and launchers for software with a flexible path. Relative paths would be a much better way to go. Why is this solution then not possible on Linux desktops? It seems unlikely that this is a mere oversight but that I am instead missing the deeper reason behind this decision.

A: You could use an inline shell script to compute the path:
Exec=sh -e -c "exec \\"\\$(dirname \\"\\$0\\")/some_app\\"" %k

Yes, two levels of escaping are required.

A: Keep in mind that the FreeDesktop standard is just that: a standard.
In principle a vendor
such as KDE, GNOME, LXDE, or XFCE could add support for relative paths
without going through the standards process,
but in practice none of them have.
(I know for sure that neither GNOME 3.28.2
nor KDE Plasma 5.12.9 support relative paths,
and to the best of my knowledge
no other desktop environment does either.)
Why is this?
Reason 1: The simplest version of relative paths would conflict with the existing standard.
Consider this desktop file:
[Desktop Entry]
Type=Application
Name=My example app
Exec=my_example_app
Icon=example-app

The FreeDesktop specification says:

Standard Keys
Icon
Icon to display in file manager, menus, etc. If the name is an absolute path,
the given file will be used. If the name is not an absolute path, the
algorithm described in the Icon Theme
Specification will be
used to locate the icon.
[ . . . ]
Values of type iconstring are the names of icons; these may be absolute
paths, or symbolic names for icons located using the algorithm described in
the Icon Theme
Specification. Such
values are not user-displayable, and are encoded in UTF-8.

Since example-app is not an absolute path,
menus and panels that want to display the icon
will follow the icon theme specification
to find the correct path,
usually by looking in a folder like
/usr/share/icons/hicolor/48x48/apps/example-app.png

However, example-app is also a valid relative path,
so the icon string is now ambiguous.
If one desktop environment adopts relative paths and the others don't,
it would break compatibility.
Similarly, consider the Exec key:
Exec=my_example_app

According to the spec,
it must be either a full path (i.e. absolute path)
or an executable in $PATH:

The Exec key must contain a command line. A command line consists
of an executable program optionally followed by one or more
arguments. The executable program can either be specified with its
full path or with the name of the executable only. If no full path is
provided the executable is looked up in the $PATH environment
variable used by the desktop environment.

https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables
So my_example_app should be looked up in $PATH,
but if we consider this a relative path,
we'll have to look somewhere that might not be in $PATH at all.
Which one gets precedence?
Now, perhaps we could require all relative paths
to be prefixed
with ./ to disambiguate them.
Since / is not allowed in filenames,
this wouldn't be ambiguous, e.g.:
Icon=./example-app.png
Exec=./my_example_app

for a file in the same working directory or
Icon=./../example-app.png
Exec=./../my_example_app

for a file in the parent directory.
This brings up another question:
what counts as the working directory?
Reason 2: The intended working directory for a desktop file may be unclear.
Desktop files
can set the working directory with the Path key:

Path
If entry is of type Application, the working directory to run the program
in.

So if a desktop file had a valid Path key
and were to specify a relative path like this:
Path=/home/username/path/to/myfolder/
Exec=./my_example_app

would that be relative to the location of the desktop file
or relative to the Path key?
There are other possibilities to consider.

*

*Should the paths be relative to $XDG_DATA_HOME?
This would make some sense
since it's where the actual desktop files and icons are stored,
but it's not where the executables are stored.

*Should the paths be relative to the working directory of the launcher process?
This would make sense
since this process that shows the panels or menus
is the one that needs to know where the executable and icon is.
Usually the working directory of the window manager
is the user's home directory,
but in principle the working directory could be anywhere.
Reason 3: Relative paths must be updated if the desktop file is moved.
OK, let's suppose we specify
that the paths to both the executables and icons
are always relative to the desktop file,
ignoring the Path key, the launcher process, and everything else.
Now suppose we want to copy that desktop file somewhere else, such as:
~/Desktop/example-app.desktop

Now the relative path is different,
and we'll have to edit the desktop file
and change the path all over again.
Using either absolute paths or standard folder locations
solves this problem.
Reason 4: Menus and panels may require desktop files to be in arbitrary locations.
As long as we keep the desktop file in the same directory
and only run it with the file manager,
relative paths will work.
But suppose we want to run our desktop file
from a menu or panel launcher.
Now the desktop file might be in
/usr/share/applications/

or it might be in
~/.local/share/applications/

or in
~/.config/xfce4/panel/

and note that the relative path to an icon or executable
is not the same for any of these.
Moreover,
depending on $XDG_DATA_HOME
and $XDG_DATA_DIRS,
the desktop file could be somewhere else entirely.
In the original question,
the stated use-case is to run executables from the GUI
and display custom icons without installing.

with executables not being easily startable from the GUI otherwise
and many launchers not using the app icon but only the icon specified
in the .desktop file.
Why then, does it not seem possible to use .desktop files that
specify a relative path to their executable and is there a way around
this?
When shipping software that one does not want to force users to
install, relative paths are the only way to enable this.

One reason why we bother with
a standard installation process for software in the first place
is to place resources in a standard location
so that other processes can find them.
This makes installing and uninstalling more complicated,
but helps with things like caching and debugging
since there's fewer directories to check.
If we don't want to install the executable,
we can still run it via a relative path,
but if we want the convenience of launching it
via another process (e.g. a menu launcher or panel),
the other process has to know where to look,
and since each process has its own working directory,
their relative paths may be different.
The spec has this to say:

So, you're an application author, and want to install application
icons so that they work in the KDE and Gnome menus. Minimally you
should install a 48x48 icon in the hicolor theme. This means
installing a PNG file in $prefix/share/icons/hicolor/48x48/apps.
Optionally you can install icons in different sizes. For example,
installing a svg icon in $prefix/share/icons/hicolor/scalable/apps
means most desktops will have one icon that works for all sizes.

So we can install an icon here:
~/.local/share/icons/hicolor/48x48/apps/example-app.png

or here:
~/.local/share/icons/hicolor/scalable/apps/example-app.svg

Then simply refer to the iconstring as example-app like this:
Icon=example-app

and the launcher process will be able to find the icon.
This is not really a relative path,
but it solves the problem of having to use an absolute path,
and it won't break if the desktop file is moved to a different location.
The same applies to the Exec key,
except it's executables somewhere in $PATH
instead of images in icon folders.
Epilogue: prior discussion and links.
It should be noted that support for relative paths to icons
has been discussed on the FreeDesktop mailing list
at least as early as September 2008:

Magnus Bergmark magnus.bergmark at gmail.com
Tue Sep 23 01:01:32 PDT 2008
[ . . . ]
I propose that we allow the usage of relative paths in some way also.
Use-cases

*

*I use a lot of .directory files to make directories containing a movie
have the movie poster as the icon. This behaviour could apply to any form of
media, like comic books, music (album art) and photos.

*A vendor might want to bundle an icon to a piece of software they're
distributing to go with a .desktop file which are not to go in the
desktop menu and therefore are still located in the application directory.

https://lists.freedesktop.org/archives/xdg/2008-September/009940.html
The only counterargument I was able to find
to this proposal is here:

A .desktop file
that is not intended to go into a standard applications directory is
almost entirely useless. Perhaps you should look at some of the
software bundle proposals and implementations, and work with using
those, instead. Another option is the xdg utils scripts, to install
the .desktop file and icons in the appropriate places. I can only
presume that your uninstalled application also intends to not follow
the Icon Theme and Icon Naming specifications either. And I don't see
setting the directory's icon as useful really. Setting an icon for the
actual executable would be much more useful, though elf binaries do
not have resources like win32 binaries do.

https://lists.freedesktop.org/archives/xdg/2008-September/009962.html
Related questions:

*

*https://askubuntu.com/questions/277190/how-to-package-an-application-icon-properly

*https://stackoverflow.com/questions/3452746/how-can-i-specify-an-icon-with-a-relative-path-for-a-linux-desktop-entry-file

*Is there a home directory location for overriding icons?

*Assign an icon to a custom mimetype
Relevant links:

*

*https://gitlab.freedesktop.org/xdg/xdg-utils/-/issues/82

*https://bugs.kde.org/show_bug.cgi?id=68507

*https://bugs.kde.org/show_bug.cgi?id=73463

*https://lists.freedesktop.org/archives/xdg/2008-September/009940.html

*https://lists.freedesktop.org/archives/xdg/2011-April/011883.html

*https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html

A: I needed a path relative to the home directory in my firefox.desktop. Such that every user get's his own firefox-profile started, i.e. firefox-frank sitting in ~/Documents/... aka /home/frank/Documents/...
And this is the Exec-line, that works: (thanks to @timothy-baldwin answer above)
Exec=sh -e -c "/usr/bin/firefox -profile \"/home/$(whoami)/Documents/chrome-profiles/firefox-$(whoami)\""

A: For the Exec fileld I suppose that the reason is that it is not obvious what path should be used as base. For example you expect relativeness to *.desktop file location, but I expect relativness to the Path value. And this ambiguity could lead to mistakes. Additionally the Path isn't required field, so it becomes more complicated what should be happened when the Exec got relative path and the Path isn't defined. More convinient to not state of supporting relative paths at all and expect only absolute paths and binaries in the %PATH% directories.
For the Icon field treated in it's own way:

Icon to display in file manager, menus, etc. If the name is an absolute path, the given file will be used. If the name is not an absolute path, the algorithm described in the Icon Theme Specification will be used to locate the icon.

By the way, they (standards.freedesktop.org) no pronounce the supporting of the relative paths, but in fact seems like *.desktop files supports that.
If you write ./ before file name - it will run the executable in the Path folder.
[Desktop Entry]
Name=TheApp
Type=Application
Path=/usr/lib/TheApp
Exec=./TheAppExecutable

A: In order to appreciate the situation, ask yourself, "Relative to what?". The .desktop files are for use within GUI contexts, for which no base path can be assumed upon which to build an absolute path from any relative path you might consider putting in the .desktop file.
Relative paths are only useful when they can be converted to a definite location (the absolute path), and that requires a reference point. which can't be assumed in any generic GUI context.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Unit voltage template method for the control of D-STATCOM I have got this model of the D-STATCOM which I am trying to implement from this paper: Analysis of shunt active powerfilter with unit template method
I have created a model as show below:

The controller set-up is show below:

No matter what I do, the DC value is not matching the reference value (no matter what the value of the PI controller is).
The complete model can be downloaded from here: MATLAB MODEL OF D-statcom.


text:
Q: How to create Liferay hook in order to extend functionality of shopping cart portlet Can anyone help me out on how to create a hook within Liferay for the shopping cart portlet? I would like to implement custom code at the point of a successful order. Any help is appreciated.
I've tried reading the documentation for overriding services:
http://www.liferay.com/community/wiki/-/wiki/Main/Portal+Hook+Plugins
but I'm not sure what the service would be that I need to override.
Thanks!

A: The way to find it yourself is to use Liferay IDE and let the "New Hook" Wizard guide you. You can rely on Liferay's naming conventions. The shopping cart services all start with "Shopping", e.g. ShoppingOrderLocalService.
In this class, take a look at the methods in that class. Extend the Liferay implementation as the default implementation (best practice) and only implement the methods, where you want to add changed behaviour. You can call super to retain the old implementation (you typically want this) or just ignore that call if you completely change the behaviour.


text:
Q: How do I get username and appname for file path How am I able to define a path like "C:/Users/<USER>/AppData/Local/<APPNAME>", for different username and app? How do I set this to automatically get the user and the appname? Thank you.

A: You can use SHGetKnownFolderPath to get the full path of App Local:
...
#include <KnownFolders.h>
#include <ShlObj.h>
...
    SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_SIMPLE_IDLIST, NULL, &path); // NULL for current user
...

A: To get the username:
char username[MAX_PATH];
DWORD size = MAX_PATH;
GetUserName(username,&size);

To get the appname(Executable File Name without ".exe"):
char appname[MAX_PATH];
char buffer[MAX_PATH];

GetModuleFileName(NULL, appname,MAX_PATH); //get the string: "PATH\\appname.exe"
char *szExe = NULL;
//Remove prefix
GetFullPathName(appname, MAX_PATH, buffer, &szExe);
//Remove suffix
strncpy_s(appname, szExe, strlen(szExe) - strlen(".exe"));

A: To get the Local AppData path for a given user, use SHGetFolderPath() specifying CSIDL_LOCAL_APPDATA, or SHGetKnownFolderPath() specifying FOLDERID_LocalAppData. Both take an optional user token for the desired user account to query. If you don't provide a token, the user associated with the calling thread is used.


text:
Q: Picasso fetch() and get() with OkHttpDownloader I am using Picasso library (2.5.2) with OkHttpDownloader (2.4.0) as downloader
OkHttpClient myOkHttpClient = new OkHttpClient();
myPicassoInstance = new Picasso.Builder(context).downloader(new OkHttpDownloader(myOkHttpClient)).build();
Picasso.setSingletonInstance(myPicassoInstance);

in a RemoteViewsService.RemoteViewsFactory to fill a images' grid prefetching by fetch() in onDataSetChanged() method
Picasso.with(mContext)
.load(picture)
.resize(Math.round(160 * displayMetrics.density), Math.round(90 * displayMetrics.density))
.centerCrop()
.fetch();

and getting by get() in getViewAt() method
Picasso.with(mContext)
.load(itemsList.get(position).getUrlImage())
.resize(Math.round(160 * displayMetrics.density), Math.round(90 * displayMetrics.density))
.centerCrop()
.get());

Well, enabling logging on Picasso's instance, I see that at first run fetch() loads from network and writes entries in cache, while get() loads from cache.
At second time, while updating grid's content, fetch() loads from memory and get() from cache.
And it is ok.
But when process dies and is restarted, fetch() restarts to load from network ignoring the cache entries, why?
UPDATE
I tried without OkHttpDownloader (2.4.0) as downloader and now fetch() loads right first time from network (if image doesnt exist in cache) or from disk (if image exists in cache), retaining in memory until process dies.
myPicassoInstance = new Picasso.Builder(context).build();
Picasso.setSingletonInstance(myPicassoInstance);

then, there is some conflict between Picasso library (2.5.2) and OkHttpDownloader (2.4.0)?
UPDATE 2

*

*Tried with OkHttpDownloader (2.3.0) as downloader: same problem

*Tried with UrlConnectionDownloader as downloader: same problem

*Tried using into() in an adapter: same problem

A: This reply on github solved my problem.


text:
Q: Does gate::allows always return false within tests? Inside AuthServiceProvider I have this gate:
  Gate::define('buy-seals', function ($user) {
        return true;
  });

If call the route /test4 it returns 'YES', which imples that this Gate is setup correctly:
Route::get('/test4', function () {
    return Gate::allows('buy-seals') ? 'YES' : 'NI';
});

However, if I want to test the closure of the Gate in a PHPUnit test like this:
public function test_buy_seals_always_true()
{
    $this->assertsTrue(Gate::allows('buy-seals'));
}

Then the test fails, meaning inside the test Gate::allows('buy-seals') is always false? Why is that?

A: Looks like I have to specify forUser($user)
$user = factory(User::class)->create();
Gate::forUser($user)->allows('buy-seals');

Not sure why this necessary, but now it returns true in tests.


text:
Q: Why increasing innodb_buffer_pool_size slow down selects? I have a server with 32G, a database of 20G. I run MySQL with innodb_buffer_pool_size of 10G, in trying to improve the performance increasing the value to 20G just slows down the select-queries. Can anybody explain me why that happens?

A: *

*Try EXPLAIN to get the general idea why the queries are slow.

*Try SHOW ENGINE INNODB STATUS to see how buffer pool is used and what your InnoDB engine is doing.

*There may be a lot of other factors in play here. Increasing buffer_pool_size you may be getting out of physical RAM (in accord with other configuration options), and then it goes into virtual memory, which is on disk... and disk operations are always slow...


text:
Q: git tagging comments - best practices I've adopted a tagging system of x.x.x.x, and this works fine. However, you also need to leave a comment with your git tag. I've been using descriptions such as "fixes bug Y" or "feature X", but is this the best sort of comment to be leaving? Particularly, what if a tag encompasses several fixes, it seems not to make sense to have a very long tag comment. Does this mean that I should be creating a tag for every bug fix or feature, or should the tag comments be reflective of something else? I have a few ideas that may be good, but I'd love some advice from seasoned git tagging veterans :)
For those who prefer specific examples:
1.0.0.0 - initial release
1.0.0.1 - bug fix for issue X
1.0.0.2 - (what if this is a bug fix for multiple issues, the comment would be too long, no?)

Another example, in this example, the comments are more or less the same as the tags, it seems redundant. Is there something else we could be describing?
https://github.com/osCommerce/oscommerce2/tags

A: A tag should be created for significant commits — something meaningful. This is a bit open-ended, but most times a tag corresponds to a release, and this is why you tend to see tags like v1.3.5.X or 1.4.0.X. You should not be creating release tags for commits that are not actually releases.
Comments on release tags should give you a short description of what is included in that release, like an "elevator pitch" or "executive summary." You can optionally include a link to the release notes for that release, but this can be risky if your project ever changes its URL. This can happen frequently with open source projects.
If the repository has a text file for the release notes, then your tag comments can refer people to that text file, which is a much more stable way to refer to this information.
An example release tag comment with new features and bug fixes:

New features and bug fixes, including a high priority security fix for issue #285.
See ReleaseNotes.md for more information.

An example release tag comment with just bug fixes:

Maintenance release to resolve defects with feature A (see ReleaseNotes.md)

Another example release tag comment outlining new features:

Added comments to blog posts and new content moderation features

Short and sweet.
You can tag other significant commits that do not correspond to a release. If the tag name is descriptive enough, then don't add a comment:

*

*before_framework_migration

*js_to_typescript_rewrite

If the tag name is not sufficient to explain why the tag exists, then add whatever comments are required in order to give team members come context. For example, let's say you created the before_framework_migration tag and added comments:

Last good commit before starting migration from .NET Framework to .NET Core
We are expected to deliver new features along with this framework upgrade prior to the November reporting deadline. See Epic 2986 (https://example.com/workItems/2986) for more info.


text:
Q: Counting $r$-permutations of a multiset Given a multiset $ S = \{\!\!\{ m \cdot 0, 1, ..., n \}\!\!\}$ where $m, n \in \mathbb{N}$, find the number of $m$-permutations of $S$.
For example, when $m=2$ and $n=2$, $S = \{\!\!\{ 0, 0, 1, 2 \}\!\!\}$ and the $2$-permutations are: $$ (0, 0), (0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)$$
Similar questions have been asked before ([1] and [2]), but no correct or concise close form solution was given in either case.

A: I prefer to use lower-case for the natural numbers here: $S=\{\!\!\{m\cdot0,1,2,\ldots,n\}\!\!\}$. As usual let $[n]=\{1,\ldots,n\}$.
Suppose that $0\le k\le m$; we'll count the $m$-permutations of $S$ with $k$ zeroes. There are $\binom{m}k$ ways to choose the positions of the zeroes and $(m-k)!\binom{n}{m-k}$ ways to fill the remaining $m-k$ positions with an $(m-k)$-permutation of $[n]$, so there are
$$(m-k)!\binom{m}k\binom{n}{m-k}=(m-k)!\binom{m}{m-k}\binom{n}{n-(m-k)}$$
$m$-permutations of $S$ with $k$ zeroes. Thus, there are altogether
$$\sum_{k=0}^m(m-k)!\binom{m}{m-k}\binom{n}{n-(m-k)}=\sum_{k=0}^mk!\binom{m}k\binom{n}{n-k}=\sum_{k=0}^mk!\binom{m}k\binom{n}k$$
$m$-permutations of $S$. I don't at the moment see any nice simplification of this sum.


text:
Q: CS50 final project: Problem with upload file path Amateur coder & enthusiast here, first time asking... I'm working on the final project of the CS50 course. I'm building a website where you can register and upload certain documents. Everything seems to be running fine, but the moment I try to upload the documents, I get an Internal Server Error with the following message:
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
What is going on? Is there a restriction for uploading documents into a folder in the CS50 IDE? I can't seem to find the solution to this problem. Documents are required to be in PDF format and I've tried /documentos, /fp/documentos & ~/workspace/fp/documentos/ as file paths. Here is the code:
import os

from cs50 import SQL
from flask import Flask, flash, redirect, render_template, request, session,
url_for
from flask_session import Session
from tempfile import mkdtemp
from werkzeug.exceptions import default_exceptions
from werkzeug.security import check_password_hash, generate_password_hash
from werkzeug.utils import secure_filename

from helpersp import apology, login_required

# Define uploaded documents destination and allowed extensions

UPLOAD_FOLDER = '/fp/documentos/'
ALLOWED_EXTENSIONS = set(['pdf'])

# Check if extension is allowed.

def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS

@app.route("/primer", methods=["GET", "POST"])
@login_required
def primer():
"""Prompts user to upload pre contractual documents"""
 if request.method == "GET":
     return render_template("primer.html")

 else:
     # check if the post request has the file part
     if "file" not in request.files:
         return render_template("sindocumentos.html")
     file = request.files["file"]
     #  if user does not select file, browser also
     # submit an empty part without filename
     if file.filename == "":
         return render_template("sindocumentos.html")
     if file and allowed_file(file.filename):
         filename = secure_filename(file.filename)
         file.save(os.path.join(app.config['/fp/documentos/'], filename))

     return render_template("successp.html")

Here is the HTML part:
{% extends "layoutp.html" %}

{% block title %}
    Subir carpeta
{% endblock %}

{% block main %}
    <form action="/primer" method="post" enctype=multipart/form-data>

            Sube tu carpeta de documentos en un solo archivo PDF.

            El nombre del archivo debe tener el siguiente formato:
           carpeta_nombre_apellido_año.pdf.

           <input type="file" name="file">

        <button class="btn btn-primary" type="submit">Subir</button>
    </form>
{% endblock %}

The flask trace goes as follows:
ERROR:flask.app:Exception on /primer [POST]
Traceback (most recent call last):
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/ubuntu/workspace/fp/helpersp.py", line 34, in decorated_function
    return f(*args, **kwargs)
  File "/home/ubuntu/workspace/fp/profesores.py", line 133, in primer
    file.save(os.path.join(app.config[UPLOAD_FOLDER], filename))
KeyError: '/documentos'

UPDATE: I have tried different absolute paths without any luck. I've tried using os.path.abspath(os.path.dirname(file)) and also UPLOAD_FOLDER=os.mkdir('documentos2'). With the os.mkdir option, it gives me the same error message as before only this type the KeyError is 'None':
 File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/ubuntu/workspace/fp/helpersp.py", line 34, in decorated_function
    return f(*args, **kwargs)
  File "/home/ubuntu/workspace/fp/profesores.py", line 124, in primer
    file.save(os.path.join(app.config[UPLOAD_FOLDER], filename))
KeyError: None

Any help is very much appreciated!

A: Try something like this:
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

instead of
file.save(os.path.join(app.config['/fp/documentos/'], filename))

Not sure if this will solve your problem, but this is how a working file of mine looks like where I use the same attributes as you do. This is kinda the only different I could find. It could also be the path, are you sure that the full path is defined in your code and do you see any files uploaded in that path when you do the post request?
Example of full path:
/Users/username/Desktop/csv_tool/upload_folder


text:
Q: How to aline the textfield and counter on the same line on flutter using maxLength? How to make the counter and text on the same line or same row? when i use maxlength the counter appear below the textfield.

Widget _nameTextField(String hintText) {
    return TextFormField(
      controller: TextEditingController(
        text: _template.name,
      ),
      decoration: InputDecoration(
        hintText: hintText,
        contentPadding: EdgeInsets.all(15)
      ),
      cursorRadius: Radius.circular(10),
      keyboardType: TextInputType.text,
      autofocus: true,
      maxLength: 40,
      // maxLengthEnforced: true,
      validator: (val) {
        if (val.isEmpty) {
          return 'Please enter text.';
        }
        return null;
      },
      onChanged: (val) {
        _template.name = val;
        print(val);
      },
    );
  }

A: Add suffix text and suffixstyle to your input decoration. Like this
Widget _nameTextField(String hintText) {
    return TextFormField(
      controller: TextEditingController(
        text: _template.name,
      ),
      decoration: InputDecoration(
        hintText: hintText,
        contentPadding: EdgeInsets.all(15),
        suffixText: '11/40',
        suffixStyle: TextStyle(color: Colors.white)
      ),
      cursorRadius: Radius.circular(10),
      keyboardType: TextInputType.text,
      autofocus: true,
      maxLength: 40,
      // maxLengthEnforced: true,
      validator: (val) {
        if (val.isEmpty) {
          return 'Please enter text.';
        }
        return null;
      },
      onChanged: (val) {
        _template.name = val;
        print(val);
      },
    );
  }

A: Fixed the problem. by adding suffix and setstate to update the value when tying.
Widget _nameTextField(String hintText) {
    int nameLength = _template.name.length;
return TextFormField(
  controller: TextEditingController(
    text: _template.name,
  ),
  decoration: InputDecoration(
    hintText: hintText,
    contentPadding: EdgeInsets.all(15),
    suffixText: nameLength.toString() + "/ 40",
    suffixStyle: TextStyle(color: Colors.grey),
    counterText: "",
  ),
  cursorRadius: Radius.circular(10),
  keyboardType: TextInputType.text,
  autofocus: true,
  maxLength: 40,
  validator: (val) {
    if (val.isEmpty) {
      return 'Please enter text.';
    }
    return null;
  },
  onChanged: (val) {
    _template.name = val;
    setState(() {
      nameLength = _template.name.length;
    });
    print(val);
  },
);

}


text:
Q: Possible bug in the "since" key, or it supposed to work like this? I'm querying the facebook feeds to get the latest feeds. I'm using the FB api:
 55xxxxx/feed?since=1323269266&date_format=U&limit=5

The since date is taken from the previous api call first object create_date. Now the problem is that if the Group/News (id :55xxxxx) the first object's create_date is still 1323269266. It will give me again the 5 feeds. But I would like it to give me any new feeds after 1323269266. Any idea how?

A: Try a combination of since and until parameters rather than just since.


text:
Q: A continuous function whose Fourier Series diverges I have read several times that there exist many continuous functions whose Fourier series diverge at some points (sometimes even on a dense subset of the domain!). I tried to find an explicit example of them and the closest thing I found is This example by Fejer, a link from MSE. According to a comment responding to the question, it seems that Fejer's example cannot be represented by a graph. Here are my questions:
1.)What is the reason that the function cannot be represented by graph?
2.)Is there any function with the properties I mentioned that can be represented by graph?
3.)What is the intuitive reason that those functions have divergent Fourier series at some points?
I am aware that this question is a duplication of some already existing topics on MSE but none of the links I read give me a satisfactory answer. Also, could anyone give me a rough description of Fejer's function's behavior that explains why it can't be graphed? Thank you in advance.


text:
Q: require 'RMagick' raise error 'undefined symbol: XStringListToTextProperty' I have:

*

*Ubuntu 10.04.4 LTS

*ruby 1.9.1

*ImageMagick 6.8.6-5

*RMagick 2.13.2

When I try to do require 'RMagick' in irb I have an error:
LoadError: /usr/local/lib/ruby/gems/1.9.1/gems/rmagick-2.13.2/lib/RMagick2.so: undefined symbol: XStringListToTextProperty - /usr/local/lib/ruby/gems/1.9.1/gems/rmagick-2.13.2/lib/RMagick2.so
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/rmagick-2.13.2/lib/RMagick.rb:11:in `<top (required)>'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from (irb):1
from /usr/local/bin/irb:12:in `<main>'

A: The solution was simple: just remove imagemagick completely!
Instead apt-get remove imagemagick use next steps:
wget imagemagick.org/download/ImageMagick.tar.gz
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.8.2-10
./configure
make uninstall


text:
Q: Converter string separada por virgula em json Tenho a função:
$data ={
$G,3,"027",8,"sao paulo"
$H,3,"027",5,"curitiba"
$SP,3,"027",5,"brasilia",62312

}

          var dados = data.split(",");
          var json = [];
          var toSplit = dados.split(",");
          for (var i = 0; i < toSplit.length; i++) {
              json.push({
                      value : toSplit[0],
                      dados:[{
                        info: toSplit[i],
                      }]
             });
           }

O problema é que não retorna da forma correta, o esperado seria:
{ "$G": { "0": 3, "1": "027", "2": 8, "3": "sao paulo"

}, "$H": { "0": 3, "1": "027", "2": 5, "3": "curitiba"

}, "$SP": { "0": 3, "1": "027", "2": 5, "3": "brasilia", "4": 62312 } }

Gostaria de saber onde estou errando..
tks


text:
Q: Incoming Host Header Doubled I'm using an Nginx webserver on an Ubuntu 18.04 server with Gunicorn and Django. My server is currently down because the incoming host header is always duplicated.
When I make a request to the server, I get an error from Django saying
Invalid HTTP_HOST header: 'dt-testing.com,dt-testing.com'. The domain name provided is not valid according to RFC 1034/1035.

I cannot figure out where the incoming header is being doubled. I have combed my nginx.conf and sites-available files the best I can, and can't find anything suspicious at all.
The sites-available file:
#server { # redirection logic
#        listen 80; # port to listen on
#        #return 301 https://$host$request_uri*;
#        return 301 https://$host$request_uri; # could this be causing the doubling of the URL?
#}

server {
#    listen 443 ssl; # listen for HTTPS
    listen 80; # listen for HTTPS
    server_name dt-testing.com www.dt-testing.com; # server name to use

    location = /favicon.ico { access_log off; log_not_found off; } # site icon to use
    location /static/ { # location of static files
        root /websites/DT/DiamondTutoring/;
    }

    location / { # error is here?
        proxy_pass http://unix:/websites/DT/run/gunicorn.sock; # connector to gunicorn
        proxy_set_header Host $host;
        include proxy_params;
        #error_page 405 =200 $uri;
    }

#    ssl_certificate /etc/letsencrypt/live/dt-testing.com/fullchain.pem; # managed by Certbot
#    ssl_certificate_key /etc/letsencrypt/live/dt-testing.com/privkey.pem; # managed by Certbot

    rewrite_log on;
    error_log /var/log/nginx/error_log;

}

The nginx.conf file
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    #include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

#mail {
#   # See sample authentication script at:
#   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#   # auth_http localhost/auth.php;
#   # pop3_capabilities "TOP" "USER";
#   # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#   server {
#       listen     localhost:110;
#       protocol   pop3;
#       proxy      on;
#   }
#
#   server {
#       listen     localhost:143;
#       protocol   imap;
#       proxy      on;
#   }
#}

Is there anything that I'm missing? I can't figure out where the header would be duplicated and concatenated together.

A: I think your nginx.conf is setting the header twice:
proxy_set_header Host $host;
include proxy_params;

So the header is set once in sites-available/, and I would bet that you'll find a second copy inside the proxy_params file which you're including on the next line.

A: I figured out what the problem was. I suspect that cerbot renew updated the nginx software somehow, which made it render the configuration file above differently. The line proxy set header was the one doubling the incoming header, but because I had a bug in my Python code on the Django side, it wasn't working.


text:
Q: Is a DbContext per thread in Parallel.ForEach safe? I am working a contract right now to increase the performance of a back end services for a modern SaaS SPA web app that is using EF 6 as their ORM. The first thing I proposed was to introduce some multi-threading to their  back end service which is currently running single threaded. The lead software engineer has indicated we cannot do that because EF 6 is not thread-safe.
I am no expert on Entity Framework. My ORM of choice is XPO by DevExpress and I have done something similar to what is proposed below without issue using that ORM. Is this pattern inherently not safe using EF 6?
int[] ids;
using(var db = new ApplicationDbContext())
{
    // query to surface id's of records representing work to be done
    ids = GetIdsOfRecordsRepresentingSomeTask(db);
}

Parallel.ForEach(ids, id => {
    using(var db = new ApplicationDbContext())
    {
        var processor = new SomeTaskProcessor(db, id);
        processor.ExecuteLongRunningProcessThatReadsDbAndCreatesSomeNewRecords();
        db.SaveChanges();
    }
});

I have researched this, and I agree that DbContext is not thread-safe. The pattern I propose does use multiple threads, but a single DbContext is only every accessed by a single thread in a single-threaded fashion. The lead is telling me that DbContext is essentially a singleton under the covers and this code would ultimately mess up the database. I can't find anything to support this claim. Is the lead right on this?
Thanks

A: Your pattern is thread-safe. However, at least for SQL Server, if your concurrency is too high, you'll find that your total throughput drops off as contention for database resources increases.
In theory, Parallel.ForEach optimizes the number of threads, but in practice, I have found it allows too much concurrency in my applications.
You can control concurrency with the ParallelOptions optional parameter. Test your use case and see if the default concurrency works well for you.
Your comment: Keeping in mind that, right now anyway, that we are talking about 100's of ids in that code above where most id's represent work that does not end up in any changes to the database and are short lived while a hand full can take minutes to complete and ultimately add 10's of new records to the DB. What MaxDegreesOfParallelism value would you recommend off the top of your head?
Probably 2-3 based on your general description, but it depends on how database intensive ExecuteLongRunningProcessThatReadsDbAndCreatesSomeNewRecords is (vs. performing CPU-bound activities or waiting for IO from files, web service calls, etc). With more than that, if that method is mostly performing DB tasks, you're likely to get locking contention or overwhelm your IO subsystem (disks). Test in your environment to be sure.
It may be worth exploring why ExecuteLongRunningProcessThatReadsDbAndCreatesSomeNewRecords is taking so long to complete for a given Id.
UPDATE
Here's some test code to demonstrate that the threads do not block each other and indeed run concurrently. I removed the DbContext portion for simplicity and since it doesn't affect the threading issue.
class SomeTaskProcessor
{
    static Random rng = new Random();
    public int Id { get; private set; }
    public SomeTaskProcessor(int id) { Id = id; }
    public void ExecuteLongRunningProcessThatReadsDbAndCreatesSomeNewRecords()
    {
        Console.WriteLine($"Starting ID {Id}");
        System.Threading.Thread.Sleep(rng.Next(1000));
        Console.WriteLine($"Completing ID {Id}");
    }
}
class Program
{
    static void Main(string[] args)
    {
        int[] ids = Enumerable.Range(1, 100).ToArray();

        Parallel.ForEach(ids, id => {
                var processor = new SomeTaskProcessor(id);
                processor.ExecuteLongRunningProcessThatReadsDbAndCreatesSomeNewRecords();
        });
    }
}

A: Issue #1 - Memory Allocation
Every single iteration will create instance of DbContext which will lead to memory allocations. Garbage collector will need to deal with those allocations. If there will be constant memory pressure it will end up in performance degradation on application level.
Issue #2 - SQL overload
Based on written above during every single iteration you'll call SaveChanges() that will probably make a call to database. In case call to the database is/will be resource intensive you may end up with poorly performing database.
Issue #3 - Thread blocking
SaveChanges() is synchronous and will block the thread. In situation call to database takes significant amount of time, thread will just sit and wait. Same for 3rd party API calls. There will be no or small performance gain.
Issue #4 - Parallel.For* methods are not guaranteed to run in parallel

It is important to keep in mind that individual iterations in a Parallel.For, Parallel.ForEach or ForAll loop may but do not have to execute in parallel.

I think this is self explanatory.
Potential Pitfalls with PLINQ
Understanding Speedup in PLINQ

I am reading comments under the question and Eric J. answer I am afraid there is problem with approach to the problem and parallelism is not going to help.

Thanks for the answer Eric. Keeping in mind that, right now anyway, that we are talking about 100's of ids in that code above where most id's represent work that does not end up in any changes to the database and are short lived while a hand full can take minutes to complete and ultimately add 10's of new records to the DB. What MaxDegreesOfParallelism value would you recommend off the top of your head?
Ahh - yes I should have included that detail. In this instance the task being performed is very much IO bound calling out to third party web API to collect required information for processing. Once all the data is collected, it is processed and may result in some new records needing to be added to the database. There are a few queries to collect some additional information during the processing phase, but all those are performing fine.

If I am not completely wrong the problem are calls to 3rd party API synchronously, which blocks the thread.
I think async approach might help here to gather data from 3rd party API.
Also would help not allocating heap memory if not necessary. You can save changes at the end of execution with just one DbContext instance and just one database call.

UPDATE
Eric J. added test to test threads are not blocking each other(which they don't) and to test concurrent execution. Code below is his original code provided in his answer.
class SomeTaskProcessor
{
    static Random rng = new Random();
    public int Id { get; private set; }
    public SomeTaskProcessor(int id) { Id = id; }
    public void ExecuteLongRunningProcessThatReadsDbAndCreatesSomeNewRecords()
    {
        Console.WriteLine($"Starting ID {Id}");
        System.Threading.Thread.Sleep(rng.Next(1000));
        Console.WriteLine($"Completing ID {Id}");
    }
}

class Program
{
    static void Main(string[] args)
    {
        int[] ids = Enumerable.Range(1, 100).ToArray();

        Parallel.ForEach(ids, id => {
                var processor = new SomeTaskProcessor(id);
                processor.ExecuteLongRunningProcessThatReadsDbAndCreatesSomeNewRecords();
        });
    }
}

I made similar test. I created server to simulate internet IO with delayed response of 1 second. Before each test run API server was started and first request made. Test were run in Release config.
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase {
    // GET api/values
    [HttpGet]
    public async Task<ActionResult<IEnumerable<string>>> Get() {
        await Task.Delay(1000);

        return new string[] { "value1", "value2" };
    }
}

I have updated his code to call API endpoint. On my virtual machine it spun 5 thread and was executing on average 23 seconds.
class SomeTaskProcessor {
    private HttpClient http = new HttpClient() {
        BaseAddress = new Uri("http://localhost:49890/api/values")
    };

    public int Id { get; private set; }
    public SomeTaskProcessor(int id) { Id = id; }
    public void ExecuteLongRunningProcessThatReadsDbAndCreatesSomeNewRecords() {
        Console.WriteLine($"Starting ID {Id}. Thread Id: {Thread.CurrentThread.ManagedThreadId}");
        var response = http.GetAsync(String.Empty).GetAwaiter().GetResult();
        Console.WriteLine($"Completing ID {Id}. Response status code is {response.StatusCode}. Thread Id: {Thread.CurrentThread.ManagedThreadId}");
    }
}

class Program {
    static void Main(string[] args) {
        int[] ids = Enumerable.Range(1, 100).ToArray();;

        var stopwatch = new Stopwatch();

        stopwatch.Start();

        Parallel.ForEach(ids, id => {
            var processor = new SomeTaskProcessor(id);
            processor.ExecuteLongRunningProcessThatReadsDbAndCreatesSomeNewRecords();
        });

        // ~23 seconds

        stopwatch.Stop();

        Console.WriteLine(stopwatch.Elapsed.ToString());
    }
}

Console output:
Starting ID 51. Thread Id: 4
Starting ID 1. Thread Id: 1
Starting ID 2. Thread Id: 5
Starting ID 52. Thread Id: 9
Starting ID 3. Thread Id: 12
Completing ID 51. Response status code is OK. Thread Id: 4
Starting ID 53. Thread Id: 4
Completing ID 2. Response status code is OK. Thread Id: 5
Starting ID 4. Thread Id: 5
Starting ID 55. Thread Id: 14
Starting ID 6. Thread Id: 15
Completing ID 52. Response status code is OK. Thread Id: 9
Starting ID 56. Thread Id: 9
Completing ID 1. Response status code is OK. Thread Id: 1
Starting ID 7. Thread Id: 1
Completing ID 3. Response status code is OK. Thread Id: 12
Starting ID 9. Thread Id: 12
Starting ID 58. Thread Id: 16
Completing ID 53. Response status code is OK. Thread Id: 4
Starting ID 54. Thread Id: 4
Completing ID 4. Response status code is OK. Thread Id: 5
Starting ID 5. Thread Id: 5
Starting ID 11. Thread Id: 18
Completing ID 55. Response status code is OK. Thread Id: 14
Starting ID 59. Thread Id: 14
Starting ID 61. Thread Id: 20
Completing ID 56. Response status code is OK. Thread Id: 9
Starting ID 57. Thread Id: 9
Completing ID 7. Response status code is OK. Thread Id: 1
Starting ID 8. Thread Id: 1
Completing ID 9. Response status code is OK. Thread Id: 12
Starting ID 10. Thread Id: 12
Completing ID 6. Response status code is OK. Thread Id: 15
Starting ID 12. Thread Id: 15
Starting ID 14. Thread Id: 22
Completing ID 5. Response status code is OK. Thread Id: 5
Starting ID 15. Thread Id: 5
Completing ID 54. Response status code is OK. Thread Id: 4
Starting ID 62. Thread Id: 4
Completing ID 58. Response status code is OK. Thread Id: 16
Starting ID 66. Thread Id: 16
Starting ID 68. Thread Id: 23
Completing ID 11. Response status code is OK. Thread Id: 18
Starting ID 19. Thread Id: 18
Completing ID 59. Response status code is OK. Thread Id: 14
Starting ID 60. Thread Id: 14
Starting ID 21. Thread Id: 24
Completing ID 57. Response status code is OK. Thread Id: 9
Starting ID 69. Thread Id: 9
Completing ID 12. Response status code is OK. Thread Id: 15
Starting ID 13. Thread Id: 15
Completing ID 61. Response status code is OK. Thread Id: 20
Starting ID 73. Thread Id: 20
Completing ID 10. Response status code is OK. Thread Id: 12
Completing ID 8. Response status code is OK. Thread Id: 1
Starting ID 22. Thread Id: 12
Starting ID 26. Thread Id: 1
Starting ID 75. Thread Id: 25
Completing ID 15. Response status code is OK. Thread Id: 5
Starting ID 16. Thread Id: 5
Completing ID 62. Response status code is OK. Thread Id: 4
Starting ID 63. Thread Id: 4
Completing ID 66. Response status code is OK. Thread Id: 16
Starting ID 67. Thread Id: 16
Completing ID 14. Response status code is OK. Thread Id: 22
Starting ID 30. Thread Id: 22
Starting ID 32. Thread Id: 26
Starting ID 76. Thread Id: 27
Completing ID 60. Response status code is OK. Thread Id: 14
Starting ID 77. Thread Id: 14
Completing ID 19. Response status code is OK. Thread Id: 18
Starting ID 20. Thread Id: 18
Completing ID 69. Response status code is OK. Thread Id: 9
Starting ID 70. Thread Id: 9
Completing ID 21. Response status code is OK. Thread Id: 24
Starting ID 33. Thread Id: 24
Completing ID 13. Response status code is OK. Thread Id: 15
Starting ID 35. Thread Id: 15
Completing ID 73. Response status code is OK. Thread Id: 20
Starting ID 74. Thread Id: 20
Completing ID 22. Response status code is OK. Thread Id: 12
Starting ID 23. Thread Id: 12
Completing ID 26. Response status code is OK. Thread Id: 1
Starting ID 27. Thread Id: 1
Completing ID 68. Response status code is OK. Thread Id: 23
Starting ID 81. Thread Id: 23
Starting ID 39. Thread Id: 29
Completing ID 67. Response status code is OK. Thread Id: 16
Starting ID 83. Thread Id: 16
Completing ID 75. Response status code is OK. Thread Id: 25
Completing ID 30. Response status code is OK. Thread Id: 22
Starting ID 31. Thread Id: 22
Completing ID 16. Response status code is OK. Thread Id: 5
Starting ID 87. Thread Id: 25
Starting ID 17. Thread Id: 5
Completing ID 63. Response status code is OK. Thread Id: 4
Starting ID 64. Thread Id: 4
Starting ID 89. Thread Id: 30
Completing ID 76. Response status code is OK. Thread Id: 27
Starting ID 90. Thread Id: 27
Completing ID 32. Response status code is OK. Thread Id: 26
Starting ID 40. Thread Id: 26
Completing ID 77. Response status code is OK. Thread Id: 14
Starting ID 78. Thread Id: 14
Starting ID 42. Thread Id: 31
Completing ID 70. Response status code is OK. Thread Id: 9
Starting ID 71. Thread Id: 9
Completing ID 27. Response status code is OK. Thread Id: 1
Starting ID 28. Thread Id: 1
Completing ID 74. Response status code is OK. Thread Id: 20
Starting ID 92. Thread Id: 20
Completing ID 35. Response status code is OK. Thread Id: 15
Starting ID 36. Thread Id: 15
Completing ID 81. Response status code is OK. Thread Id: 23
Starting ID 82. Thread Id: 23
Completing ID 33. Response status code is OK. Thread Id: 24
Starting ID 34. Thread Id: 24
Completing ID 20. Response status code is OK. Thread Id: 18
Starting ID 43. Thread Id: 18
Completing ID 23. Response status code is OK. Thread Id: 12
Starting ID 24. Thread Id: 12
Starting ID 96. Thread Id: 32
Completing ID 39. Response status code is OK. Thread Id: 29
Completing ID 17. Response status code is OK. Thread Id: 5
Starting ID 18. Thread Id: 5
Starting ID 47. Thread Id: 29
Completing ID 64. Response status code is OK. Thread Id: 4
Starting ID 65. Thread Id: 4
Completing ID 87. Response status code is OK. Thread Id: 25
Starting ID 88. Thread Id: 25
Completing ID 31. Response status code is OK. Thread Id: 22
Completing ID 83. Response status code is OK. Thread Id: 16
Starting ID 84. Thread Id: 16
Starting ID 49. Thread Id: 22
Starting ID 97. Thread Id: 33
Completing ID 90. Response status code is OK. Thread Id: 27
Starting ID 91. Thread Id: 27
Completing ID 40. Response status code is OK. Thread Id: 26
Starting ID 41. Thread Id: 26
Completing ID 89. Response status code is OK. Thread Id: 30
Starting ID 98. Thread Id: 30
Completing ID 78. Response status code is OK. Thread Id: 14
Starting ID 79. Thread Id: 14
Starting ID 100. Thread Id: 34
Completing ID 36. Response status code is OK. Thread Id: 15
Starting ID 37. Thread Id: 15
Completing ID 92. Response status code is OK. Thread Id: 20
Starting ID 93. Thread Id: 20
Completing ID 42. Response status code is OK. Thread Id: 31
Completing ID 28. Response status code is OK. Thread Id: 1
Starting ID 29. Thread Id: 1
Completing ID 24. Response status code is OK. Thread Id: 12
Starting ID 25. Thread Id: 12
Completing ID 82. Response status code is OK. Thread Id: 23
Completing ID 71. Response status code is OK. Thread Id: 9
Starting ID 72. Thread Id: 9
Completing ID 43. Response status code is OK. Thread Id: 18
Starting ID 44. Thread Id: 18
Completing ID 96. Response status code is OK. Thread Id: 32
Completing ID 65. Response status code is OK. Thread Id: 4
Completing ID 88. Response status code is OK. Thread Id: 25
Completing ID 49. Response status code is OK. Thread Id: 22
Starting ID 50. Thread Id: 22
Completing ID 47. Response status code is OK. Thread Id: 29
Starting ID 48. Thread Id: 29
Completing ID 18. Response status code is OK. Thread Id: 5
Completing ID 34. Response status code is OK. Thread Id: 24
Completing ID 84. Response status code is OK. Thread Id: 16
Starting ID 85. Thread Id: 16
Completing ID 97. Response status code is OK. Thread Id: 33
Completing ID 41. Response status code is OK. Thread Id: 26
Completing ID 79. Response status code is OK. Thread Id: 14
Starting ID 80. Thread Id: 14
Completing ID 100. Response status code is OK. Thread Id: 34
Completing ID 93. Response status code is OK. Thread Id: 20
Starting ID 94. Thread Id: 20
Completing ID 29. Response status code is OK. Thread Id: 1
Completing ID 98. Response status code is OK. Thread Id: 30
Starting ID 99. Thread Id: 30
Completing ID 44. Response status code is OK. Thread Id: 18
Starting ID 45. Thread Id: 18
Completing ID 25. Response status code is OK. Thread Id: 12
Completing ID 37. Response status code is OK. Thread Id: 15
Starting ID 38. Thread Id: 15
Completing ID 72. Response status code is OK. Thread Id: 9
Completing ID 91. Response status code is OK. Thread Id: 27
Completing ID 50. Response status code is OK. Thread Id: 22
Completing ID 48. Response status code is OK. Thread Id: 29
Completing ID 85. Response status code is OK. Thread Id: 16
Starting ID 86. Thread Id: 16
Completing ID 80. Response status code is OK. Thread Id: 14
Completing ID 94. Response status code is OK. Thread Id: 20
Starting ID 95. Thread Id: 20
Completing ID 99. Response status code is OK. Thread Id: 30
Completing ID 45. Response status code is OK. Thread Id: 18
Starting ID 46. Thread Id: 18
Completing ID 38. Response status code is OK. Thread Id: 15
Completing ID 86. Response status code is OK. Thread Id: 16
Completing ID 95. Response status code is OK. Thread Id: 20
Completing ID 46. Response status code is OK. Thread Id: 18
00:00:23.6046580

C:\Program Files\dotnet\dotnet.exe (process 7208) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .

Then I created async version of the same code. Execition took on average 7 seconds.
class SomeTaskProcessor {
    private HttpClient http = new HttpClient() {
        BaseAddress = new Uri("http://localhost:49890/api/values")
    };

    public int Id { get; private set; }
    public SomeTaskProcessor(int id) { Id = id; }
    public async Task ExecuteLongRunningProcessThatReadsDbAndCreatesSomeNewRecords() {
        Console.WriteLine($"Starting ID {Id}");
        var response = await http.GetAsync(String.Empty);
        Console.WriteLine($"Completing ID {Id}. Response status code is {response.StatusCode}");
    }
}

class Program {
    static async Task Main(string[] args) {
        int[] ids = Enumerable.Range(1, 100).ToArray();;

        var stopwatch = new Stopwatch();

        stopwatch.Start();

        var tasks = ids.Select(id => {
            var processor = new SomeTaskProcessor(id);
            return processor.ExecuteLongRunningProcessThatReadsDbAndCreatesSomeNewRecords();
        }).ToArray();

        await Task.WhenAll(tasks);

        // ~8 seconds

        stopwatch.Stop();

        Console.WriteLine(stopwatch.Elapsed.ToString());
    }
}

Console output:
Starting ID 1. Thread Id: 1
Starting ID 2. Thread Id: 1
Starting ID 3. Thread Id: 1
Starting ID 4. Thread Id: 1
Starting ID 5. Thread Id: 1
Starting ID 6. Thread Id: 1
Starting ID 7. Thread Id: 1
Starting ID 8. Thread Id: 1
Starting ID 9. Thread Id: 1
Starting ID 10. Thread Id: 1
Starting ID 11. Thread Id: 1
Starting ID 12. Thread Id: 1
Starting ID 13. Thread Id: 1
Starting ID 14. Thread Id: 1
Starting ID 15. Thread Id: 1
Starting ID 16. Thread Id: 1
Starting ID 17. Thread Id: 1
Starting ID 18. Thread Id: 1
Starting ID 19. Thread Id: 1
Starting ID 20. Thread Id: 1
Starting ID 21. Thread Id: 1
Starting ID 22. Thread Id: 1
Starting ID 23. Thread Id: 1
Starting ID 24. Thread Id: 1
Starting ID 25. Thread Id: 1
Starting ID 26. Thread Id: 1
Starting ID 27. Thread Id: 1
Starting ID 28. Thread Id: 1
Starting ID 29. Thread Id: 1
Starting ID 30. Thread Id: 1
Starting ID 31. Thread Id: 1
Starting ID 32. Thread Id: 1
Starting ID 33. Thread Id: 1
Starting ID 34. Thread Id: 1
Starting ID 35. Thread Id: 1
Starting ID 36. Thread Id: 1
Starting ID 37. Thread Id: 1
Starting ID 38. Thread Id: 1
Starting ID 39. Thread Id: 1
Starting ID 40. Thread Id: 1
Starting ID 41. Thread Id: 1
Starting ID 42. Thread Id: 1
Starting ID 43. Thread Id: 1
Starting ID 44. Thread Id: 1
Starting ID 45. Thread Id: 1
Starting ID 46. Thread Id: 1
Starting ID 47. Thread Id: 1
Starting ID 48. Thread Id: 1
Starting ID 49. Thread Id: 1
Starting ID 50. Thread Id: 1
Starting ID 51. Thread Id: 1
Starting ID 52. Thread Id: 1
Starting ID 53. Thread Id: 1
Starting ID 54. Thread Id: 1
Starting ID 55. Thread Id: 1
Starting ID 56. Thread Id: 1
Starting ID 57. Thread Id: 1
Starting ID 58. Thread Id: 1
Starting ID 59. Thread Id: 1
Starting ID 60. Thread Id: 1
Starting ID 61. Thread Id: 1
Starting ID 62. Thread Id: 1
Starting ID 63. Thread Id: 1
Starting ID 64. Thread Id: 1
Starting ID 65. Thread Id: 1
Starting ID 66. Thread Id: 1
Starting ID 67. Thread Id: 1
Starting ID 68. Thread Id: 1
Starting ID 69. Thread Id: 1
Starting ID 70. Thread Id: 1
Starting ID 71. Thread Id: 1
Starting ID 72. Thread Id: 1
Starting ID 73. Thread Id: 1
Starting ID 74. Thread Id: 1
Starting ID 75. Thread Id: 1
Starting ID 76. Thread Id: 1
Starting ID 77. Thread Id: 1
Starting ID 78. Thread Id: 1
Starting ID 79. Thread Id: 1
Starting ID 80. Thread Id: 1
Starting ID 81. Thread Id: 1
Starting ID 82. Thread Id: 1
Starting ID 83. Thread Id: 1
Starting ID 84. Thread Id: 1
Starting ID 85. Thread Id: 1
Starting ID 86. Thread Id: 1
Starting ID 87. Thread Id: 1
Starting ID 88. Thread Id: 1
Starting ID 89. Thread Id: 1
Starting ID 90. Thread Id: 1
Starting ID 91. Thread Id: 1
Starting ID 92. Thread Id: 1
Starting ID 93. Thread Id: 1
Starting ID 94. Thread Id: 1
Starting ID 95. Thread Id: 1
Starting ID 96. Thread Id: 1
Starting ID 97. Thread Id: 1
Starting ID 98. Thread Id: 1
Starting ID 99. Thread Id: 1
Starting ID 100. Thread Id: 1
Completing ID 3. Response status code is OK. Thread Id: 14
Completing ID 10. Response status code is OK. Thread Id: 8
Completing ID 8. Response status code is OK. Thread Id: 9
Completing ID 7. Response status code is OK. Thread Id: 15
Completing ID 11. Response status code is OK. Thread Id: 14
Completing ID 4. Response status code is OK. Thread Id: 8
Completing ID 9. Response status code is OK. Thread Id: 9
Completing ID 12. Response status code is OK. Thread Id: 8
Completing ID 13. Response status code is OK. Thread Id: 8
Completing ID 6. Response status code is OK. Thread Id: 8
Completing ID 17. Response status code is OK. Thread Id: 8
Completing ID 18. Response status code is OK. Thread Id: 8
Completing ID 21. Response status code is OK. Thread Id: 8
Completing ID 24. Response status code is OK. Thread Id: 8
Completing ID 20. Response status code is OK. Thread Id: 8
Completing ID 30. Response status code is OK. Thread Id: 8
Completing ID 22. Response status code is OK. Thread Id: 8
Completing ID 34. Response status code is OK. Thread Id: 8
Completing ID 32. Response status code is OK. Thread Id: 9
Completing ID 33. Response status code is OK. Thread Id: 9
Completing ID 39. Response status code is OK. Thread Id: 9
Completing ID 35. Response status code is OK. Thread Id: 8
Completing ID 2. Response status code is OK. Thread Id: 9
Completing ID 44. Response status code is OK. Thread Id: 9
Completing ID 23. Response status code is OK. Thread Id: 8
Completing ID 31. Response status code is OK. Thread Id: 14
Completing ID 38. Response status code is OK. Thread Id: 14
Completing ID 43. Response status code is OK. Thread Id: 8
Completing ID 50. Response status code is OK. Thread Id: 9
Completing ID 1. Response status code is OK. Thread Id: 15
Completing ID 48. Response status code is OK. Thread Id: 14
Completing ID 27. Response status code is OK. Thread Id: 8
Completing ID 49. Response status code is OK. Thread Id: 9
Completing ID 28. Response status code is OK. Thread Id: 15
Completing ID 14. Response status code is OK. Thread Id: 14
Completing ID 29. Response status code is OK. Thread Id: 8
Completing ID 26. Response status code is OK. Thread Id: 14
Completing ID 15. Response status code is OK. Thread Id: 9
Completing ID 19. Response status code is OK. Thread Id: 8
Completing ID 25. Response status code is OK. Thread Id: 15
Completing ID 5. Response status code is OK. Thread Id: 14
Completing ID 40. Response status code is OK. Thread Id: 9
Completing ID 60. Response status code is OK. Thread Id: 8
Completing ID 37. Response status code is OK. Thread Id: 15
Completing ID 41. Response status code is OK. Thread Id: 14
Completing ID 16. Response status code is OK. Thread Id: 9
Completing ID 63. Response status code is OK. Thread Id: 14
Completing ID 36. Response status code is OK. Thread Id: 14
Completing ID 42. Response status code is OK. Thread Id: 9
Completing ID 45. Response status code is OK. Thread Id: 14
Completing ID 64. Response status code is OK. Thread Id: 14
Completing ID 53. Response status code is OK. Thread Id: 9
Completing ID 61. Response status code is OK. Thread Id: 15
Completing ID 52. Response status code is OK. Thread Id: 14
Completing ID 67. Response status code is OK. Thread Id: 14
Completing ID 74. Response status code is OK. Thread Id: 14
Completing ID 75. Response status code is OK. Thread Id: 14
Completing ID 62. Response status code is OK. Thread Id: 15
Completing ID 78. Response status code is OK. Thread Id: 8
Completing ID 66. Response status code is OK. Thread Id: 15
Completing ID 55. Response status code is OK. Thread Id: 14
Completing ID 83. Response status code is OK. Thread Id: 15
Completing ID 59. Response status code is OK. Thread Id: 14
Completing ID 68. Response status code is OK. Thread Id: 8
Completing ID 85. Response status code is OK. Thread Id: 15
Completing ID 47. Response status code is OK. Thread Id: 9
Completing ID 72. Response status code is OK. Thread Id: 14
Completing ID 65. Response status code is OK. Thread Id: 8
Completing ID 84. Response status code is OK. Thread Id: 8
Completing ID 70. Response status code is OK. Thread Id: 14
Completing ID 87. Response status code is OK. Thread Id: 14
Completing ID 56. Response status code is OK. Thread Id: 8
Completing ID 90. Response status code is OK. Thread Id: 15
Completing ID 76. Response status code is OK. Thread Id: 9
Completing ID 73. Response status code is OK. Thread Id: 14
Completing ID 69. Response status code is OK. Thread Id: 8
Completing ID 86. Response status code is OK. Thread Id: 15
Completing ID 81. Response status code is OK. Thread Id: 9
Completing ID 91. Response status code is OK. Thread Id: 15
Completing ID 77. Response status code is OK. Thread Id: 9
Completing ID 57. Response status code is OK. Thread Id: 15
Completing ID 98. Response status code is OK. Thread Id: 9
Completing ID 100. Response status code is OK. Thread Id: 15
Completing ID 79. Response status code is OK. Thread Id: 9
Completing ID 58. Response status code is OK. Thread Id: 15
Completing ID 80. Response status code is OK. Thread Id: 8
Completing ID 82. Response status code is OK. Thread Id: 14
Completing ID 89. Response status code is OK. Thread Id: 9
Completing ID 88. Response status code is OK. Thread Id: 15
Completing ID 97. Response status code is OK. Thread Id: 8
Completing ID 51. Response status code is OK. Thread Id: 14
Completing ID 94. Response status code is OK. Thread Id: 9
Completing ID 93. Response status code is OK. Thread Id: 15
Completing ID 71. Response status code is OK. Thread Id: 8
Completing ID 46. Response status code is OK. Thread Id: 14
Completing ID 54. Response status code is OK. Thread Id: 9
Completing ID 95. Response status code is OK. Thread Id: 15
Completing ID 92. Response status code is OK. Thread Id: 8
Completing ID 99. Response status code is OK. Thread Id: 14
Completing ID 96. Response status code is OK. Thread Id: 9
00:00:06.7737961

C:\Program Files\dotnet\dotnet.exe (process 296) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .

I believe 23 seconds vs 7 seconds are enough of proof to say it is async/await scenario.


text:
Q: OTA Application Provisioning implementation on Android i am trying to implement OTA settings update for my app.
didn't find any tutorial regarding this issue.
the settings file would be an XML file.
Thanks.

A: There is no built-in "OTA settings update" in Android.
If "OTA settings update" implies an update to your application itself, download the APK to external storage and call startActivity() with an ACTION_VIEW Intent, a Uri pointing to that (world-readable), and the magic MIME type (application/vnd.android.package-archive).
If "OTA settings update" is data, download what you want from your Web server.


text:
Q: Supremum of continuous function on an unbounded interval Let f(x) be a continuous function on an unbounded interval $[a,\infty)$. If $\lim_{x\to\infty}f(x)=c<1$ and $f(x)<1$ $\forall x\geq a$, can we conclude that $\sup\{f(x)\}<1$? Why or why not?

A: I think yes.
Since $\lim_{x \to \infty}f(x)=c<1$, for $\epsilon$ small enough there exists $M >a$ such that $f(x)<c+\epsilon<1$ for all $x>M$.
By contradiction, assume that $\sup_{x\geq a} f(x)=1$. Since $f(x)<1$ for all $x>M$, we must have $\sup_{a\leq x \leq M} f(x)=1$. Since $f(x)$ is continuous and $[a,M]$ is compact, $f$ achieves supremum on $[a.M]$, i.e., there exists $x_0 \in [a,M]$ such that $f(x_0)=1$, contradiction to assumption $f(x)<1$ for all $x \geq a$.

A: By contradiction : if the supremum is equal to $1$ there is an increasing sequence $u_n$ such that $f(u_n) \rightarrow 1$.
Since $f(\infty) = c < 1$, $u_n$ must converge to some $s \in [a, \infty)$, but by continuity of $f$, $f(u_n) \rightarrow f(s) = 1$ which contradicts the fact that $f<1$

A: yes:
we know that: $\lim _{x \rightarrow \infty} f(x)=c<1$.
we can infer from this that there exists a b, such that for all x>b: $f\left(x\right)<1-\dfrac{1-c}{2}$.
now lets look at the values of f on [a,b]. the function is continues, and therefore :
$$sup_{x\in\left[a,b\right]}\left(f\left(x\right)\right)=max{}_{x\in\left[a,b\right]}\left(f\left(x\right)\right)$$
but we know that: $max_{x\in\left[a,b\right]}\left(f\left(x\right)\right)<1$. All together we get that for every x>a: $$f\left(x\right)\leq max\left(max_{x\in\left[a,b\right]}\left(f\left(x\right)\right),1-\dfrac{1-c}{2}\right)<1$$
which finishes the proof


text:
Q: How to convert TIF image to char array in c++ I'm working with tesseract ocr.I have done it by console. But during GUI of C++ I faced some problem.  In console I have used char array to get input image. But now I'm uploading an image by openFileDialog. I need to convert it in char array. But giving many error. I'm giving my code which is written under a recogition button. How can I solve my problem? I have seen this. It's not helpful for me.
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e)
{
             char image[256];
             //cin>>image;//while I'm taking input in console
             image=im;//im is the bitmap image which I have loaded.
             PIX   *pixs = pixRead(image);

             STRING text_out;
             api.ProcessPages(image, NULL, 0, &text_out);

            //cout<<text_out.string();
            ofstream myfile;
            myfile.open ("example.txt");
            myfile << text_out.string();
            myfile.close();
}


text:
Q: Allow the window to calculate before continuing Javascript (GAS) I have seen a lot of duplicates on this subject, but I don't see how to actually get done what needs to be done.
I have a list of URLs in one sheet tab and an IMPORTXML() function in another. I'm writing a script to copy each URL to the second tab then perform an action based on the output of the IMPORTXML(). For this to work, I need a slight delay in the script to ensure the IMPORTXML() has calculated before continuing. setTimeout() doesn't seem appropriate here, because I need the other parameters of the script (which row it's checking, etc) to be calculated based on outputs. Help!
function test(){
  var sh = SpreadsheetApp.getActiveSpreadsheet();
  var list = sh.getSheetByName("Dec 2018").getRange(row,3,sh.getSheetByName("Dec 2018").getLastRow()-row).getValues();
  var check = sh.getSheetByName("Check");
  for(var row = 2;row<500;row++){
  check.getRange(1,1).setValue(list[row-2][0]);
  //wait right here
  //other code to run based on the output of the =IMPORTXML() formula on the Check sheet
  }
}

A: To insert a slight delay use Utilities.sleep(milliseconds) with a milliseconds value big enough to wait the slowest recalculation time (I think that it's 30000 ms for a single formula because it's the execution time limit for custom functions). If you want to optimize this time, maybe you will want to use a technique like exponential back-off
Note: The Window object isn't available on Google Apps Script server side code execution, so setTimeout() can't be used.


text:
Q: JScrollPane not showing up So I am making a list of names of the players that have previously played the games. I came across the problem that the list is not adding a scroll pane to it after the names list becomes way too long without scrolling. I have tried to implement the scroll bar this way but with no success. What am I doing wrong?
    Insets insets = pane.getInsets();

    Dimension size = Player1.getPreferredSize();

    Player1.setBounds(90 + insets.left, 50 + insets.top, 250, 40);
        size = Player2.getPreferredSize();
    Player2.setBounds(450 + insets.left, 50 + insets.top, 250, 40);
        size = P1List.getPreferredSize();
    P1List.setBounds(90 + insets.left, 100 + insets.top, 250, 350);
        size = P2List.getPreferredSize();
    P2List.setBounds(450 + insets.left, 100 + insets.top, 250, 350);
    Ok.setBounds(650 + insets.left, 500 + insets.top, 100, 30);
        size = Ok.getPreferredSize();

    final JScrollPane sp1 = new JScrollPane();
    sp1.setViewportView(P1List);

    final JScrollPane sp2 = new JScrollPane();
    sp2.setViewportView(P2List);

    pane.add(Player1);
    pane.add(Player2);
    pane.add(P1List);
    pane.add(P2List);
    pane.add(sp1);
    pane.add(sp2);
    pane.add(Ok);


text:
Q: JAX-B handling double nested elements from xml Basically im trying to unmarhall this
<polls xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="polls.xsd">
<poll id="1">
    <title>WSD Meeting</title>
    <state>Open</state>
    <userID>1</userID>
    <datecreated>88/88/1996</datecreated>
    <location>UTS</location>
    <description>Meeting for assignment</description>
    <meetings>
        <meeting option ='1'>
            <time>12:00</time>
            <date>99/88/1996</date>
            <responses>
                <response>John Doe</response>
            </responses>
        </meeting>
        <meeting option ='2'>
            <time>12:00</time>
            <date>99/88/1996</date>
            <responses>
                <response>John Doe</response>
                <response>John Smith</response>
            </responses>
        </meeting>
    </meetings>
</poll>
  </polls>

and the unmarshalling hits trouble when I get to the Meetings
this is the Poll class
@XmlAccessorType(XmlAccessType.FIELD)
public class Poll implements Serializable {
@XmlAttribute
private int ID;
private String title;
private int state;
private int userID;
private String datecreated;
private String location;
private String description;
@XmlElement(name = "meetings")
private ArrayList<Meeting> meetings = new ArrayList<Meeting>();

and this is the meeting class
@XmlAccessorType(XmlAccessType.FIELD)
public class Meeting implements Serializable {
@XmlAttribute
private int option;
private String time;
private String date;
@XmlElement(name = "responses")
private ArrayList<Response> responses = new ArrayList<Response>();

basically the data from poll is getting marshalled in fine (i have checked this) but once it hits meetings it makes the list with one entry that is empty am i missing something?

A: You seem to be missing a Meetings class (corresponding to <meetings> )wrapping the Meeting instances (corresponding to <meeting>).
If you generated the JAXB using a tool like XJC this wouldn't have happened, so it's not clear how you ended up in this situation (maybe you were trying to customize something).   But maybe this helps in any case.


text:
Q: JQuery printElement prints the whole page in Internet Explorer I am using jQuery printElement in order to print the content of a div.
It's working perfectly on Safari, Chrome and Firefox but when I try with Internet Explorer (all versions), it prints the whole page instead of the div only. Why is that? What can I do?
Here's the code used to print :
$('.print_button').each(function() {
    $(this).click(function() {
        $(this).closest('.details').find('.div_to_print').printElement({
            pageTitle: '...',
            overrideElementCSS: [
                '<?php echo stylesheet_path("print.css"); ?>'
            ]
        });
    });
});

A: Have you tried using simply CSS:
@media print {
      .element-not-to-print {
          display: none;
      }
}

OR
@media print {
      .element-not-to-print {
          visibility: hidden;
      }
}

Support for Media Queries is IE9+ : http://caniuse.com/css-mediaqueries
For IE7 and IE8 use check this article. Or just go straight to the point by adding this JavaScript file to your project and continue using the good old Media Queries that will not kill your performance like jQuery.


text:
Q: "Gatsby build" orders jsx improperly, but gatsby develop doesn't An  tag with a
 inside is generated with the entire  tag (including closing tag) before the
 that is supposed to be inside it. When running "gatsby develop" this never happens and before today "gatsby build" didn't have this issue either.
For reference:

                    <InfoOverlay name={props.status} color={props.statusColor ? props.statusColor : "light"} overlayLink={props.overlayLink} />

                        <Icon props={props} />

{props.name}

I can't seem to find this issue anywhere else, but that could be the case of me not knowing where to look (this is my first gatsby project and my first relatively complex react project). If this is too little information, let me know and I can send more. Any help would be appreciated!

A: All of the contents of <InfoOverlay /> (which I didn't include the code to) are wrapped in a separate  tag, causing the renderer to work improperly. This appears to be neither Gatsby nor React breaking, but the browser. Remedy is to remove the link and make it visually appear nested, rather than actually nest them.
This post covers the core of the problem: https://stackoverflow.com/a/9883044/9214204


text:
Q: Htaccess redirect по маске Возможно ли редиректить по слову?
Например кулхацкер, пытаясь найди адрес админки на сайте, перебирает с помощью брута все адреса админок популярных cms (наивный:]).
Так вот собственно сабж. Можно ли редиректить, если в адресе встречается слово admin, ну и его вариации.
Гугл не затащил.
A: да можно.

Syntax:    RewriteCond TestString CondPattern
REQUEST_URI
The path component of the requested URI, such as "/index.html". This notably excludes the query string which is available as as its own variable named QUERY_STRING.

REQUEST_URI
Часть URI, типа "/index.html". Эта переменная не включает строку поиска (после знака вопроса в строке типа "/index.html?search=term"), для обработки поиска существует отдельная переменная - QUERY_STRING .

Remember: CondPattern is a perl compatible regular expression with some additions:

Помните: CondPattern это регулярное выражение perl c некоторыми дополнениями.

к счастью на SO подобный вопрос не продержался бы и пяти минут.


text:
Q: align the link_to with the select tag ruby on rails I'm using "x" button for closing a small form on my project. I want to align the button with the other fields just like this   Here you can see the x link_to is aligned with the other forms. But this is what I have right now:
I'm stuck with this, I tried to manipulate the col- but I can't get my desired output. This is the code:

  <%= f.label :assembled_product_id %>
  <%= f.select :assembled_product_id,options_from_collection_for_select(AssembledProduct.all,:id, :name, :selected => f.object.assembled_product_id),{include_blank: true}, class:"select2", required: true, onchange: "setGroupPrice(this.id, this.value);" %>

    <%= f.label :unit_price, "Unit Price" %>
    <%= f.number_field :unit_price, class: "form-control", step: 0.01, min: 0, required: true, value: "0.00", onblur: "setTwoNumberDecimal(this)" %>

    <%= f.label :discount_rate, "Discount (in %)" %>
    <%= f.number_field :discount_rate, class:" form-control", step: 0.01, min: 0, required: true, value: "0.00", onblur: "setTwoNumberDecimal(this)" %>

    <%= f.label :qty, "Qty" %>

      <%= f.number_field :qty, class: "form-control qty_size", min: 1, step: 1, required: true, value: "0" %>

    <%= f.label :unit %>
    <%= f.select :unit,options_from_collection_for_select(Unit.all,:name, :name, :selected => f.object.unit),{include_blank: true}, class:"select2", required: true %>

      <%=link_to_remove_association "x", f, class:"btn btn-danger btn-simple btn-xs pull-right" %>


text:
Q: Actions must be plain objects. Use custom middleware for async actions. after adding redux-thunk and using it as a middleware Actions must be plain objects. Use custom middleware for async actions.
This is the error and this function is pointed

this.props.registerUser(newUser);

see the next code snippet!
redux-thunk is used for referring plain js object but not working
This is my action creator file :
import { GET_ERRORS } from "./types";
import axios from "axios";

// Register User
export const registerUser = userData => dispatch => {
axios
.post("/api/users/register", userData)
.then(res => console.log(res))
.catch(err =>
  dispatch({
    type: GET_ERRORS,
    payload: err.response.data
  })
 );
};

This is my react registration page :
import React, { Component } from "react";
import PropTypes from "prop-types";
// import { withRouter } from 'react-router-dom';
import classnames from "classnames";
import { connect } from "react-redux";
import { registerUser } from "../../actions/authActions";

class Register extends Component {
  constructor() {
    super();
    this.state = {
      name: "",
      email: "",
      password: "",
      password2: "",
      errors: {}
    };

    this.onChange = this.onChange.bind(this);
    this.onSubmit = this.onSubmit.bind(this);
  }

  componentWillReceiveProps(nextProps) {
    if (nextProps.errors) {
      this.setState({ errors: nextProps.errors });
    }
  }

  onChange(event) {
    this.setState({ [event.target.name]: event.target.value });
  }
  onSubmit(event) {
    event.preventDefault();
    const newUser = {
      name: this.state.name,
      email: this.state.email,
      password: this.state.password,
      confirm_password: this.state.password2
    };
    this.props.registerUser(newUser);
  }
  render() {
    const { errors } = this.state;

    return (

Sign Up

                Create your SocioStalker account

              <form noValidate onSubmit={this.onSubmit}>

                  <input
                    type="text"
                    className={classnames("form-control form-control-lg", {
                      "is-invalid": errors.name
                    })}
                    placeholder="Name"
                    name="name"
                    value={this.state.name}
                    onChange={this.onChange}
                  />

{errors.name}

                  <input
                    type="email"
                    className={classnames("form-control form-control-lg", {
                      "is-invalid": errors.email
                    })}
                    placeholder="Email Address"
                    name="email"
                    value={this.state.email}
                    onChange={this.onChange}
                  />

{errors.email}

                    This site uses Gravatar so if you want a profile image, use
                    a Gravatar email

                  <input
                    type="password"
                    className={classnames("form-control form-control-lg", {
                      "is-invalid": errors.password
                    })}
                    placeholder="Password"
                    name="password"
                    value={this.state.password}
                    onChange={this.onChange}
                  />

{errors.password}

                  <input
                    type="password"
                    className={classnames("form-control form-control-lg", {
                      "is-invalid": errors.confirm_password
                    })}
                    placeholder="Confirm Password"
                    name="password2"
                    value={this.state.password2}
                    onChange={this.onChange}
                  />

                    {errors.confirm_password}

                <input type="submit" className="btn btn-info btn-block mt-4" />
              </form>

    );
  }
}

Register.propTypes = {
  registerUser: PropTypes.func.isRequired,
  auth: PropTypes.object.isRequired,
  errors: PropTypes.object.isRequired
};

const mapStateToProps = state => ({
  auth: state.auth,
  errors: state.errors
});

export default connect(
  mapStateToProps,
  { registerUser }
)(Register);

Store config file:
import { createStore, applyMiddleware, compose } from "redux";
import thunk from "redux-thunk";
import rootReducer from "./reducers";
import { composeWithDevTools } from "redux-devtools-extension";

const initialState = {};

const middleware = [thunk];
const store = createStore(
  rootReducer,
  initialState,
  compose(
    composeWithDevTools(),
    applyMiddleware(...middleware)
  )
);

export default store;

A: Your store setup logic is wrong.  You've got this:
compose(
    composeWithDevTools(),
    applyMiddleware(...middleware)
)

Instead, it should be:
composeWithDevTools(
    applyMiddleware(...middleware)
)

Please see the Redux docs page on "Configuring Your Store" for examples of how to correctly set up middleware and the DevTools Extension.
I'd also encourage you to try out our new redux-starter-kit package.  It includes a configureStore function that does all that for you automatically.
Here's how you could simplify your startup file using configureStore:
import {configureStore} from "redux-starter-kit";
import rootReducer from "./reducers";

const store = configureStore({
    reducer : rootReducer,
});


text:
Q: VBA Runtime error 1004 on If statement Good day to all,
I keep getting the same runtime error while executing my code. I don't have formal training in VBA (mostly some VB in highschool).
The code is this
Sub Lavaggi2():
Dim i, j, k, lavaggio, x, daymax As Integer
Dim day As Date
Dim Ore(10) As Single
Dim column_len, row_len As Integer
Dim totale_ore As Integer

'Determining variable for row and columns
column_len = Sheets("Foglio7").Cells.CurrentRegion.Columns.Count
row_len = Sheets("Foglio7").Cells.CurrentRegion.Rows.Count
k = 1

For j = 1 To row_len
    For i = 1 To column_len
        If (Sheets("Foglio7").Cells(2, i).Value = "Codice") Then
            If (Sheets("Foglio7").Cells(j, i).Value = "00/100" Or Sheets("Foglio7").Cells(j, i).Value = "00/200") Then
                day = Sheets("Foglio7").Cells(j, 1).Value
                    For k = 1 To 10
                        If (Sheets("Foglio7").Cells(j - k, 1).Value = day) Then
                            Ore(k) = Sheets("Foglio7").Cells(j - k, i + 5).Value
                            daymax = daymax + 1
                            Else
                        End If
                    Next k
                totale_ore = Worksheet.funcion.Sum(Ore)
                lavaggio = Sheets("Foglio7").Cells(j, i + 7) / totale_ore
                    For x = 1 To daymax
                        Sheets("Foglio7").Cells(j - x, i + 7).Value = lavaggio * Ore(x)
                    Next x
                Erase Ore
            End If
        End If
    Next i
Next j

End Sub

The line where I get the error is
   If (Sheets("Foglio7").Cells(j - k, 1).Value = day) Then

I'm quite sure it's something silly but I'm unable to wrap my head around it.
PS: I'm aware that the code is probably a little clunky but I'll streamline it at a future stage.
Thanks to all who will answer

A: On your first iteration of the loop, j - k would equal 0, and your cell would be .Cells(0, 1), which doesn't exist.

A: I managed to solve the issues I encountered. It works as intended. Thanks to all for the help
Sub Lavaggi2():
Dim i, j, k, x, daymax As Integer
Dim day As Date
Dim lavaggio, totale_ore, Ore(10) As Double
Dim column_len, row_len As Integer

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

column_len = Sheets("Foglio7").Cells.CurrentRegion.Columns.Count
row_len = Sheets("Foglio7").Cells.CurrentRegion.Rows.Count

daymax = 1
For j = 1 To row_len
    For i = 1 To column_len
        If (Sheets("Foglio7").Cells(2, i).Value = "Codice") Then
            If (Sheets("Foglio7").Cells(j, i).Value = "00/100" Or Sheets("Foglio7").Cells(j, i).Value = "00/200") Then
                day = Sheets("Foglio7").Cells(j, 1).Value
                    For k = 1 To 10
                        If (Sheets("Foglio7").Cells(j - k, 1).Value = day) Then
                            Ore(k) = Sheets("Foglio7").Cells(j - k, i + 5).Value
                            daymax = daymax + 1
                            Else
                            Exit For
                        End If
                    Next k
                totale_ore = Application.WorksheetFunction.Sum(Ore)
                lavaggio = Sheets("Foglio7").Cells(j, i + 7) / totale_ore
                    For x = 1 To daymax - 1
                        Sheets("Foglio7").Cells(j - x, i + 7).Value = lavaggio * Ore(x)
                    Next x
                daymax = 1
                Erase Ore
            End If
        End If
    Next i
Next j

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub

I also tweaked the declarations in order to achieve the desired precision in the final results.


text:
Q: css 3d flickering issue in firefox I have a div that rotae to Y axis to -15deg.It works great in chrome but has areally bad flickering issue firefox.The images inside the div looks scattered and jumpy.The rotation also looks little shaky.
here is the link to codepen demo http://codepen.io/wahidpolin/pen/PZoWbx

$('.chapter').on('click', function() {
  $(this).toggleClass("flip-to-back")

});
.chapters {
  background-color: #ececec;
}
.chapter {
  position: relative;
  height: 266px;
  -webkit-perspective: 1000px;
  box-sizing: border-box;
  cursor: pointer;
  max-width: 374px;
  margin: 0 auto 30px;
}
.chapter .front,
.chapter .back {
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  -o-backface-visibility: hidden;
  -ms-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-transition-duration: .75s;
  -moz-transition-duration: .75s;
  -o-transition-duration: .75s;
  -ms-transition-duration: .75s;
  transition-duration: .75s;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  -o-transform-style: preserve-3d;
  -ms-transform-style: preserve-3d;
  transform-style: preserve-3d;
  -webkit-transform-origin: 0 0;
  -ms-transform-origin: 0 0;
  position: absolute;
  top: 0;
  left: 0;
  border: 1px solid #ccc;
}
.chapter .front {
  background: #fff;
  -webkit-transform: rotateY(0deg);
  -moz-transform: rotateY(0deg);
  -o-transform: rotateY(0deg);
  -ms-transform: rotateY(0deg);
  transform: rotateY(0deg);
  transition: all 1s;
  z-index: 2;
  border: 1px solid rgba(0, 0, 0, 0.2);
}
.chapter .back {
  background-color: #fff;
  font-size: 24px;
  color: rgba(0, 0, 0, 0.2);
  border: 1px solid #ccc;
  padding: 0;
  -webkit-transform: rotateY(180deg);
  -moz-transform: rotateY(180deg);
  -o-transform: rotateY(180deg);
  -ms-transform: rotateY(180deg);
  transform: rotateY(180deg);
  transition: all 1s;
}
.chapter .back .chapter-back-top {
  padding: 20px;
}
.chapter .back img,
.chapter .back h3,
.chapter .back h4 {
  display: inline-block;
  float: left;
}
.chapter .back img {
  width: 48px;
  margin: 10px 0 0;
}
.chapter .back h3,
.chapter .back h4 {
  padding: 0 0 0 20px;
}
.chapter .back h3 {
  color: #666;
  margin: 5px 0 10px;
}
.chapter .back h4 {
  color: #777;
}
.chapter .back p {
  padding: 0 20px 20px;
  font-size: 15px;
  text-align: left;
}
.chapter:hover {
  z-index: 10;
}
.chapter:hover .back {
  background-color: #fff;
}
.chapter:hover .front {
  -webkit-transform: rotateY(-15deg);
  -moz-transform: rotateY(-15deg);
  -o-transform: rotateY(-15deg);
  -ms-transform: rotateY(-15deg);
  transform: rotateY(-15deg);
  background: #f7f7f7;
  border: 1px solid #f7f7f7;
}
.chapter:hover .back {
  -webkit-transform: rotateY(165deg);
  -moz-transform: rotateY(165deg);
  -o-transform: rotateY(165deg);
  -ms-transform: rotateY(165deg);
  transform: rotateY(165deg);
}
.chapter .front img {
  width: 100px;
  margin: 30px 0 20px;
}
.chapter h3 {
  font-size: 22px;
  font-weight: 800;
  padding: 7px 25px;
  margin-bottom: 5px;
  color: #333;
  text-transform: none;
  letter-spacing: 0;
}
.chapter h4 {
  padding: 5px;
  color: #000;
}
.chapter.flip-to-back .front {
  -webkit-transform: rotateY(-180deg);
  -moz-transform: rotateY(-180deg);
  -o-transform: rotateY(-180deg);
  -ms-transform: rotateY(-180deg);
  transform: rotateY(-180deg);
  -webkit-transform-origin: 50% 50%;
}
.chapter.flip-to-back .back {
  -webkit-transform: rotateY(0deg);
  -moz-transform: rotateY(0deg);
  -o-transform: rotateY(0deg);
  -ms-transform: rotateY(0deg);
  transform: rotateY(0deg);
  -webkit-transform-origin: 50% 50%;
}

Chapters

Chapter 1

Getting started

Chapter 1

Getting started

Lorem ipsum dolor sit amet consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.

A: OK so according to W3Schools Firefox has supported transform-origin since version 16, but it seems to me it hasn't implemented it quite as well as -moz-transform-origin. Even with the proprietary version, though, borders seem to disappear in the animation. For me, using a box-shadow instead of a border fixed that:
.chapter .front,
.chapter .back {
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  -o-backface-visibility: hidden;
  -ms-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-transition-duration: .75s;
  -moz-transition-duration: .75s;
  -o-transition-duration: .75s;
  -ms-transition-duration: .75s;
  transition-duration: .75s;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  -o-transform-style: preserve-3d;
  -ms-transform-style: preserve-3d;
  transform-style: preserve-3d;
  -webkit-transform-origin: 0 0;
  -ms-transform-origin: 0 0;
  -moz-transform-origin: 0 0;
  position: absolute;
  top: 0;
  left: 0;
  box-shadow: 0 0 0 1px #ccc;
}