text:
Q: How can I stop DustJS converting entities back to normal characters? To replicate my problem, go here, and please paste this code into corresponding sections:
Dust Template:
{title|s}

Data:
{
  "title": ""
}

You will see following output:

In my opinion it's a wrong behaviour, as entities are converted back to normal characters. Which results in alert being executed.
I want to control whether value I'm inserting to my template is HTML-escaped or not via JS. So Dust JS shouldn't do any smart operations behind, and just feed the template with exactly the content I want. How can I achieve that?

A: |s seems to stand for supressing any additional escaping routines done by the library. Since you're entering your data as escaped HTML already, it spits out exactly what you gave it. The browser is rendering it as , but behind the scenes it's still <script>alert('yo');</script> No alert is executed since your string is already escaped:

var data = {
  "title": "<script>alert('yo');</script>"
};

//innerHTML version
var src = document.getElementById('template-s').textContent;
var compiled = dust.compile(src, 'output-s');

dust.loadSource(compiled);

dust.render('output-s', data, function(err, out) {
  document.getElementById('output-s').innerHTML = out;
});

// textContent version

src = document.getElementById('template-s-textContent').textContent;
compiled = dust.compile(src, 'output-s-textContent');

dust.loadSource(compiled);

dust.render('output-s-textContent', data, function(err, out) {
  document.getElementById('output-s-textContent').textContent = out;
});

Flag: |s set as innerHTML

Flag: |s set as textContent

This article seems to do a better job of explaining the filters than the official docs. His example has an unescaped string that illustrates when alert will be executed depending on the flag you use.


text:
Q: Why ASP.NET restarting WCF service? i have a problem. I am developing ASP.NET app with WCF service. There is a custom session manager, which based on SessionID. I'm keeping session ids in static class, which stored in assembly with WCF service.
Sometimes, WCF service unexpectely restarts (or recreates?) and session manager clears with all ids of opened sessions. It's unacceptable in this project.
I readed about the InstanceContextMode/ConcurrencyMode attributes and a set them to "Single", but it has no effect: WCF service restarts all the same.
How to disable WCF service restarting?

A: IIS may recycle application pool hosting your application for many different reasons. It means that the process hosting your application will be restarted and all data saved in static fields or classes will be lost.
In order to fix this I would suggest keeping your data in database or some other persistent storage instead of a memory. If this data is used very frequently you may consider creating in-memory cache on top of this persistent storage.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Varnish-modules make check fails completely I have a new server, ubuntu 20.04.02.lts, fully patched.  I've installed varnish 6.6.0 and it starts correctly.  I've downloaded the varnish-modules file from github, 0.18.0.tar.gz, and unzipped it (varnish-modules-0.18.0).
I've installed all the prerequisites identified here:
Compiling, testing and installing relies on the autotools suite and requires:
the usual autotools dependencies (make, automake, libtool)
the Varnish development files (varnish-dev or varnish-devel)
rst2man (python-sphinx) (actually for 20.04 it was sphinx-common)
I follow these steps:
./bootstrap
./configure   # run "configure -h" first to list options
make
make check    # optional (tests).
all the tests (55 total) fail. the make command appears to be fine.
i discovered this error in the test-suite.log file - /root/tmp/varnish-modules-0.18.0/src/.libs/libvmod_var.so: cannot open shared object file: Permission denied
I'm running as root.  The file exists and has these permissions:
-rwxr-xr-x 1 root root 75256 Apr  7 05:09 /root/tmp/varnish-modules-0.18.0/src/.libs/libvmod_var.so

A: Apparently, there was some security on the /root partition that was preventing the make check command from reading any file in the root/tmp/varnish-modules-0.18.0/src/.libs folder.
I moved the varnish-modules folder to my home folder and could successfully run the make check command.


text:
Q: handlebars with webpack - variables is not passing into custom helper I have files as below:
/assets
|- /templates
   |- /helpers
      |- iff.js
   |- /partials
      |- head.hbs
   |- chat.hbs
   |- index.hbs
|- /public
   |- chat.html <---- exported by webpack build command
   |- index.html <---- exported by webpack build command
|- webpack.config.js

in chat.hbs, I include head.hbs like this:
{{>head pageName='Chat Room'}}

in index.hbs, I include head.hbs like this:
{{>head}}

in head.hbs, I call custom helper iff as below:
{{#iff pageName '!==' undefined}}
   <span> {{pageName}}</span>
{{/iff}}

the custom helper iff.js as below:
module.exports = (a, operator, b, opts)=> {
    var bool = false;
    switch(operator) {
       case '==':
           bool = a == b;
           break;
       case '!==':
            bool = a !== b;
            break;
       case '>':
           bool = a > b;
           break;
       case '<':
           bool = a < b;
           break;
       default:
           throw "Unknown operator " + operator;
    }

    if (bool) {
        return opts.fn(this);
    } else {
        return opts.inverse(this);
    }
}

and to setup custom helpers, webpack.config.js as below:
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: {
        'app': [
            './assets/js/app.js'
        ]
    },
    output: {
        path: path.join(__dirname, 'public'),
        filename: 'js/[name].min.js'
    },
    optimization: {
        minimize: false
    },
   plugins: [
        new webpack.optimize.OccurrenceOrderPlugin(),
        new HtmlWebpackPlugin({
            template: './assets/templates/index.hbs',
            filename: 'index.html'
        }),
        new HtmlWebpackPlugin({
            template: './assets/templates/chat.hbs',
            filename: 'chat.html'
        })
    ],
    module: {
        rules: [{
            test: /\.(hbs|handlebars)$/,
            use: [{
                loader: "handlebars-loader",
                options: {
                    partialDirs: path.resolve(__dirname, './assets/templates/partials'),
                    knownHelpersOnly: false,
                    helperDirs: path.resolve(__dirname, "./assets/templates/helpers")
                }
              }]
        }]
    }
};

The result is:
for index.html, elements between {{#iff}} and {{/iff}} block do not render which is good.
but for chat.html, the block between {{#iff}} and {{/iff}} rendered without passing variable pageName in.
I know I could custom made a helper and don't use {{/iff}} structure instead.
But I wonder is there any way to make it works as same as handlebars on the server-side node.js.


text:
Q: DistutilsError: Could not find suitable distribution for Requirement.parse('setuptools-scm') Hello when trying to deploy a django application to elastic beanstalk this error shows up,
DistutilsError: Could not find suitable distribution for Requirement.parse('setuptools-scm')

I have tried to add the library setuptools-scm in my requirements.txt file and even in my .ebextension directory, but still no luck any suggestions?
EDIT, here's the a full log of the error:
Application deployment failed at 2021-05-18T23:56:56Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py failed. Collecting Django==1.11.16 Using cached Django-1.11.16-py2.py3-none-any.whl (7.0 MB) Collecting django-oscar==1.6.4 Using cached django_oscar-1.6.4-py2.py3-none-any.whl (7.5 MB) Collecting psycopg2==2.7.3.2 Using cached psycopg2-2.7.3.2-cp36-cp36m-manylinux1_x86_64.whl (2.7 MB) Collecting openpyxl==2.4.10 Using cached openpyxl-2.4.10.tar.gz (158 kB) Collecting django-storages==1.6.5 Using cached django_storages-1.6.5-py2.py3-none-any.whl (47 kB) Collecting boto3==1.5.19 Using cached boto3-1.5.19-py2.py3-none-any.whl (128 kB) Collecting django-ipware==2.0.1 Using cached django-ipware-2.0.1.tar.gz (10 kB) Collecting django-extensions>=2.0.6 Using cached django_extensions-3.1.3-py3-none-any.whl (223 kB) Collecting pygeoip==0.3.2 Using cached pygeoip-0.3.2-py2.py3-none-any.whl (20 kB) Collecting selenium==3.14.1 Using cached selenium-3.14.1-py2.py3-none-any.whl (902 kB) Collecting pycountry==18.5.26 Using cached pycountry-18.5.26-py2.py3-none-any.whl (10.3 MB) Collecting pysolr==3.8.1 Using cached pysolr-3.8.1-py2.py3-none-any.whl (16 kB) Collecting django-filter==0.13.0 Using cached django_filter-0.13.0-py2.py3-none-any.whl (27 kB) Collecting djangorestframework==3.3.3 Using cached djangorestframework-3.3.3-py2.py3-none-any.whl (662 kB) Collecting Pillow==5.3.0 Using cached Pillow-5.3.0-cp36-cp36m-manylinux1_x86_64.whl (2.0 MB) Collecting django-settings-export==1.2.1 Using cached django-settings-export-1.2.1.tar.gz (5.0 kB) Collecting django-background-tasks==1.2.0 Using cached django-background-tasks-1.2.0.tar.gz (19 kB) Collecting ip2geotools==0.1.5 Using cached ip2geotools-0.1.5-py3-none-any.whl (16 kB) Collecting watchtower==0.7.3 Using cached watchtower-0.7.3-py2.py3-none-any.whl (13 kB) Collecting pytz Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB) Collecting sorl-thumbnail<12.5,>=12.4.1 Using cached sorl_thumbnail-12.4.1-py2.py3-none-any.whl (44 kB) Collecting django-widget-tweaks>=1.4.1 Using cached django_widget_tweaks-1.4.8-py2.py3-none-any.whl (11 kB) Collecting django-treebeard>=4.3.0 Using cached django_treebeard-4.5.1-py3-none-any.whl (103 kB) Collecting django-extra-views<0.12,>=0.11 Using cached django-extra-views-0.11.0.tar.gz (13 kB) Collecting Unidecode<1.1,>=1.0 Using cached Unidecode-1.0.23-py2.py3-none-any.whl (237 kB) Collecting Babel<3.0,>=1.0 Using cached Babel-2.9.1-py2.py3-none-any.whl (8.8 MB) Collecting factory-boy<3.0,>=2.4.1 Using cached factory_boy-2.12.0-py2.py3-none-any.whl (36 kB) Collecting mock<3.0,>=1.0.1 Using cached mock-2.0.0-py2.py3-none-any.whl (56 kB) Collecting phonenumbers Using cached phonenumbers-8.12.23-py2.py3-none-any.whl (2.6 MB) Collecting django-haystack<3.0.0,>=2.5.0 Using cached django-haystack-2.8.1.tar.gz (1.6 MB) ERROR: Command errored out with exit status 1: command: /opt/python/run/venv/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ji9vxolp/django-haystack_504d7caab43d489ebad3acd0546161a6/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ji9vxolp/django-haystack_504d7caab43d489ebad3acd0546161a6/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-2lhqu4p5 cwd: /tmp/pip-install-ji9vxolp/django-haystack_504d7caab43d489ebad3acd0546161a6/ Complete output (23 lines): Couldn't find index page for 'setuptools_scm' (maybe misspelled?) No local packages or working download links found for setuptools_scm Traceback (most recent call last): File "", line 1, in File "/tmp/pip-install-ji9vxolp/django-haystack_504d7caab43d489ebad3acd0546161a6/setup.py", line 71, in setup_requires=['setuptools_scm'], File "/usr/lib64/python3.6/distutils/core.py", line 108, in setup _setup_distribution = dist = klass(attrs) File "/opt/python/run/venv/local/lib/python3.6/site-packages/setuptools/dist.py", line 315, in __init__ self.fetch_build_eggs(attrs['setup_requires']) File "/opt/python/run/venv/local/lib/python3.6/site-packages/setuptools/dist.py", line 361, in fetch_build_eggs replace_conflicting=True, File "/opt/python/run/venv/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 850, in resolve dist = best[req.key] = env.best_match(req, ws, installer) File "/opt/python/run/venv/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1122, in best_match return self.obtain(req, installer) File "/opt/python/run/venv/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1134, in obtain return installer(requirement) File "/opt/python/run/venv/local/lib/python3.6/site-packages/setuptools/dist.py", line 429, in fetch_build_egg return cmd.easy_install(req) File "/opt/python/run/venv/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 659, in easy_install raise DistutilsError(msg) distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('setuptools_scm') ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/69/43/3e247b7b2134b48e9a53fb387e191e5e05b5f38f2faf78ca892097c2b441/django-haystack-2.8.1.tar.gz#sha256=8b54bcc926596765d0a3383d693bcdd76109c7abb6b2323b3984a39e3576028c (from https://pypi.org/simple/django-haystack/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Using cached django-haystack-2.8.0.tar.gz (425 kB) ERROR: Command errored out with exit status 1: command: /opt/python/run/venv/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ji9vxolp/django-haystack_b5f23b3fb1794ae0b1220ef21f1b8b09/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ji9vxolp/django-haystack_b5f23b3fb1794ae0b1220ef21f1b8b09/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-sd7n9ubs cwd: /tmp/pip-install-ji9vxolp/django-haystack_b5f23b3fb1794ae0b1220ef21f1b8b09/ Complete output (23 lines): Couldn't find index page for 'setuptools_scm' (maybe misspelled?) No local packages or working download links found for setuptools_scm Traceback (most recent call last): File "", line 1, in File "/tmp/pip-install-ji9vxolp/django-haystack_b5f23b3fb1794ae0b1220ef21f1b8b09/setup.py", line 71, in setup_requires=['setuptools_scm'], File "/usr/lib64/python3.6/distutils/core.py", line 108, in setup _setup_distribution = dist = klass(attrs) File "/opt/python/run/venv/local/lib/python3.6/site-packages/setuptools/dist.py", line 315, in __init__ self.fetch_build_eggs(attrs['setup_requires']) File "/opt/python/run/venv/local/lib/python3.6/site-packages/setuptools/dist.py", line 361, in fetch_build_eggs replace_conflicting=True, File "/opt/python/run/venv/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 850, in resolve dist = best[req.key] = env.best_match(req, ws, installer) File "/opt/python/run/venv/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1122, in best_match return self.obtain(req, installer) File "/opt/python/run/venv/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1134, in obtain return installer(requirement) File "/opt/python/run/venv/local/lib/python3.6/site-packages/setuptools/dist.py", line 429, in fetch_build_egg return cmd.easy_install(req) File "/opt/python/run/venv/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 659, in easy_install raise DistutilsError(msg) distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('setuptools_scm') ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/5e/33/f7978374d447abd2803a2ea8128ff7296c89da42b0e9621ca9dd3495d2fc/django-haystack-2.8.0.tar.gz#sha256=579cd2080f7ad508e909a46c027078e278aeebd133973c1c4efcf0dc57d85c10 (from https://pypi.org/simple/django-haystack/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Using cached django-haystack-2.7.0.tar.gz (1.6 MB) ERROR: Command errored out with exit status 1: command: /opt/python/run/venv/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ji9vxolp/django-haystack_ef77b238789b4b61bc1f1b36fd1ccc05/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ji9vxolp/django-haystack_ef77b238789b4b61bc1f1b36fd1ccc05/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-ls_ug5_i cwd: /tmp/pip-install-ji9vxolp/django-haystack_ef77b238789b4b61bc1f1b36fd1ccc05/ Complete output (23 lines): Couldn't find index page for 'setuptools_scm' (maybe misspelled?) No local packages or working download links found for setuptools_scm Traceback (most recent call last): File "", line 1, in Command output has been truncated. Please see logs for more details.
UPDATE: The problem was in the configuration of and set-up of my elastic beanstalk enviroment, also I was using some deprecated libraries that needed to be upgraded (Django-Oscar)

A: Did you try updating setuptools?
pip install --upgrade setuptools


text:
Q: Volume Slider using Tkinter I'm new to coding, and I am attempting to create a juke box for a school project, but I'm struggling to create a slider that will edit the volume. I'm just unsure where to start to get the volume to actually change as I move the slider.
I'm using VLC lib.
import vlc
import random
from tkinter import *
import threading

song = ""
instance = vlc.Instance()

def get_songs():
    global song
    global x
    global songs
    songs = filedialog.askopenfilenames()
    x = 0
    song = songs[x]
    print(songs)
    commence(song)

def pause_resume():
    player.pause()

def commence(song):
    global player
    global x
    player = instance.media_player_new()
    media = instance.media_new(song)
    player.set_media(media)
    player.play()

def next_song():
    if x >= len(songs):
        print("Error: Can't go any further")
        x = 0
        return
    player.stop()
    song = songs[x]
    commence(song)

window = Tk()

window.geometry("600x600")
window.title('JukeBox')

#pause_button = Button(window, text = "Next", command = next_song)
#pause_button.grid(row=1, column = 2)
Button(window, text="Start", command=get_songs).grid(column=1,row=1)
Button(window, text="Next", command=next_song).grid(column=1,row=2)
pause_button = Button(window, text = "Pause/Resume", command = pause_resume)
pause_button.grid(row=3, column = 1)
menubar = Menu(window)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_separator()
filemenu.add_command(label="Open", command=get_songs())
filemenu.add_command(label="Exit", command=window.destroy)
menubar.add_cascade(label="File", menu=filemenu)
window.config(menu=menubar)
vol = Scale(window,from_ = 0,to = 1,orient = HORIZONTAL ,resolution = .1,)
vol.grid(row = 1, column = 2)

window.mainloop()

I understand I'm not using the best coding practices, but this way I can actually understand what I have written.

A: Set the command parameter when creating the Scale widget:
def set_volume(v):
    global vol
    global player
    # either get the new volume from given argument v (type: str):
    # value = int(v)
    # or get it directly from Scale widget (type: int)
    value = vol.get()
    player.audio_set_volume(value)

vol = Scale(..., command=set_volume)

A: My mate was able to help me with this by simply adding self in the required paramaters of the function, no clue why it helps and thanks everyone for trying, much appreciated.
def show_value(self):
    global player
    i = vol.get()
    player.audio_set_volume(i)

vol = Scale(window,from_ = 0,to = 100,orient = HORIZONTAL ,resolution = 1,command = show_value)
    vol.place(x=75, y = 300)
    vol.set(50)


text:
Q: ZeroMQ master slave two way communication I want to create a networked architecture where a master process is connected with some slave processes and exchange messages in this way:

Every slave should be able to send a message to the master. The master should be able to send a message to every subset of connected slaves.
i.e.

*

*Master sends a message to Slave 1

*Master sends a message to Slave 2 and Slave 3

*Master sends a message to all Slaves

*Slave 1 send a message to Master

These messages could have answers, but this can be handled at an higher level if there's not a dedicated way of doing this with ZeroMQ.
This should work using only one port.
With plain sockets I could make the Master bind on a port, accept connections, spawn a thread for every slave to handle incoming data and use the single connection to contact the single slave.
Since this architecture will use message-based communication, I think that ZeroMQ is the proper tool to implement it, but browsing the doc i can't find a way do that.
I'm going to write this in python, but the problem should be language agnostic.

A: Only using one port I think its best to use Dealer/Router :

*

*Master would be a Router socket

*Slave would be a Dealer socket

*When slaves start send an 'I'm here message' to the master which should store identity (first frame received) in a list of known slaves.

The master then sends to a slave by prepending the identity and an empty frame to the message. (You can only send to one client at a time with a router socket, but trivial to write a function to take a message and a list of slave identities and send to each in turn.)
The identities of the slaves can either be set by you, using the setsockopt call on the Dealer sockets, or ZeroMQ will auto assign unique ones if you don't.


text:
Q: How to find an element in Scene Builder by its fx:id In Scene Builder I'm getting an warning every time I open a .fxml file. The warning says:

Duplicate usage of fx:id="x2"

I don't remember to have set an fx:id of x2 to any element, but this is not really a problem. The problem is that I have hundreds of elements in several different containers and it's very hard to find this two elements with this fx:id to fix this warning.
Is there a way I can find an element in Scene Builder by searching it by its fx:id?
EDIT
The element with duplicated id was an Insets, I'm not sure how it is created, but I'm sure that it's not visible neither in the Library area, nor in the Hierarchy area, nor in the main area of the Scene Builder. Their ids were duplicated somehow when I copied and pasted an HBox with an Label and a Button inside. The ids of the HBox, Label and Button weren't duplicated, just the Insets' id was.
The Insets looks like this in the source code:
<HBox.margin>
    <Insets left="130.0" fx:id="x2" />
</HBox.margin>

I just removed their id and the problem was gone! Antoniossss' answer helped me.

A: Why don't you just simply edit your generated fxml file with text editor and search for x2 in it?

A: try the below to get the element by id
scene.lookup("#yourid");


text:
Q: Intersection of lists of disjoint intervals Here is my problem: I have two very large lists of intervals (stored as many couples in the form {{"start point", "end point"}, ..., {"start point", "end point"}), and I want the result of the intersection of those lists.
Here is an example :
intervalsA = {{1, 2}, {3, 4}, {5, 7}, {8, 8.5}};
intervalsB = {{1.5, 3.5}, {4.1, 6}, {9, 10}};

The expected result is: overlap = {{1.5, 2}, {3, 3.5}, {5, 6}};
I tried using Interval, IntervalUnion and IntervalIntersection, but nothing worked. The only working method that I found uses Piecewise functions where each interval is set as 1. By multiplying the two piecewise functions, I have something similar to the intersection, but the solution is very inefficient.
I hope I am clear and precise enough.

A: intervalsA = {{1, 2}, {3, 4}, {5, 7}, {8, 8.5}};
intervalsB = {{1.5, 3.5}, {4.1, 6}, {9, 10}};
IntervalIntersection @@ Interval @@@ {intervalsA, intervalsB}

Interval[{1.5, 2}, {3, 3.5}, {5, 6}]

A: or more general:
youFunction[intervals__] := Composition[
    DeleteCases[#, Interval[]] &,
    DeleteDuplicates,
    (IntervalIntersection @@ # &) /@ # &,
    Subsets[#, {2}] &,
    Join[##] &
    ][intervals];

intervalsA = Interval /@ {{1, 2}, {3, 4}, {5, 7}, {8, 8.5}};
intervalsB = Interval /@ {{1.5, 3.5}, {4.1, 6}, {9, 10}};
youFunction[intervalsA, intervalsB]
(*{Interval[{1.5, 2}], Interval[{3, 3.5}], Interval[{5, 6}]}*)


text:
Q: Access REST from external application: 401 I'm trying to access the REST api calls from an external application on my local machine, the SharePoint instance is hosted in AZURE, not SP Online.
I've followed numerous blogs stating that I need a token issued via calling the /contentinfo route first, however, this also gives me a 401 Unauthorized.
I've Googled, Stackoverflow'd, tried numerous blogs on the topic and it just does not seem possible. From my understanding is that the REST api's where added specifically so that iOS / Android apps could interact with SharePoint, so building an application outside of the installation of SharePoint would seem possible?
Here's a snippet I tried, based on what I've Googled. I have tried using the WebClient but this does not work either:
var request = (HttpWebRequest)HttpWebRequest.Create("http://sharepoint-tyrano.northeurope.cloudapp.azure.com/_api/contextinfo");

request.Method = "POST";
request.Accept = "application/json;odata=verbose";
request.ContentType = "application/json;odata=verbose";
request.ContentLength = 0;
request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(@"tyrano\apitest: ThisisacerysecurePwd123"));
request.Credentials = System.Net.CredentialCache.DefaultCredentials;

var response = request.GetResponse();

This is called from within the home controller's Index() action, just as a simple test run. I've also tried to get this going on my local inside a console application and still 401.
I've added this user under the user policy for the web application with Full Read, in Central Admin, but still nothing.
Any ideas why this will fail?

A: You'll have to have the code provide credentials to the code (via secure store, pulled from a web config, part of the code, etc) as the system executing code a default credentials on behalf of someone else is considered a double hop and isn't allowed.


text:
Q: WPF: K.O. Can't Synchronize StoryBoards animations + Can't change application theme  So I have a StackPanel menu which has a lot of buttons, each button must have a grid and inside 2 labels, the first for the icon, and the second for a small rectangle which indicates if this button is active or no. In addition, each button is linked to a page, and when the user clicks, the program displays the appropriate page.
When the program wants to get the user's attention to a specific page (for example, a notification page), an animation is started, in which we will flash the icon label (linked to that specific page) 2 times in red color for a short time, and it will be repeated every 10 seconds until the user clicks this button to see the notification.
Problem N: 1
It may happen that multiple notifications arrive at the same time from different pages, in this scenario we need to sync the StoryBoards so that the buttons will flash together every 10 seconds, otherwise you will see an unhappy result as each button will flash separately on others. My first thought was to bind something to the BeginTime of the StoryBoard, and make the StoryBoard wait for the running animations before starting. So, I jumped to the code, and as soon as I write this binding, an awesome exception pops up: Could not freeze this Storyboard timeline tree for use in feeds, I google it and I have found that I am not allowed to use any binding or dynamic resource inside the StoryBoard ControlTemplate, so, I implement a small DependencyProperty in order to synchronize the animation, and this is the reason for which you'll notice this little line here:
<Condition Binding="{Binding Synchronizer}" Value="1"/>

C# Code
public partial class Layout : Window {
    public double Synchronizer { get; set; } = 0;
    public static readonly DependencyProperty DependencyProperty = DependencyProperty.Register("Synchronizer", typeof(double), typeof(Layout), new PropertyMetadata());
    public Layout(){
        {
            InitializeComponent(); DataContext = this;
        }
    }
}

This Synchronizer is triggered due to this XAML Code:
<Window.Triggers>
    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
        <BeginStoryboard>
            <Storyboard RepeatBehavior="Forever" Duration="0:0:10">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="DataContext.Synchronizer" Duration="0:0:0.6">
                    <DiscreteDoubleKeyFrame Value="1" KeyTime="0:0:0.0"/>
                    <DiscreteDoubleKeyFrame Value="0" KeyTime="0:0:0.6"/>
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
</Window.Triggers>

Question N: 1 In yes / no answer, is there is any work around for this exception?

Question N: 2 Is there a better solution?

Problem N: 2
The application has several styles, mainly Dark.Xaml and Light.Xaml, as we already saw in the first issue, animation is used to indicate to the user that a specific page needs some attention. in dark mode we are going to flash the icon with a red color, and in light mode we are going to flash with a blue color, so let me focus on this part of the code:
<ColorAnimationUsingKeyFrames Duration="0:0:0.6" Storyboard.TargetProperty="(Label.Foreground).(SolidColorBrush.Color)">
    <LinearColorKeyFrame Value="#8B0000" KeyTime="0:0:0.2"/>
    <LinearColorKeyFrame Value="#272725" KeyTime="0:0:0.3"/>
    <LinearColorKeyFrame Value="#8B0000" KeyTime="0:0:0.4"/>
    <LinearColorKeyFrame Value="#272725" KeyTime="0:0:0.6"/>
</ColorAnimationUsingKeyFrames>

In general, I change the theme of the app using this C # code:
Resources.MergedDictionaries.Clear();
Resources.MergedDictionaries.Add(Global.Themes[i]);

It works fine with elements that have a DynamicResource binding, but for StaticResource No !!

Question: How can I change the app theme for this StoryBoard ControlTemplate, especially when there is no chance to use the Binding or the Dynamic Resource.

<ControlTemplate x:Key="Menu.Button" TargetType="Button">
    <Grid>
        <Label Content="{TemplateBinding Content}">
            <Label.Style>
                <Style TargetType="Label">
                    <Setter Property="Width" Value="35"/>
                    <Setter Property="FontSize" Value="11"/>
                    <Setter Property="VerticalContentAlignment" Value="Center"/>
                    <Setter Property="HorizontalContentAlignment" Value="Center"/>
                    <Style.Triggers>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}, Path=Tag, Converter={StaticResource Check}, ConverterParameter=1|1}" Value="True"/>
                                <Condition Binding="{Binding Synchronizer}" Value="1"/>
                            </MultiDataTrigger.Conditions>
                            <MultiDataTrigger.EnterActions>
                                <BeginStoryboard Name="Storyboard">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Duration="0:0:0.6" Storyboard.TargetProperty="(Label.Foreground).(SolidColorBrush.Color)">
                                            <LinearColorKeyFrame Value="#8B0000" KeyTime="0:0:0.2"/>
                                            <LinearColorKeyFrame Value="#272725" KeyTime="0:0:0.3"/>
                                            <LinearColorKeyFrame Value="#8B0000" KeyTime="0:0:0.4"/>
                                            <LinearColorKeyFrame Value="#272725" KeyTime="0:0:0.6"/>
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiDataTrigger.EnterActions>
                            <MultiDataTrigger.ExitActions>
                                <RemoveStoryboard BeginStoryboardName="Storyboard"/>
                            </MultiDataTrigger.ExitActions>
                        </MultiDataTrigger>
                    </Style.Triggers>
                </Style>
            </Label.Style>
        </Label>
        <Label>
            <Label.Style>
                <Style TargetType="Label">
                    <Setter Property="Width" Value="2"/>
                    <Setter Property="HorizontalAlignment" Value="Left"/>
                    <Style.Triggers>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}, Path=Tag, Converter={StaticResource Check}, ConverterParameter=0|0}" Value="True"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Visibility" Value="Collapsed"></Setter>
                        </MultiDataTrigger>
                    </Style.Triggers>
                </Style>
            </Label.Style>
        </Label>
    </Grid>
</ControlTemplate>
<StackPanel Name="Menu" DockPanel.Dock="Left" Width="35" Orientation="Vertical" VerticalAlignment="Bottom">
    <Button Template="{StaticResource Menu.Button}"/>
    <Button Template="{StaticResource Menu.Button}"/>
    <Button Template="{StaticResource Menu.Button}"/>
    <Button Template="{StaticResource Menu.Button}"/>
    <Button Template="{StaticResource Menu.Button}"/>
    <Button Template="{StaticResource Menu.Button}"/>
    <Button Template="{StaticResource Menu.Button}"/>
    <Button Template="{StaticResource Menu.Button}"/>
    <Button Template="{StaticResource Menu.Button}"/>
    <Button Template="{StaticResource Menu.Button}"/>
    <Button Template="{StaticResource Menu.Button}"/>
    <Button Template="{StaticResource Menu.Button}"/>
    <Button Template="{StaticResource Menu.Button}"/>
    <Button Template="{StaticResource Menu.Button}"/>
</StackPanel>

A: You cannot get around the problems you're facing using XAML alone. This is because Storyboards in XAML are frozen and you cannot alter them in any way.
The way I handle this is that I move any animations that need dynamic capabilities such as databinding or theme switching into code and I make them available as XAML/attached behaviors.


text:
Q: Json POST request to the server but server respond (400) Bad Request I want to use google api for creation of gmail user account. I am sending JSON request to server for getting authorization code but I got these error in httpwebresponse :-
Exception Details: System.Net.WebException: The remote server returned an error: (400) Bad Request
    var request = (HttpWebRequest)WebRequest.Create(@"https://accounts.google.com/o/oauth2/auth");
    request.Method = "POST";
    request.ContentType = "text/json";
    request.KeepAlive = false;

    //request.ContentLength = 0;

    using (StreamWriter streamWriter = new StreamWriter(request.GetRequestStream()))
    {
        string json = "{\"scope\":\"https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile\"," + "\"state\":\"%2Fprofile\"," + "\"redirect_uri\":\"http://gmailcheck.com/response.aspx\"," + "\"response_type\":\"code\"," + "\"client_id\":\"841994137170.apps.googleusercontent.com\"}";

        streamWriter.Write(json);
        // streamWriter.Flush();
        //streamWriter.Close();
    }
        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
        {
            StreamReader responsereader = new StreamReader(response.GetResponseStream());

            var responsedata = responsereader.ReadToEnd();
            //Session["responseinfo"] = responsereader;

            //testdiv.InnerHtml = responsedata;
        }

}

A: As soon as you get an exception, you have to read the actual responce from server there should be something helpfull. Like an error description or extended status code...
For Instance:
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

         ... your code goes here....

}
catch (WebException ex)
        {
        using (WebResponse response = ex.Response)
        {
            var httpResponse = (HttpWebResponse)response;

            using (Stream data = response.GetResponseStream())
            {
                StreamReader sr = new StreamReader(data);
                throw new Exception(sr.ReadToEnd());
            }
        }
    }


text:
Q: Probability with combination (assigning men and women to hotel rooms). I am totally clueless about this probability question. After spending an hour I decided to give up.
A hotel has $5$ single rooms, for which $6$ men and $3$ women apply. What is the probability that the rooms will be rented to $3$ men and $2$ women, assuming that each applicant has an equal chance of getting a room?

A: The total possible assignments are ${9 \choose 5}=126$. Rooms can be assigned to 3 men and 2 women in ${6 \choose 3} \cdot {3 \choose 2} = 60$ ways. So, the probability is $60/126 = 10/21$.


text:
Q: how to get the date from listview in code behind? i have one listview and i want use from data  in there .but
The program gives an error when receiving data
that do not recognize the word item

            TextBox countText = (TextBox)item.FindControl("txtcount");
  <asp:TextBox ID="txtcount" type="text" runat="server" Width="30"></asp:TextBox>

Your help will be much appreciated.


text:
Q: HAproxy static pod runs 100% CPU on node on containerd I am working on Deprecating Docker shim and using containerd as container engine in kubelet. It caused haproxy Static pod to run 100% CPU on node. The resource limits doesn't work for static pod so that did not work. The same pod when run as a container in Podman, works fine and it worked fine when docker was the container engine for K8s. Any way to troubleshoot what's causing the issue as kubelet, containerd and haproxy are involved?
HA-Proxy version 2.0.25-6986403 2021/09/07 - https://haproxy.org/
Build options :
  TARGET  = linux-glibc
  CPU     = generic
  CC      = gcc
  CFLAGS  = -O2 -g -fno-strict-aliasing -Wdeclaration-after-statement -fwrapv -Wno-unused-label -Wno-sign-compare -Wno-unused-parameter -Wno-old-style-declaration -Wno-ignored-qualifiers -Wno-clobbered -Wno-missing-field-initializers -Wno-implicit-fallthrough -Wno-stringop-overflow -Wno-cast-function-type -Wtype-limits -Wshift-negative-value -Wshift-overflow=2 -Wduplicated-cond -Wnull-dereference
  OPTIONS = USE_PCRE2=1 USE_PCRE2_JIT=1 USE_GETADDRINFO=1 USE_OPENSSL=1 USE_LUA=1 USE_ZLIB=1

Feature list : +EPOLL -KQUEUE -MY_EPOLL -MY_SPLICE +NETFILTER -PCRE -PCRE_JIT +PCRE2 +PCRE2_JIT +POLL -PRIVATE_CACHE +THREAD -PTHREAD_PSHARED -REGPARM -STATIC_PCRE -STATIC_PCRE2 +TPROXY +LINUX_TPROXY +LINUX_SPLICE +LIBCRYPT +CRYPT_H -VSYSCALL +GETADDRINFO +OPENSSL +LUA +FUTEX +ACCEPT4 -CLOSEFROM -MY_ACCEPT4 +ZLIB -SLZ +CPU_AFFINITY +TFO +NS +DL +RT -DEVICEATLAS -51DEGREES -WURFL -SYSTEMD -OBSOLETE_LINKER +PRCTL +THREAD_DUMP -EVPORTS

Default settings :
  bufsize = 16384, maxrewrite = 1024, maxpollevents = 200

Built with multi-threading support (MAX_THREADS=64, default=8).
Built with OpenSSL version : OpenSSL 1.1.1d  10 Sep 2019
Running on OpenSSL version : OpenSSL 1.1.1d  10 Sep 2019
OpenSSL library supports TLS extensions : yes
OpenSSL library supports SNI : yes
OpenSSL library supports : TLSv1.0 TLSv1.1 TLSv1.2 TLSv1.3
Built with Lua version : Lua 5.3.3
Built with network namespace support.
Built with transparent proxy support using: IP_TRANSPARENT IPV6_TRANSPARENT IP_FREEBIND
Built with zlib version : 1.2.11
Running on zlib version : 1.2.11
Compression algorithms supported : identity("identity"), deflate("deflate"), raw-deflate("deflate"), gzip("gzip")
Built with PCRE2 version : 10.32 2018-09-10
PCRE2 library supports JIT : yes
Encrypted password support via crypt(3): yes
Built with the Prometheus exporter as a service

Available polling systems :
      epoll : pref=300,  test result OK
       poll : pref=200,  test result OK
     select : pref=150,  test result OK
Total: 3 (3 usable), will use epoll.

Available multiplexer protocols :
(protocols marked as <default> cannot be specified using 'proto' keyword)
              h2 : mode=HTX        side=FE|BE     mux=H2
              h2 : mode=HTTP       side=FE        mux=H2
       <default> : mode=HTX        side=FE|BE     mux=H1
       <default> : mode=TCP|HTTP   side=FE|BE     mux=PASS

Available services :
    prometheus-exporter

Available filters :
    [SPOE] spoe
    [COMP] compression
    [CACHE] cache
    [TRACE] trace

Here is the static pod spec
apiVersion: v1
kind: Pod
metadata:
  name: static-web
  labels:
    role: myrole
spec:
  containers:
    - name: web
      image: haproxy:v2.0.0
      - mountPath: /usr/local/etc/haproxy/haproxy.cfg
        name: configfile
      ports:
        - name: web
          containerPort: 6443
          protocol: TCP
  volumes:
  - name: configfile
    hostPath:
      path: /etc/kubernetes/config/haproxy.cfg
      type: FileOrCreate

A: The issue is fixed. When maxconnections is not declared in global params, haproxy automatically uses max open file kernel parameter and in my case it was 536870882. This is causing 100% CPU and 95% memory consumption. Now added maxconn 10000 in global and the issue is fixed.
global
  maxconn 10000


text:
Q: How to change the size of html div element with text inside it I have an DIV element on my page with some text inside it which is less the size of the DIV element.
I also have a javascript function that uses setTimeout to animate the change of width property of the element.
However when the width becomes less than the width of the text inside it the text breaks on new line and so on. I tried using white-space:nowrap which makes the text stay on the same line but when the width of the element becomes less than the text width the text stays outside of it.
How to make the text stay on the same line AND hides along the div container?

A: Add ( overflow:hidden ) to the div element. (demo)

A: You want to add one more bit of CSS (demo):
overflow:hidden;

A: Try with
white-space: pre-wrap


text:
Q: Xcode error keeps saying size undeclared how do i fix this? I am writing the below code into xcode and it keeps coming up size undeclared: first use in this function how do I fix this so I can run the code?
// on "init" you need to initialize your instance
-(id) init
{ CCSprite *spaceCargoShip = [CCSprite
                             spriteWithFile:@"spaceCargoShip.png"];
[spaceCargoShip     setPosition:ccp(size.width/2, size.height/2)];
[self addChild:spaceCargoShip];

A: The size variable isn't declared in that function. You have to get it from somewhere else — perhaps self.size, but without seeing the rest of the code I don't know where it should be coming from.

A: I'm guessing that you want to position your cargo ship at the lower left corner of the screen. For that, you want to use the size of the sprite you created, which is spaceCargoShip.contentSize.
Instead of
[spaceCargoShip setPosition:ccp(size.width/2, size.height/2)];

use
[spaceCargoShip setPosition:ccp(spaceCargoShip.contentSize.width/2,
                                spaceCargoShip.contentSize.height/2)];

Have fun!

A: I was having the same issue.
The code has to be put in the init function and inside the if statement.
- (id)init {
   if (self = [super init]) {
    //Code for the spaceCargoShip
     ...
    // ask director the the window size
    CGSize size = [[CCDirector sharedDirector] winSize]; //<-- This is the "size" variable that the code is looking for.
     ...
    //Enter the code for the spaceCargoShip in here.
    CCSprite *spaceCargoShip = [CCSprite spriteWithFile:@"SpaceCargoShip.png"];
    [spaceCargoShip setPosition:ccp(size.width/2, size.height/2)];
    [self addChild:spaceCargoShip];

   }
   return self;
}

The reason that it is not working is that the variable falls out of scope if you don't put it within the if statement.


text:
Q: Error while distribution I am able to test my app in Simulator...I am now preparing the app for submission to the app store..
However I get an error while trying to use Distribution
Could you please let me know the steps/ things to check wile distributing the app. I have the latest XCode installed 3.2.5


text:
Q: How Can I Get Virtual Key Code from VK_Packet in Windows Api (Win32)? I wanted to monitor Key presses on my computer and wrote this simple program in c++ \ win32api :
#include <stdio.h>
#include <iostream>
#include <windows.h>
#include <string>

using namespace std;

HHOOK hKeyHook;
KBDLLHOOKSTRUCT kbdStruct;

LRESULT WINAPI KeyEvent(int nCode, WPARAM wParam, LPARAM lParam)
{
    if((nCode == HC_ACTION) && ((wParam == WM_SYSKEYDOWN) || (wParam == WM_KEYDOWN)))
    {
        kbdStruct = *((KBDLLHOOKSTRUCT*)lParam);

        switch((unsigned int)kbdStruct.vkCode)
        {
            /*
            case 0x01:
                printf("[0x01] - [VK_LBUTTON] - [Left mouse button]\n");
                break;
            case 0x02:
                printf("[0x02] - [VK_RBUTTON] - [Right mouse button]\n");
                break;
            case 0x03:
                printf("[0x03] - [VK_CANCEL] - [Control-break processing]\n");
                break;
            case 0x04:
                printf("[0x04] - [VK_MBUTTON] - [Middle mouse button (three-button mouse)]\n");
                break;
            case 0x05:
                printf("[0x05] - [VK_XBUTTON1] - [X1 mouse button]\n");
                break;
            case 0x06:
                printf("[0x06] - [VK_XBUTTON2] - [X2 mouse button]\n");
                break;
            */

            case 0x07:
                printf("[0x07] - [-] - [Undefined]\n");
                break;
            case 0x08:
                printf("[0x08] - [VK_BACK] - [BACKSPACE key]\n");
                break;
            case 0x09:
                printf("[0x09] - [VK_TAB] - [TAB key]\n");
                break;

            /*
            case 0x0A-0B:
                printf("[0x0A-0B] - [-] - [Reserved]\n");
                break;
            */

            case 0x0C:
                printf("[0x0C] - [VK_CLEAR] - [CLEAR key]\n");
                break;
            case 0x0D:
                printf("[0x0D] - [VK_RETURN] - [ENTER key]\n");
                break;

            /*
            case 0x0E-0F:
                printf("[0x0E-0F] - [-] - [Undefined]\n");
                break;
            */

            case 0x10:
                printf("[0x10] - [VK_SHIFT] - [SHIFT key]\n");
                break;
            case 0x11:
                printf("[0x11] - [VK_CONTROL] - [CTRL key]\n");
                break;
            case 0x12:
                printf("[0x12] - [VK_MENU] - [ALT key]\n");
                break;
            case 0x13:
                printf("[0x13] - [VK_PAUSE] - [PAUSE key]\n");
                break;
            case 0x14:
                printf("[0x14] - [VK_CAPITAL] - [CAPS LOCK key]\n");
                break;

            /*
            case 0x15:
                printf("[0x15] - [VK_KANA] - [IME Kana mode]\n");
                break;
            case 0x15:
                printf("[0x15] - [VK_HANGUEL] - [IME Hanguel mode (maintained for compatibility; use VK_HANGUL)]\n");
                break;
            case 0x15:
                printf("[0x15] - [VK_HANGUL] - [IME Hangul mode]\n");
                break;
            */

            case 0x16:
                printf("[0x16] - [VK_IME_ON] - [IME On]\n");
                break;
            case 0x17:
                printf("[0x17] - [VK_JUNJA] - [IME Junja mode]\n");
                break;
            case 0x18:
                printf("[0x18] - [VK_FINAL] - [IME final mode]\n");
                break;

            /*
            case 0x19:
                printf("[0x19] - [VK_HANJA] - [IME Hanja mode]\n");
                break;
            case 0x19:
                printf("[0x19] - [VK_KANJI] - [IME Kanji mode]\n");
                break;
            */

            case 0x1A:
                printf("[0x1A] - [VK_IME_OFF] - [IME Off]\n");
                break;
            case 0x1B:
                printf("[0x1B] - [VK_ESCAPE] - [ESC key]\n");
                break;
            case 0x1C:
                printf("[0x1C] - [VK_CONVERT] - [IME convert]\n");
                break;
            case 0x1D:
                printf("[0x1D] - [VK_NONCONVERT] - [IME nonconvert]\n");
                break;
            case 0x1E:
                printf("[0x1E] - [VK_ACCEPT] - [IME accept]\n");
                break;
            case 0x1F:
                printf("[0x1F] - [VK_MODECHANGE] - [IME mode change request]\n");
                break;
            case 0x20:
                printf("[0x20] - [VK_SPACE] - [SPACEBAR]\n");
                break;
            case 0x21:
                printf("[0x21] - [VK_PRIOR] - [PAGE UP key]\n");
                break;
            case 0x22:
                printf("[0x22] - [VK_NEXT] - [PAGE DOWN key]\n");
                break;
            case 0x23:
                printf("[0x23] - [VK_END] - [END key]\n");
                break;
            case 0x24:
                printf("[0x24] - [VK_HOME] - [HOME key]\n");
                break;
            case 0x25:
                printf("[0x25] - [VK_LEFT] - [LEFT ARROW key]\n");
                break;
            case 0x26:
                printf("[0x26] - [VK_UP] - [UP ARROW key]\n");
                break;
            case 0x27:
                printf("[0x27] - [VK_RIGHT] - [RIGHT ARROW key]\n");
                break;
            case 0x28:
                printf("[0x28] - [VK_DOWN] - [DOWN ARROW key]\n");
                break;
            case 0x29:
                printf("[0x29] - [VK_SELECT] - [SELECT key]\n");
                break;
            case 0x2A:
                printf("[0x2A] - [VK_PRINT] - [PRINT key]\n");
                break;
            case 0x2B:
                printf("[0x2B] - [VK_EXECUTE] - [EXECUTE key]\n");
                break;
            case 0x2C:
                printf("[0x2C] - [VK_SNAPSHOT] - [PRINT SCREEN key]\n");
                break;
            case 0x2D:
                printf("[0x2D] - [VK_INSERT] - [INS key]\n");
                break;
            case 0x2E:
                printf("[0x2E] - [VK_DELETE] - [DEL key]\n");
                break;
            case 0x2F:
                printf("[0x2F] - [VK_HELP] - [HELP key]\n");
                break;
            case 0x30:
                printf("[0x30] - [] - [0 key]\n");
                break;
            case 0x31:
                printf("[0x31] - [] - [1 key]\n");
                break;
            case 0x32:
                printf("[0x32] - [] - [2 key]\n");
                break;
            case 0x33:
                printf("[0x33] - [] - [3 key]\n");
                break;
            case 0x34:
                printf("[0x34] - [] - [4 key]\n");
                break;
            case 0x35:
                printf("[0x35] - [] - [5 key]\n");
                break;
            case 0x36:
                printf("[0x36] - [] - [6 key]\n");
                break;
            case 0x37:
                printf("[0x37] - [] - [7 key]\n");
                break;
            case 0x38:
                printf("[0x38] - [] - [8 key]\n");
                break;
            case 0x39:
                printf("[0x39] - [] - [9 key]\n");
                break;

            /*
            case 0x3A-40:
                printf("[0x3A-40] - [-] - [Undefined]\n");
                break;
            */

            case 0x41:
                printf("[0x41] - [] - [A key]\n");
                break;
            case 0x42:
                printf("[0x42] - [] - [B key]\n");
                break;
            case 0x43:
                printf("[0x43] - [] - [C key]\n");
                break;
            case 0x44:
                printf("[0x44] - [] - [D key]\n");
                break;
            case 0x45:
                printf("[0x45] - [] - [E key]\n");
                break;
            case 0x46:
                printf("[0x46] - [] - [F key]\n");
                break;
            case 0x47:
                printf("[0x47] - [] - [G key]\n");
                break;
            case 0x48:
                printf("[0x48] - [] - [H key]\n");
                break;
            case 0x49:
                printf("[0x49] - [] - [I key]\n");
                break;
            case 0x4A:
                printf("[0x4A] - [] - [J key]\n");
                break;
            case 0x4B:
                printf("[0x4B] - [] - [K key]\n");
                break;
            case 0x4C:
                printf("[0x4C] - [] - [L key]\n");
                break;
            case 0x4D:
                printf("[0x4D] - [] - [M key]\n");
                break;
            case 0x4E:
                printf("[0x4E] - [] - [N key]\n");
                break;
            case 0x4F:
                printf("[0x4F] - [] - [O key]\n");
                break;
            case 0x50:
                printf("[0x50] - [] - [P key]\n");
                break;
            case 0x51:
                printf("[0x51] - [] - [Q key]\n");
                break;
            case 0x52:
                printf("[0x52] - [] - [R key]\n");
                break;
            case 0x53:
                printf("[0x53] - [] - [S key]\n");
                break;
            case 0x54:
                printf("[0x54] - [] - [T key]\n");
                break;
            case 0x55:
                printf("[0x55] - [] - [U key]\n");
                break;
            case 0x56:
                printf("[0x56] - [] - [V key]\n");
                break;
            case 0x57:
                printf("[0x57] - [] - [W key]\n");
                break;
            case 0x58:
                printf("[0x58] - [] - [X key]\n");
                break;
            case 0x59:
                printf("[0x59] - [] - [Y key]\n");
                break;
            case 0x5A:
                printf("[0x5A] - [] - [Z key]\n");
                break;
            case 0x5B:
                printf("[0x5B] - [VK_LWIN] - [Left Windows key (Natural keyboard)]\n");
                break;
            case 0x5C:
                printf("[0x5C] - [VK_RWIN] - [Right Windows key (Natural keyboard)]\n");
                break;
            case 0x5D:
                printf("[0x5D] - [VK_APPS] - [Applications key (Natural keyboard)]\n");
                break;
            case 0x5E:
                printf("[0x5E] - [-] - [Reserved]\n");
                break;
            case 0x5F:
                printf("[0x5F] - [VK_SLEEP] - [Computer Sleep key]\n");
                break;
            case 0x60:
                printf("[0x60] - [VK_NUMPAD0] - [Numeric keypad 0 key]\n");
                break;
            case 0x61:
                printf("[0x61] - [VK_NUMPAD1] - [Numeric keypad 1 key]\n");
                break;
            case 0x62:
                printf("[0x62] - [VK_NUMPAD2] - [Numeric keypad 2 key]\n");
                break;
            case 0x63:
                printf("[0x63] - [VK_NUMPAD3] - [Numeric keypad 3 key]\n");
                break;
            case 0x64:
                printf("[0x64] - [VK_NUMPAD4] - [Numeric keypad 4 key]\n");
                break;
            case 0x65:
                printf("[0x65] - [VK_NUMPAD5] - [Numeric keypad 5 key]\n");
                break;
            case 0x66:
                printf("[0x66] - [VK_NUMPAD6] - [Numeric keypad 6 key]\n");
                break;
            case 0x67:
                printf("[0x67] - [VK_NUMPAD7] - [Numeric keypad 7 key]\n");
                break;
            case 0x68:
                printf("[0x68] - [VK_NUMPAD8] - [Numeric keypad 8 key]\n");
                break;
            case 0x69:
                printf("[0x69] - [VK_NUMPAD9] - [Numeric keypad 9 key]\n");
                break;
            case 0x6A:
                printf("[0x6A] - [VK_MULTIPLY] - [Multiply key]\n");
                break;
            case 0x6B:
                printf("[0x6B] - [VK_ADD] - [Add key]\n");
                break;
            case 0x6C:
                printf("[0x6C] - [VK_SEPARATOR] - [Separator key]\n");
                break;
            case 0x6D:
                printf("[0x6D] - [VK_SUBTRACT] - [Subtract key]\n");
                break;
            case 0x6E:
                printf("[0x6E] - [VK_DECIMAL] - [Decimal key]\n");
                break;
            case 0x6F:
                printf("[0x6F] - [VK_DIVIDE] - [Divide key]\n");
                break;
            case 0x70:
                printf("[0x70] - [VK_F1] - [F1 key]\n");
                break;
            case 0x71:
                printf("[0x71] - [VK_F2] - [F2 key]\n");
                break;
            case 0x72:
                printf("[0x72] - [VK_F3] - [F3 key]\n");
                break;
            case 0x73:
                printf("[0x73] - [VK_F4] - [F4 key]\n");
                break;
            case 0x74:
                printf("[0x74] - [VK_F5] - [F5 key]\n");
                break;
            case 0x75:
                printf("[0x75] - [VK_F6] - [F6 key]\n");
                break;
            case 0x76:
                printf("[0x76] - [VK_F7] - [F7 key]\n");
                break;
            case 0x77:
                printf("[0x77] - [VK_F8] - [F8 key]\n");
                break;
            case 0x78:
                printf("[0x78] - [VK_F9] - [F9 key]\n");
                break;
            case 0x79:
                printf("[0x79] - [VK_F10] - [F10 key]\n");
                break;
            case 0x7A:
                printf("[0x7A] - [VK_F11] - [F11 key]\n");
                break;
            case 0x7B:
                printf("[0x7B] - [VK_F12] - [F12 key]\n");
                break;
            case 0x7C:
                printf("[0x7C] - [VK_F13] - [F13 key]\n");
                break;
            case 0x7D:
                printf("[0x7D] - [VK_F14] - [F14 key]\n");
                break;
            case 0x7E:
                printf("[0x7E] - [VK_F15] - [F15 key]\n");
                break;
            case 0x7F:
                printf("[0x7F] - [VK_F16] - [F16 key]\n");
                break;
            case 0x80:
                printf("[0x80] - [VK_F17] - [F17 key]\n");
                break;
            case 0x81:
                printf("[0x81] - [VK_F18] - [F18 key]\n");
                break;
            case 0x82:
                printf("[0x82] - [VK_F19] - [F19 key]\n");
                break;
            case 0x83:
                printf("[0x83] - [VK_F20] - [F20 key]\n");
                break;
            case 0x84:
                printf("[0x84] - [VK_F21] - [F21 key]\n");
                break;
            case 0x85:
                printf("[0x85] - [VK_F22] - [F22 key]\n");
                break;
            case 0x86:
                printf("[0x86] - [VK_F23] - [F23 key]\n");
                break;
            case 0x87:
                printf("[0x87] - [VK_F24] - [F24 key]\n");
                break;

            /*
            case 0x88-8F:
                printf("[0x88-8F] - [-] - [Unassigned]\n");
                break;
            */

            case 0x90:
                printf("[0x90] - [VK_NUMLOCK] - [NUM LOCK key]\n");
                break;
            case 0x91:
                printf("[0x91] - [VK_SCROLL] - [SCROLL LOCK key]\n");
                break;

            /*
            case 0x92-96:
                printf("[0x92-96] - [] - [OEM specific]\n");
                break;
            case 0x97-9F:
                printf("[0x97-9F] - [-] - [Unassigned]\n");
                break;
            */

            case 0xA0:
                printf("[0xA0] - [VK_LSHIFT] - [Left SHIFT key] [Down]\n");
                break;
            case 0xA1:
                printf("[0xA1] - [VK_RSHIFT] - [Right SHIFT key] [Down]\n");
                break;
            case 0xA2:
                printf("[0xA2] - [VK_LCONTROL] - [Left CONTROL key]\n");
                break;
            case 0xA3:
                printf("[0xA3] - [VK_RCONTROL] - [Right CONTROL key]\n");
                break;
            case 0xA4:
                printf("[0xA4] - [VK_LMENU] - [Left ALT key]\n");
                break;
            case 0xA5:
                printf("[0xA5] - [VK_RMENU] - [Right ALT key]\n");
                break;
            case 0xA6:
                printf("[0xA6] - [VK_BROWSER_BACK] - [Browser Back key]\n");
                break;
            case 0xA7:
                printf("[0xA7] - [VK_BROWSER_FORWARD] - [Browser Forward key]\n");
                break;
            case 0xA8:
                printf("[0xA8] - [VK_BROWSER_REFRESH] - [Browser Refresh key]\n");
                break;
            case 0xA9:
                printf("[0xA9] - [VK_BROWSER_STOP] - [Browser Stop key]\n");
                break;
            case 0xAA:
                printf("[0xAA] - [VK_BROWSER_SEARCH] - [Browser Search key]\n");
                break;
            case 0xAB:
                printf("[0xAB] - [VK_BROWSER_FAVORITES] - [Browser Favorites key]\n");
                break;
            case 0xAC:
                printf("[0xAC] - [VK_BROWSER_HOME] - [Browser Start and Home key]\n");
                break;
            case 0xAD:
                printf("[0xAD] - [VK_VOLUME_MUTE] - [Volume Mute key]\n");
                break;
            case 0xAE:
                printf("[0xAE] - [VK_VOLUME_DOWN] - [Volume Down key]\n");
                break;
            case 0xAF:
                printf("[0xAF] - [VK_VOLUME_UP] - [Volume Up key]\n");
                break;
            case 0xB0:
                printf("[0xB0] - [VK_MEDIA_NEXT_TRACK] - [Next Track key]\n");
                break;
            case 0xB1:
                printf("[0xB1] - [VK_MEDIA_PREV_TRACK] - [Previous Track key]\n");
                break;
            case 0xB2:
                printf("[0xB2] - [VK_MEDIA_STOP] - [Stop Media key]\n");
                break;
            case 0xB3:
                printf("[0xB3] - [VK_MEDIA_PLAY_PAUSE] - [Play/Pause Media key]\n");
                break;
            case 0xB4:
                printf("[0xB4] - [VK_LAUNCH_MAIL] - [Start Mail key]\n");
                break;
            case 0xB5:
                printf("[0xB5] - [VK_LAUNCH_MEDIA_SELECT] - [Select Media key]\n");
                break;
            case 0xB6:
                printf("[0xB6] - [VK_LAUNCH_APP1] - [Start Application 1 key]\n");
                break;
            case 0xB7:
                printf("[0xB7] - [VK_LAUNCH_APP2] - [Start Application 2 key]\n");
                break;

            /*
            case 0xB8-B9:
                printf("[0xB8-B9] - [-] - [Reserved]\n");
                break;
            */

            case 0xBA:
                printf("[0xBA] - [VK_OEM_1] - [Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the \';:\' key]\n");
                break;
            case 0xBB:
                printf("[0xBB] - [VK_OEM_PLUS] - [For any country/region, the \'+\' key]\n");
                break;
            case 0xBC:
                printf("[0xBC] - [VK_OEM_COMMA] - [For any country/region, the \',\' key]\n");
                break;
            case 0xBD:
                printf("[0xBD] - [VK_OEM_MINUS] - [For any country/region, the \'-\' key]\n");
                break;
            case 0xBE:
                printf("[0xBE] - [VK_OEM_PERIOD] - [For any country/region, the \'.\' key]\n");
                break;
            case 0xBF:
                printf("[0xBF] - [VK_OEM_2] - [Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the \'/?\' key]\n");
                break;
            case 0xC0:
                printf("[0xC0] - [VK_OEM_3] - [Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the \'`~\' key]\n");
                break;

            /*
            case 0xC1-D7:
                printf("[0xC1-D7] - [-] - [Reserved]\n");
                break;
            case 0xD8-DA:
                printf("[0xD8-DA] - [-] - [Unassigned]\n");
                break;
            */

            case 0xDB:
                printf("[0xDB] - [VK_OEM_4] - [Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the \'[{\' key]\n");
                break;
            case 0xDC:
                printf("[0xDC] - [VK_OEM_5] - [Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the \'\\|\' key]\n");
                break;
            case 0xDD:
                printf("[0xDD] - [VK_OEM_6] - [Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the \']}\' key]\n");
                break;
            case 0xDE:
                printf("[0xDE] - [VK_OEM_7] - [Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the \'single-quote/double-quote\' key]\n");
                break;
            case 0xDF:
                printf("[0xDF] - [VK_OEM_8] - [Used for miscellaneous characters; it can vary by keyboard.]\n");
                break;
            case 0xE0:
                printf("[0xE0] - [-] - [Reserved]\n");
                break;
            case 0xE1:
                printf("[0xE1] - [] - [OEM specific]\n");
                break;
            case 0xE2:
                printf("[0xE2] - [VK_OEM_102] - [The <> keys on the US standard keyboard, or the \\| key on the non-US 102-key keyboard]\n");
                break;

            /*
            case 0xE3-E4:
                printf("[0xE3-E4] - [] - [OEM specific]\n");
                break;
            */

            case 0xE5:
                printf("[0xE5] - [VK_PROCESSKEY] - [IME PROCESS key]\n");
                break;
            case 0xE6:
                printf("[0xE6] - [] - [OEM specific]\n");
                break;
            case 0xE7:
                printf("[0xE7] - [VK_PACKET] - [Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP]\n");
                break;
            case 0xE8:
                printf("[0xE8] - [-] - [Unassigned]\n");
                break;

            /*
            case 0xE9-F5:
                printf("[0xE9-F5] - [] - [OEM specific]\n");
                break;
            */

            case 0xF6:
                printf("[0xF6] - [VK_ATTN] - [Attn key]\n");
                break;
            case 0xF7:
                printf("[0xF7] - [VK_CRSEL] - [CrSel key]\n");
                break;
            case 0xF8:
                printf("[0xF8] - [VK_EXSEL] - [ExSel key]\n");
                break;
            case 0xF9:
                printf("[0xF9] - [VK_EREOF] - [Erase EOF key]\n");
                break;
            case 0xFA:
                printf("[0xFA] - [VK_PLAY] - [Play key]\n");
                break;
            case 0xFB:
                printf("[0xFB] - [VK_ZOOM] - [Zoom key]\n");
                break;
            case 0xFC:
                printf("[0xFC] - [VK_NONAME] - [Reserved]\n");
                break;
            case 0xFD:
                printf("[0xFD] - [VK_PA1] - [PA1 key]\n");
                break;
            case 0xFE:
                printf("[0xFE] - [VK_OEM_CLEAR] - [Clear key]\n");
                break;
            default:
                printf("[UNKNOWN]\n");
                break;
        }
    }
    if((nCode == HC_ACTION) && ((wParam == WM_SYSKEYUP) || (wParam == WM_KEYUP)))
    {
        kbdStruct = *((KBDLLHOOKSTRUCT*)lParam);

        switch((unsigned int)kbdStruct.vkCode)
        {
            case 0xA0:
                printf("[0xA0] - [VK_LSHIFT] - [Left SHIFT key] [Up]\n");
                break;
            case 0xA1:
                printf("[0xA1] - [VK_RSHIFT] - [Right SHIFT key] [Up]\n");
                break;
        }
    }
    return CallNextHookEx(hKeyHook, nCode, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int nCmdShow)
{
    hKeyHook = SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)KeyEvent, GetModuleHandle(NULL), 0);
    MSG message;
    while(GetMessage(&message, NULL, 0, 0))
    {
        TranslateMessage(&message);
        DispatchMessage(&message);
    }
    UnhookWindowsHookEx(hKeyHook);
    return 0;
}

Actually This code works - it shows the key presses when i type on physical keyboard, but when someone connects to my computer with AnyDesk and changes the keyboard layout it shows VK_PACKET / Fails to detect keystrokes...
So how can i detect the keystrokes AND / OR key codes sent to my computer?


text:
Q: Free group and normal subgroups with corresponding schreier representatives. Let $\mathbb{F}$ be a free group on $a$ and $b$. Let $N$ be the normal subgroup of $\mathbb{F}$ generated by $a^2,b^3$ and $(ab)^2$. Similarly $H$ is the normal subgroup generated by $a^2,b^3$ and $aba^{-1}b^{-1}$.
i) Show that $N\neq H$.
ii)Find Schreier representative for $\mathbb{F}$ mod $H$ and $\mathbb{F}$ mod $N$.

A: I don't know the Schreier representative, however there is some information I can provide.
$$F/N=\langle a,b \mid b^3,a^2,aba^{-1}=b^{-1}\rangle\cong D_6$$
$$F/H=\langle a,b \mid b^3,a^2,ab=ba \rangle\cong C_2\oplus C_3$$

A: If I understand you correctly, a Schreier system of representatives for both subgroups should be provided by
$$
1, b, b^{2}, a, b a, b^{2} a
$$
Addendum The reason is that both quotient groups are a semidirect product of a cyclic group $\langle b \rangle$ of order three by a cyclic group $\langle a \rangle$ of order $2$. Then one of them is abelian (and thus cyclic of order $6$) while the other is not (and thus isomorphic to the symmetric group on three letters, a.k.a. the dihedral group of order $6$).


text:
Q: Importing plain (raw) files into a postgres table (bytea and large objects) What is a good way to insert/copy plain files into a postgres table, preferrably using the psql command-line?
In my case the files are a bunch of eMails from Maildir archives, so I tried to use COPY:
psql -c "COPY emails (data) FROM '/tmp/emailfile' WITH (FORMAT text);" emails

which I would use in a for-loop shell script (for file in $(ls dir); do psql ...; done).
However, I have trouble finding a good "delimiter" that couldn't possibly be in the file,
and I'm getting these errors: ERROR:  extra data after last expected column.
So I considered using the COPY ... FORMAT binary version and a BYTEA field in the db (then convert the column to TEXT inside the db),
but that requires a file header and trailer, which I have no easy way of building on-the-fly.
Is there an easy way to do this from the commandline, or do I need to write a python script for this?

A: Server-side files
Assuming  the account has the pg_read_server_files role (or is superuser), if the files are accessible on a filesystem mounted on the server, and their paths have been collected in the table, this will grab the contents efficiently:
UPDATE emails SET mail_data = pg_read_binary_file(emails.fullpath);

It is more efficient than using large objects as an intermediate storage area.
Client-side files
When the files are not accessible server-side or the account does not have elevated permissions, with psql a more generic solution may be, for each file:
\set clientpath '/path/to/file'
-- assume clean paths (without any character that would be special to the shell)
\set contents `base64 :clientpath`

insert into email_data([other columns...], mail_data)
 values ( [other columns values...], decode(:'contents','base64'));

A base64 intermediate representation is used because psql doesn't support parameters in binary form. The :'contents' syntax instructs psql to inject the variable in text form into the query.

A: This PDF document PGOpen2018_data_loading.pdf I found, explains data
imports using PG's Large Objects support.
It's been a bit unclear, and is slightly cumbersome; so I scripted it to automate the process (see below).
The procedure works as follows:
-- Create table
CREATE TABLE tmp_docs(file_name text PRIMARY KEY);
-- Pull list of filenames from folder
psql -c "\copy tmp_docs FROM PROGRAM 'ls /file/location/data/* -R' WITH (FORMAT csv);" emails
-- Add fields to hold file link ID and blob of the files
ALTER TABLE tmp_docs ADD COLUMN doc bytea, ADD COLUMN doc_oid oid;
-- Add the documents to large object storage and return the link id
UPDATE tmp_docs SET doc_oid = lo_import(file_name);
-- Pull documents from large object storage into table
UPDATE tmp_docs SET doc = lo_get(doc_oid);
-- Delete the files from large object storage
SELECT lo_unlink(doc_oid) FROM tmp_docs;

Note, the last SELECT did error out for me, I increased shared_buffers and
max_locks_per_transaction for my number of files.
[...]
WARNING:  out of shared memory
WARNING:  out of shared memory
ERROR:  out of shared memory
HINT:  You might need to increase max_locks_per_transaction.

I've written scripts to automate the whole process for me,
a server-side variant and a client-side (remote) version using psql-local
functions.
They've become slightly large for a SO codeblock, so instead they got a GitHub repo here

https://github.com/nyov/postgres-bindata-batchimport

and this is their usage:
mkdir /tmp/randomtext
for OF in `seq 101 120`; do # twenty random files, please
   curl -s http://metaphorpsum.com/paragraphs/5/5 > /tmp/randomtext/${OF};
done

DB="postgres"

# Usage: ./pg_bytea_batchimport_*.sh <dbname> <source-dir> [<tablename>]
# Run script
./pg_bytea_batchimport_cs.sh $DB /tmp/randomtext tmp_docs
# (or) Server-side version; faster, but requires a local db cluster
#./pg_bytea_batchimport_ss.sh $DB /tmp/randomtext tmp_docs

# Verify; should count 20 rows
psql -c "SELECT count(*) FROM tmp_docs" $DB
psql -c "SELECT encode(doc::bytea, 'escape')::text FROM $TABLE LIMIT 1" $DB

# clean up
rm -r /tmp/randomtext
psql -c "DROP TABLE tmp_docs" $DB
unset DB

Comparing client-side vs server-side script run-time, the client-side variant
is about 50% slower on average. Here timed on a test dataset of many smallish
text-files:
time ./pg_bytea_batchimport_ss.sh emails /mnt/stor/

real    2m48.045s
user    0m0.368s
sys 0m0.092s

time ./pg_bytea_batchimport_cs.sh emails /mnt/stor/

real    4m46.319s
user    0m1.944s
sys 0m4.448s


text:
Q: What is the purpose of the "territory" configuration parameter? This is the command that I use to create a new Db2 database in my project:
db2 create db <DATABASE_NAME> using codeset 1251 territory ru

Unfortunately, there is no documentation left and I cannot trace the origin of this specific command. I am trying to understand the purpose of the territory parameter. The Db2 documentation says:

This parameter shows the territory used to create the database.
  territory is used by the database manager when processing data that is
  territory sensitive.

What could be the purpose of this parameter? What kind of data could be territory sensitive? What are the possible use cases where territory matters?

A: "Territory" is essentially equivalent to country code or locale. This setting affects default behaviour of the database when handling the date format, as well as the default SYSTEM collation (sorting) in some locales. Note that the client locale overrides this, so, when connected to a database with territory ru from a client with a US locale, the default date format will be taken from the client setting.
It is also used by federation to determine the necessary conversions when retrieving data from remote servers with different territory (locale) settings.


text:
Q: Repeated measures anova: lm vs lmer I'm trying to reproduce several interaction test between with both lm and lmer on repeated measures (2x2x2). The reason I want to compare both methods is because SPSS's GLM for repeated measures yields the exact same results as the lm approach presented here, so at the end I want to compare SPSS vs R-lmer. So far, I've only managed to reproduce (closely) some of these interactions.
You'll find below a script to better illustrate my point:
library(data.table)
library(tidyr)
library(lmerTest)
library(MASS)

set.seed(1)

N     <- 100 # number of subjects
sigma <- 1   # popuplation sd
rho   <- .6  # correlation between variables

# X1:   a  a  a  a  b  b  b  b
# X2:   a  a  b  b  a  a  b  b
# X3:   a  b  a  b  a  b  a  b
mu <- c(5, 3, 3, 5, 3, 5, 5, 3) # means

# Simulate the data
sigma.mat <- rep(sigma, length(mu))
S <- matrix(sigma.mat, ncol = length(sigma.mat), nrow = length(sigma.mat))
Sigma <- t(S) * S * rho
diag(Sigma) <- sigma**2
X <- data.table( mvrnorm(N, mu, Sigma) )
setnames(X, names(X), c("aaa", "aab", "aba", "abb", "baa", "bab", "bba", "bbb"))
X[, id := 1:.N]

# Long format
XL <- data.table( gather(X, key, Y, aaa:bbb) )
XL[, X1 := substr(key, 1, 1)]
XL[, X2 := substr(key, 2, 2)]
XL[, X3 := substr(key, 3, 3)]

# Recode long format (a = +1; b = -1)
XL[, X1c := ifelse(X1 == "a", +1, -1)]
XL[, X2c := ifelse(X2 == "a", +1, -1)]
XL[, X3c := ifelse(X3 == "a", +1, -1)]

### Composite scores to be used with lm
# X2:X3 2-way interaction (for half the data; i.e. when X1 == "a")
X[, X1a_X2.X3 := (aaa - aab) - (aba - abb)]

# X2:X3 2-way interaction (for all the data)
X[, aa := (aaa + baa) / 2]
X[, ab := (aab + bab) / 2]
X[, ba := (aba + bba) / 2]
X[, bb := (abb + bbb) / 2]
X[, X2.X3 := (aa - ab) - (ba - bb)]

# X1:X2:X3 3-way interaction (for all the data)
X[, X1.X2.X3 := ( (aaa - aab) - (aba - abb) ) - ( (baa - bab) - (bba - bbb) )]

### Fit models
# X2:X3 2-way interaction (for half the data; i.e. when X1 == "a")
summary( lm(X1a_X2.X3 ~ 1, X) ) # t = 34.13303
summary( lmer(Y ~ X2c*X3c + (X2c+X3c|id), XL[X1 == "a"]) ) # t = 34.132846  close match
summary( lmer(Y ~ X2c*X3c + (X2c+X3c||id), XL[X1 == "a"]) ) # t = 34.134624  close match

# X2:X3 2-way interaction (for all the data)
summary( lm(X2.X3 ~ 1, X) ) # t = 0.3075025
summary( lmer(Y ~ X2c*X3c + (X2c+X3c|id), XL) ) # t = 0.1641932
summary( lmer(Y ~ X2c*X3c + (X2c+X3c||id), XL) ) # t = 0.1640710
summary( lmer(Y ~ X2c*X3c + (X2c*X3c|id), XL) ) # t = 0.1641765
anova(   lmer(Y ~ X2c*X3c + (X2c*X3c|id), XL), ddf = "Kenward-Roger" ) # t = 0.1643168
summary( lmer(Y ~ X2c*X3c + (X2c*X3c|id), XL, REML = FALSE) ) # t = 0.1645303
summary( lmer(Y ~ X2c*X3c + (X2c*X3c||id), XL) ) # t = 0.1640704

# X1:X2:X3 3-way interaction (for all the data)
summary( lm(X1.X2.X3 ~ 1, X) ) # t = 46.50177
summary( lmer(Y ~ X1c*X2c*X3c + (X1c*X2c*X3c - X1c:X2c:X3c|id), XL) ) # t = 49.0317599
anova(   lmer(Y ~ X1c*X2c*X3c + (X1c*X2c*X3c - X1c:X2c:X3c|id), XL), ddf = "Kenward-Roger" ) # t = 49.03176
summary( lmer(Y ~ X1c*X2c*X3c + (X1c*X2c*X3c - X1c:X2c:X3c|id), XL, REML = FALSE) ) # t = 49.2677606
summary( lmer(Y ~ X1c*X2c*X3c + (X1c*X2c*X3c - X1c:X2c:X3c||id), XL) ) # t = 46.5193774 close match
summary( lmer(Y ~ X1c*X2c*X3c + (X1c*X2c*X3c|id), XL) ) # unidentifiable
summary( lmer(Y ~ X1c*X2c*X3c + (X1c*X2c*X3c|id), XL,
              control = lmerControl(check.nobs.vs.nRE="ignore")) ) # t = 46.5148684 close match

As you can see from above, none of the lm estimations are exactly matched by the lmer ones. Although some of the results are very similar and may differ only due because of numerical/computational reasons. The gap between both estimation method is specially large for the X2:X3 2-way interaction (for all the data).
My question is if there's a way to obtain the exact same results with both methods, and if there is a correct way to perform the analyses with lmer (although it may not match the lm results).

Bonus:
I've noticed that the t value associated with the 3-way interaction is affected by the way factors are coded, which seems very strange to me:
summary( lmer(Y ~ X1*X2*X3 + (X1*X2*X3 - X1:X2:X3||id), XL) ) # t = 48.36
summary( lmer(Y ~ X1c*X2c*X3c + (X1c*X2c*X3c - X1c:X2c:X3c||id), XL) ) # t = 56.52

A: Strange, when I use your last model, I find a perfect match, not a close match:
Fixed effects:
            Estimate Std. Error       df t value Pr(>|t|)
(Intercept)  3.91221    0.07242 99.00001  54.025   <2e-16 ***
X1c          0.03277    0.05006 99.00000   0.655    0.514
X2c         -0.04836    0.04644 99.00000  -1.042    0.300
X3c          0.04248    0.05009 99.00001   0.848    0.398
X1c:X2c      0.08370    0.08747 98.99998   0.957    0.341
X1c:X3c     -0.07025    0.08895 98.99994  -0.790    0.432
X2c:X3c     -0.02957    0.09616 99.00000  -0.308    0.759
X1c:X2c:X3c -8.14099    0.17507 99.00003 -46.502   <2e-16 ***


text:
Q: parser the xml and build a ui for user Now I have to handle some xml in my java swing application.
I have to build a swing ui according to the special schema ,then user can fill some values.After user completed,I will collect the information,validate the value and then build a xml file.
For building xml file I can use the xmlbeans,however how to parse the schema and build a swing ui? Since the schema is rather complex.
A schema can be found here:
example schema
I have to parser this schema,for the LiteralInputType ,a JTextArea should be built.
However there are other types "complexType" and etc..
These types may not occur at the sametime. Some times only the LiteralInputType is needed,somethimes the ComplexType is needed,also maybe all of them are needed.
So, how to implement it? Anyone can help me?

A: Interesting to see someone else busy with WPS. :)
I believe WPS is quite special so that no existing tool would be able to build user interfaces for WPS processes. When we were solving this task, we just took a JAXB-based parser for WPS and simply built the UI programmaticaly using factories. We've implemented Swing-based as well as Javascript/OpenLayers based generic WPS clients this way.


text:
Q: Null Reference error in gridview code While debugging I found that ItemID value is getting null. I am trying to get the list item's ID.
   ItemId = GridView1.DataKeys[e.RowIndex].Value.ToString();

Can anyone please tell me what could be the reason and how to solve this?
I have tried different things but nothing is working.
Is there anything wrong with this gridview?
<asp:GridView ID="GridView1" runat="server" OnRowEditing="Edit_row" OnRowCancelingEdit="cancel_Edit" OnRowDeleting="Delete_row" OnRowUpdating="Update_row" AutoGenerateColumns="true" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
               <Columns>
                   <asp:TemplateField HeaderText="Sr No.">
                       <ItemTemplate>
                           <%# Container.DataItemIndex+1 %>
                       </ItemTemplate>
                   </asp:TemplateField>

               </Columns>

                 <AlternatingRowStyle BackColor="White" />
                <FooterStyle BackColor="#CCCC99" />
                <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
                <RowStyle BackColor="#F7F7DE" />
                <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#FBFBF2" />
                <SortedAscendingHeaderStyle BackColor="#848384" />
                <SortedDescendingCellStyle BackColor="#EAEAD3" />
                <SortedDescendingHeaderStyle BackColor="#575357" />
            </asp:GridView>

A: I guess you will need set DataKeyNames property of gridview. I don't see that property set in your Gridview.
Hence ItemId = GridView1.DataKeys[e.RowIndex].Value.ToString(); returning null value.
For reference: https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.datakeys(v=vs.110).aspx
https://msdn.microsoft.com/en-in/library/system.web.ui.webcontrols.gridview.datakeynames(v=vs.110).aspx


text:
Q: How do I get real-time facebook page feed in my webhook? I subscribed my page with feed event in pages webhook (https://developers.facebook.com/docs/pages/realtime/).
Also, setup the apps webhook product with feed subscribe and changed the domain name as webhook domain name. We have "manage_pages" permission on our app and our app is now live mode. I tried every possible way that I know and got after googling. But I couldn't receive facebook page feed real-time data in my webhook. Please help me to solve this problem.
Thanks so much.
Note: I tried before posting this question: https://stackoverflow.com/a/52039198/5695622 with the test user. But didn't get the real-time facebook page feed on my webhook.

A: The problem with the "Ngrok", that's why I didn't get the real-time facebook feed data. After chatting with facebook support they fix the problem.
Here is the facebook support link


text:
Q: How can I use the model.ckpt Files from Tensorflow Training on Google Cloud for making predictions? I am using Tensorflow 1.15 and Python 3.7 and I am a beginner.
I trained a tensorflow model with my own dataset on google cloud as described here:
https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf1_training_and_evaluation.md
After training my google cloud bucket had listed the model.ckpt files. I saved the model as described here: https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/exporting_models.md . Doing this generated some files: checkpoint, frozen_inference_graph.pb, model.ckpt.data-00000-of-00001, model.ckpt.index, model.ckpt.meta, pipeline.config and a folder "saved_model" which contains a file saved_model.pb and an empty variables folder. So far so good. Now I wanted to use these files to make predictions using this notebook: https://colab.research.google.com/github/tensorflow/models/blob/master/research/object_detection/colab_tutorials/object_detection_tutorial.ipynb but I stuck at the "load object detection model" section, I always get this
OSError: SavedModel file does not exist at: home/user/models/research/exported_graphs/saved_model/{saved_model.pbtxt|saved_model.pb}

What am I doing wrong? I tried all the possibilities and read dozens of stackoverflow articles but I can't find any usable solution. Is there any other possibility to use the model.ckpt files which were generated by training to make a .h5 / make predictions?
Thank you very much in advance!

A: Firstly upload saved_model on Google_cloud, and use below code snippet to load saved_model.
def load_model(model_name):
  #path to model directory
  model_dir = "model_directory"

  model_dir = pathlib.Path(model_dir)/"saved_model"

  model = tf.saved_model.load(str(model_dir))

  return model


text:
Q: Clarification on reduce to create filter in javascript My main goal for academic purposes is to solve this problem and for the most part I did. Also I wanted to make sure that I was not missing a fundamental part of reduce by not understanding what is wrong with my code.
This is how I would solve it, I've attached my reduce function as well as filter function. I believe my reduce function works however, my filter function isn't quite working so well as I can't pass my test cases.
1) Why am i not hitting the last element of the array?
I've noticed that prev and curr actually never return 5 at any point of the reduce function. Am I missing something in my reduce function?

myArray = [1,2,3,4,5];

function each(collection, action){
 if(Array.isArray(collection)){
  for(var i = 0; i < collection.length; i ++){
   action(collection[i]);
  }
 }
 else if(typeof(collection) === "object"){
  for (var property in collection){
   action(collection[property]);
  }
 }
}

function reduce(collection, combine, start){
 each(collection, function(element){
  if(start === undefined){
   return start = element;
  }
  else {
   return start = combine(start, element);
  }
 });
 return start;
}

function filterR(collection, predicate){
 var aR = [];
 reduce(collection, function(prev, curr){
  if(predicate(prev)){
   aR.push(prev);
  }
  if(predicate(curr)){
   aR.push(curr);
  }

 });
 return aR;
}

console.log(filter(myArray, function(val){return val % 5 === 0;})); //expected [5]
console.log(filter(myArray, function(val){return val <= 5;})); //expected [1,2,3,4,5]

A:
I can't diagnose your problem because I don't know what your each procedure is.
Anyway, it doesn't matter; you're overthinking it.

reduce is very simple to implement by hand.
function reduce(f, start, arr) {
  if (arr.length === 0)
    return start;
  else
    return reduce(f, f(start, arr[0]), arr.slice(1));
}

// example
function add(x,y) { return x+y; }
reduce(add, 0, []);      //=> 0
reduce(add, 0, [1,2,3]); //=> 6

I see that you are trying to support a sort of reduce without an optional starting value. That is impossible if your reduce function is to be considered a total function. A starting value is required. Don't try to be clever.

Now a filter implemented using reduce
function filter(f, arr) {
  return reduce(function(result, x) {
    if (f(x))
      return result.concat([x]);
    else
      return result;
  }, [], arr);
}

Your examples
var myArray = [1,2,3,4,5];

filter(function(val){return val % 5 === 0;}, myArray)
//=> [5]

filter(function(val){return val <= 5;}, myArray)
//=> [1, 2, 3, 4, 5]

If you want to learn more...
There are other ways to implement reduce as well. One such improvement you could make is to put the recursion in tail position. When JavaScript engines support tail call elimination (with ES6), this would prevent reduce from stack-overflowing for significantly large values of arr.
function reduce(f, start, arr) {
  function loop(result, arr) {
    if (arr.length === 0)
      return result;
    else
      return loop(f(result, arr[0]), arr.slice(1));
  }
  return loop(start, arr);
}

A blackhole appears...
With reduce and higher-order functions under your belt, you now stand at the shores of the deep, vast sea that is lambda calculus and functional programming. If you're feeling very zealous, you can explore how currying and combinators change this definition even more dramatically.
The following code is written in ES6
// U-combinator
const U = f=> f(f);

// Y-combinator
const Y = U (h=> f=> f (x=> h (h) (f) (x)));

// reduce
const reduce = f=> Y(h=> start=> arr=>
  arr.length === 0
    ? start
    : h (f (start) (arr[0])) (arr.slice(1)));

// filter
const filter = f=>
  reduce(result=> x=>
    f(x) ? result.concat([x]) : result) ([]);

// your examples again...
var myArray = [1,2,3,4,5];
filter (x=> x % 5 === 0) (myArray) //=> [5]
filter (x=> x <= 5) (myArray)      //=> [1, 2, 3, 4, 5]

A:
Why am i not hitting the last element of the array?

I don't know. It might be an error in your each-function, wich is not posted here. But since you have some more flaws in boh of your functions, I'll add a working implementation.

I've noticed that prev and curr actually never return 5 at any point of the reduce function.

prev and curr never return anything, they are arguments. And that particular function itself, also doesn't ever return anything.
First start === undefined is no proper check to determine wether yo want to initialize the result-value with the first(current)-element. undefined is an unexpected, even unwanted value in that place, but it is actually perfectly fine. So with that check, your reduce-function might start over again, in the middle of the collection.
Just take a look at the previously mentioned function you utilize in filter. This function does return undefined (as the value for the next iteration) ;) so that prev will always be undefined in your code.
Then, reduce makes no sense in your filter-function, at least the way you use it. You use it as each.
function reduce(collection, combine, start){
    var result = start, hasValue = arguments.length > 2;

    each(collection, function(element){
        if(hasValue){
            result = combine(result, element);
        }else{
            result = element;
            hasValue = true;
        }
    });

    if(!hasValue){
        //no start/default-value, no elements in the collection,
        //what result do you expect from this reduce-task?
        throw new Error("reduce of empty array with no initial value");
    }
    return result;
}

function filter(collection, predicate){
    return reduce(collection, function(result, elm){
        //the functional-approach: no mutations
        return predicate(elm)?
            result.concat( [elm] ):
            result;

        //or a more sane way to do this in JS
        if( predicate(elm) ) result.push( elm );
        return result;
    }, []);
}


text:
Q: How to show sql table data in hierarchy in JAVA I have 2 tables unit and unit_hier. unit table contains some static data and unit_hier table contains hierarchy relation.
**UNIT TABLE**
UNIT_ID     UNIT_NAME       DESC
1           Test1           Test 1
2           Test2           Test 2
3           Test3           Test 3
4           Test4           Test 4
5           Test5           Test 5
6           Test6           Test 6
7           Test7           Test 7
8           Test8           Test 8
9           Test9           Test 9
10          Test10          Test 10
11          Test11          Test 11
12          Test12          Test 12
13          Test13          Test 13
14          Test14          Test 14

**UNIT_Hier Table**
PARENT_UNIT_ID  CHILD_UNIT_ID
1               2
1               3
1               4
2               5
2               6
5               7
5               8
3               9
7               10
3               11
3               12
4               13
5               14

Now as per unit_hier table I need to frame a response json.
Below are the expected response json:
{
        "UNIT_ID": 1,
        "UNIT_NAME": "Test1",
        "DESC": "Test 1",
        "childUnit":[
            {"UNIT_ID": 2,
            "UNIT_NAME": "Test2",
            "DESC": "Test 2",
            "childUnit":[
                {"UNIT_ID": 5,
                "UNIT_NAME": "Test5",
                "DESC": "Test 5",
                "childUnit":[
                    {"UNIT_ID": 7,
                    "UNIT_NAME": "Test7",
                    "DESC": "Test 7",
                    "childUnit":[
                        {"UNIT_ID": 10,
                        "UNIT_NAME": "Test10",
                        "DESC": "Test 10",
                        "childUnit":[]
                        }
                        ]},

                    {
                    "UNIT_ID": 8,
                    "UNIT_NAME": "Test8",
                    "DESC": "Test 8",
                    "childUnit":[]
                    },
                    {
                    "UNIT_ID": 14,
                    "UNIT_NAME": "Test14",
                    "DESC": "Test 14",
                    "childUnit":[]
                    }

                {
                "UNIT_ID": 6,
                "UNIT_NAME": "Test6",
                "DESC": "Test 6",
                "childUnit":[]
                }
                ],

        {
            "UNIT_ID": 3,
            "UNIT_NAME": "Test3",
            "DESC": "Test 3",
            "childUnit":[
                {"UNIT_ID": 9,
                "UNIT_NAME": "Test9",
                "DESC": "Test 9",
                "childUnit":[]
                },
                {
                "UNIT_ID": 11,
                "UNIT_NAME": "Test11",
                "DESC": "Test 11"
                "childUnit":[]
                },
                {
                "UNIT_ID": 12,
                "UNIT_NAME": "Test12",
                "DESC": "Test 12",
                "childUnit":[]
                }
        ],
        {
        "UNIT_ID": 4,
        "UNIT_NAME": "Test4",
        "DESC": "Test 4",
        "childUnit":[
        {"UNIT_ID": 13,
        "UNIT_NAME": "Test13",
        "DESC": "Test 13",
        "childUnit":[]
        }
        ]
        }
        }
    }

Problem is I tried simply parsing the data. I am getting only 1 level of parsing but I need to get all the child till the last element where no child exists.

A: JPA does support recursive parent/child relationships via normal
bidirectional @ManyToOne/@OneToMany
Your table structure needs changing before you can use it though. You don't need a separate hierarchy table. Just add a parentId column to the main table and map via it bidirectionally.