text:
Q: OpenGL 1.1 scene coordinates to screen coordinates I know OpenGL 1.x is more than only outdated but due to the required target hardware which lacks better OpenGL drivers, I'm bound to this kind of legacy code. Or in other words: people pay for support of this old crap and who pays is the boss...
My problem: Before sending my objects coordinates, I set some transformation with functions glLoadIdentity(), glTranslatef(), glScaled(), glRotatef() to change the view to my objects by translating/zooming/rotating.
These parameters can be changed by the user to get a different view to the scene (by dragging the mouse on the related window).
My problem: how can I convert between the scene-coordinates (based on the transformation done by the functions described above) and the draw-canvas coordinates (means position of the mouse on the window that displays the scene)?
Thanks!


text:
Q: DNS Configuration: Am I doin' it right? Here's how I have my DNS records setup:
domain.com          IN     A         <server ip>
sub1.domain.com     IN     CNAME     domain.com
sub2.domain.com     IN     CNAME     domain.com
www.domain.com      IN     CNAME     domain.com

sub1.domain.com and sub2.domain.com are alternate ways of accessing domain.com. By default my host had an A record for *.domain.com but I removed it.
Is this setup correct?

A: The A record for domain.com is exactly right, you can't use a CNAME there.
My personal view is that pointing a CNAME back at the apex of your domain is sub-optimal:

*

*It inadvertently means that any other records at your apex (especially NS, SOA and MX) also exist for those subdomains.  That may have unintended consequences.

*It's marginally slower than using an A record as the DNS client has to follow the CNAME chain.

To avoid the first problem my recommendation would be:
domain.com          IN     A         <server ip>
www.domain.com      IN     A         <server ip>
sub1.domain.com     IN     CNAME     www.domain.com
sub2.domain.com     IN     CNAME     www.domain.com

A: Alternatively, you don't even need CNAME records, and I don't recommend using them unless you have a really good reason to do so.
domain.com          IN     A         <server ip>
www.domain.com      IN     A         <server ip>
sub1.domain.com     IN     A         <server ip>
sub2.domain.com     IN     A         <server ip>

redpajama_set_name: RedPajamaStackExchange


text:
Q: K-Means Binary Clustering in OpenCV to Extract Mask I try to use cv2.kmeans to segment the left auricle DICOM image as mask.

I use the following code to do the k-means binary clustering in OpenCV.
import numpy as np
import cv2
import os
from matplotlib import pyplot as plt

img = cv2.imread('1_LA.jpg')
img2 = img.reshape((-1, 3))
img2 = np.float32(img2)

criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 10, 1.0)
ret, label, center = cv2.kmeans(img2, 2, None, criteria, 10, cv2.KMEANS_RANDOM_CENTERS)
center = np.uint8(center)

res = center[label.flatten()]
res2 = res.reshape((img.shape))
cv2.imwrite('1_LA_kmeans.jpg', res2)

Then, I can get this segmentation result well.

But how can I extract one of the segmentations as mask?
I have referred other similar questions, and I try to use the code from here.
import numpy as np
import cv2

img = cv2.imread('1_LA.jpg')
Z = np.float32(img.reshape((-1,3)))

criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 10, 1.0)
K = 2
_,labels,centers = cv2.kmeans(Z, K, None, criteria, 10, cv2.KMEANS_RANDOM_CENTERS)
labels = labels.reshape((img.shape[:-1]))
reduced = np.uint8(centers)[labels]
result = [np.hstack([img, reduced])]

for i, c in enumerate(centers):
    mask = cv2.inRange(labels, i, i)
    mask = np.dstack([mask]*3) # Make it 3 channel
    ex_img = cv2.bitwise_and(img, mask)
    ex_reduced = cv2.bitwise_and(reduced, mask)
    result.append(np.hstack([ex_img, ex_reduced]))
    cv2.imwrite('kmeans/' + str(i) + '_1.jpg', np.vstack(result))

cv2.imwrite('1_LA_kmeans.jpg', np.vstack(result))

Then, I can get this output.

Becase I want to calculate the area of the left auricle, I need to extract the mask like below.

So, how can I extract one of the binary segmentation results?

A: Thanks for @fmw42's help.
After I refer this answer, and use the following code.
import cv2
import numpy as np

# read input and convert to range 0-1
image = cv2.imread('1.jpg')
h, w, c = image.shape

# reshape to 1D array
image_2d = image.reshape(h*w, c).astype(np.float32)

# set number of colors
numcolors = 2
numiters = 10
epsilon = 1
attempts = 10

# do kmeans processing
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, numiters, epsilon)
ret, labels, centers = cv2.kmeans(image_2d, numcolors, None, criteria, attempts, cv2.KMEANS_RANDOM_CENTERS)

# reconstitute 2D image of results
centers = np.uint8(centers)
newimage = centers[labels.flatten()]
newimage = newimage.reshape(image.shape)
#cv2.imwrite("1_test.jpg", newimage)
#cv2.imshow('new image', newimage)
#cv2.waitKey(0)

k = 0
for center in centers:
    # select color and create mask
    #print(center)
    layer = newimage.copy()
    mask = cv2.inRange(layer, center, center)

    # apply mask to layer
    layer[mask == 0] = [0,0,0]
    #cv2.imshow('layer', layer)
    #cv2.waitKey(0)

    # save kmeans clustered image and layer
    if(k == 0):
        cv2.imwrite("1_test{0}.jpg".format(k), layer)
    k = k + 1

I can extract the mask I want, appreciate.


text:
Q: Capturing output of asynchronous bash commands? Is it possible to do something like this in bash?
output=$(echo hello; sleep 10) &
pid=$!
# run some more commands
wait $pid
echo $output

I would like to run multiple commands in parallel, capturing their output. I'd like to do it in a "clean" way - not writing to temporary files etc.

A: You can use a named pipe to communicate between parent and child, see man mkfifo for details. Parent can use read command to fetch data from the pipe.


text:
Q: Adding block programmatically to InnerBlocks I am building a tab-style block, where you can choose tab in a header and enter the content in the section. For section, I am using InnerBlocks where you can insert specific "Tab" blocks separately created.
I set InnerBlocks property templateLock to 'all', so user cannot add tabs via usual interface. Instead, when "new tab" is clicked in header area, new Tab block should be programmatically inserted (via dispatch('core/editor').insertBlock()). This works only when Innerblocks template is not locked.
Any solutions? Unlock then lock Innerblocks? How?
Is there more elegant solution?


text:
Q: Puppeteer video automatically downloading instead of displaying player Basically I have this piece of code below
;(async () => {
  const browser = await puppeteer.launch({
    args: ['--no-sandbox'],
    headless: false
  })

  const page = await browser.newPage()

  await page.goto('https://www.w3schools.com/html/mov_bbb.mp4', {waitUntil: 'load'})
})()

and for some reason when I execute the script chromium just automatically starts downloading the video instead of showing the player.
Is there any way I could prevent this?

A: At the time of writing this answer, Unfortunately Chromium does not support playing .mp4, Learn more: https://www.chromium.org/audio-video
How can you bypass this action?
You can download the latest chrome dev version from here,
https://www.chromium.org/getting-involved/dev-channel
And then use that chrome path like this,
const browser = await puppeteer.launch({
    args: ["--no-sandbox"],
    headless: false,
    executablePath: "./chrome-unstable/chrome" // <-- chrome path here
});

You'll see it loads properly without downloading,

There is one major drawback, the browser doesn't know when the page is loaded, Should it wait until the whole video is loaded? Should it autoplay?
Puppeteer still does not have any good way to deal with media files except to download it. Same goes with .ppt, .doc, .pdf and any other kind of files.
You can look for other media related issue here: https://github.com/GoogleChrome/puppeteer/issues?utf8=%E2%9C%93&q=is%3Aissue%20mp4


text:
Q: Display data in HTML form when loaded N00b alert; I know enough to be dangerous, so forgive my ignorance...I've been through all of the related questions here and elsewhere, but I just can't seem to comprehend the answer that's surely included in the responses :-(
I'm posting a record id to a page where I want a form to display with the contents of the related record. I'm getting the record in correctly (confirmed using the alert) with this script in the HEAD section (jquery 1.9 is called as well):

...and the form in the BODY to be loaded:
<form method="post" id="quoteForm" action="process_quote.php">

    Name
    <input type="text" value="<?php $customerRecord['full_name']; ?>" name="full_name">

...other bits of the form...

        <input type="submit" value="Submit">

</form>

I know I'm incorrectly munging various things together. Can someone please get me straightened out on what to do?
Michael's answer solved the INPUT fields in the form. Didn't mention I had SELECT fields as well:
<select size="0" name="email_sent">
    <option value="No">No</option>
    <option value="Yes">Yes</option>
</select>

Changing INPUT to SELECT works.

A: What your missing is where code is being executed. The PHP code is being executed on the server, before being sent to the browser. The Javascript is then rendered by the browser. You can't pass variables back and forth between Javascript and PHP.
You want to inject the name with Javascript. I see you're already using jQuery, so the heavy lifting is already done for you. Remove the value="<?php $customerRecord['full_name']; ?>" from the PHP file, and replace $("#quoteForm").load(customerRecord); with $("#quoteForm input[name='full_name']").val(customerRecord.full_name);
Should work, might need some variation depending on your exact circumstances. At least it should put you down the right path.


text:
Q: SelectOneMenu ajax does not work I'm working on project base on primefaces....
I'm trying to do as follows: JSF
<p:selectOneMenu        id          = "activeTin"
                        panelStyle  = "width:280px"
                        effect      = "fade"
                        var         = "t"
                        value       = "#{homeBean.value}"
                        itemValue   =  "#{data}">

               <p:ajax  process     =  "@this"
                        event       =  "change"
                        listener    =  "#{homeBean.changeActiveTin}"
                        update      =  "@this"/>

           <f:selectItems value     = "#{homeBean.valueList}"
                          var       = "data"
                          itemLabel ="#{data.companyTinId}"></f:selectItems>
</p:selectOneMenu>

selectOneMenu dose not enter ajax listener
What's wrong in my code?


text:
Q: WooCommerce: Add content to archive with multiple filter attributes I want to add some SEO content to some of my archives.
For example:
I have a category called "Sportcars".
It's easy to add some content thereby adding it to the category archive page.
But I also want some content on the archive where I filter by "Sportcars" (product category), "Cabrio" (attribute) and "black" (attribute).
The URL looks something like this:

domain.com/products/sportcars/?filter_type=cabrio&filter_color=black

Is there any way to address such an archive?
I'm thinking about something to do with the URL parameters.
But I couldn't figure out a good solution.
Maybe there is a way to rewrite the URL to add some ID's for the category and the filters and use them to build a custom post type with a slug based on ID's.
I can then search for the post type and display. it's content.
But maybe the filters are in different orders sometimes!?
For example here's what I mean:

domain.com/products/100/?filter_type=200&filter_color=300

Now the Custom Post Type slug is something like this (not visible in the frontend):

/seo-content/100-200-300/

Is this possible? Or is there a better way?
I searched a lot and couldn't find anything.

A: An easy way to get the job done without messing with custom slugs and archives is to use a php if statement in your archive checking if the values posted is "cabrio" & "black" like this:
$filter_type = $_GET[filter_type];
$filter_color = $_GET[filter_color];
if ( (isset($filter_type) == 'cabrio') && (isset($filter_color) == 'black') )
{
//your content here
} else {
//your content here
}


text:
Q: What is a "split peg" in a header Specifically, I ask about the Molex 36638 series header, but I guess that it is a more common term.
I searched Images for a peg, for a split peg etc. but I still have no idea what it is about. There is no further explanation in the respective datasheet https://www.molex.com/pdm_docs/ps/PS-36638-001-001.pdf.

A: The split peg is a plastic pin that pushes into a hole on the PCB to provide mechanical strength - also known as a snap pin.
From the technical drawing of those connectors, we see this diagram which shows how the peg looks:

We can confirm that this is what is meant by the split peg, partly because it looks like a peg that is split, but also because that drawing indicates the same part numbers differentiating between w/ PCB Snap and w/o PCB snap in the same way the other document says w/ Split Peg and w/o Split Peg.


text:
Q: Web2py - How to determine end of load control after ajax I run a ajax call that updates interpolated value as a fully built selectbox element.
I would like to transform the created/returned selectbox into a chosen selectbox once it has finished fully loading otherwise it reverts back to a regular selectbox.
I have tried:

*

*Listening to 'DOMSubtreeModified'(and other similar events) and then activating chosen lines but, these run too often and I have to know when the selectbox with all options are fully initiated. I can force initiation on each change, it's terrible - resource consuming and just plain wrong.

*Initiate some callback on ajax return('ajax:complete' event) but, again - this does not guarantee the html controls are fully initiated as stated in this answer (and tested).

*I've tried to set a onload event for the select control.

Main lines of code:
JavaScript call:
ajax('{{=URL('controller_name', 'func_name')}}', ['param1'], 'target_div');

Python controller returns(this returns a select control with option objects initiated in it and overrides the target_div inner html):
return SELECT(distinct_values, _id = 'selectbox_id' , _multiple = 'true' , _class='SelectBoxSingleDisabled');

Looking for a web2py oriented solution. No brute force/hacky stuff if possible. thanks!

A: There are several options (the first two are suggested here):

*

*In the controller, add the Chosen initialization code to response.js -- this will be executed after the returned HTML is added to the DOM.

*Add the Chosen initialization code to a script element after the select element:
CAT(SELECT(distinct_values, _id = 'manual_group_selectbox' , _multiple = 'true' ,
           _class='SelectBoxSingleDisabled'),
    SCRIPT('[Chosen code]'))

*The third argument to the ajax() function can be a Javascript function that takes the data returned by the server. So, you could write a function that adds the returned HTML to the DOM and then initializes Chosen:
ajax(
  '{{=URL('controller_name', 'func_name')}}', ['param1'],
  function(html) {
    [add html to DOM]
    [initialize Chosen]
  }
);

*Set up a jQuery .ajaxSuccess() event handler, which should run after the ajax() function updates the DOM.


text:
Q: XSLT String Comparison How can I compare strings to create a table with XSLT?
I have an xml like this:
<Os>
        <O type="xyz">
            <Count>126</Count>
            <Food>Yes</Food>
            <Owner name="Jack">
                <Phone>564815</Phone>
            </Owner>
            <Date>12/12/2014</Date>
        </O>
        <O type="zyx">
            <Count>56</Count>
            <Food>No</Food>
            <Owner name="Phill">
                <Phone>826633</Phone>
            </Owner>
            <Date>09/11/2015</Date>
        </O>
</Os

And I want to traverse in it with for each and add a row if food='yes'.
  <xsl:for-each select="Os/O">
  <xsl:sort select="Count" data-type="number" />

    <xsl:value-of select="@type"/>
    <xsl:value-of select="Count"/>
    <xsl:value-of select="Food"/>
    <xsl:value-of select="Owner/@name"/>
    <xsl:value-of select="Owner/Phone"/>
    <xsl:value-of select="Date"/>

  </xsl:for-each>

I think I can do it if I say food:1 when there is food and food:0 when there is not. And then I can write an if statement food>0 but I don't want to do that.
Thanks in advance.

A:
add a row if food='yes'.

Why don't you simply use a predicate:
<xsl:for-each select="Os/O[Food='yes']">
  ...

A: Here's how to do it with <xsl:if>:
<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
  <xsl:template match="Os">

      <xsl:for-each select="O">
        <xsl:sort select="Count" data-type="number" />
        <xsl:if test="Food='Yes'">

            <xsl:value-of select="@type"/>
            <xsl:value-of select="Count"/>
            <xsl:value-of select="Food"/>
            <xsl:value-of select="Owner/@name"/>
            <xsl:value-of select="Owner/Phone"/>
            <xsl:value-of select="Date"/>

        </xsl:if>
      </xsl:for-each>

  </xsl:template>

</xsl:stylesheet>


text:
Q: Programmatically switch USB between shared (disk mode) and mounted (charge only) I have an old HTC Desire S connected to my PC with a USB cable, and am doing development work on both a PC program and an Android app. It is convenient for me to have the PC program write some test data to the Android device's SD card (needs shared mode), and then for the Android app to read this test data from the SD card (needs mounted mode, otherwise it gets a FileNotFoundException with "permission denied").
I can manually switch back and forth between the shared and mounted modes by pulling down the notification tray menu on the Android device, and using the "USB connection type" menu item.
But that's inconvenient, so my question is, are there some Android API calls I can make, so my Android app can switch the USB connection to mounted mode, read the test data, and then switch back to shared mode so it's ready for the next iteration of my PC program?

A: Rather than toggling the USB mode back and forth, consider if it might be effective and more convenient to transfer your development test data to and from the device using the adb push and adb pull commands.
If you strongly prefer GUI interfaces, there is a file browser built atop adb push/pull in the DDMS tool, and perhaps also in whatever the Android Studio equivalent of that is.


text:
Q: On Android or iOS - how to approach the possibility of a service or app going into a broken state ...and this broken state persisting until a device restart, since a naive attempt to restart an app would not work. Many users are not savvy enough to know how to terminate services/backgrounded apps. If the user can't (or doesn't 'need to') close apps, then what about restarting apps which have gone wrong? ( It can happen :) ) If my app goes wrong on someone's phone and they cannot easily restart the app without restarting the phone, that seems like a problem. I am aware that apps and services can be terminated by navigating system menus or double tapping the home button etc. but - many users are not aware of these features. For this reason I am thinking of adding an explicit close button to my app which will kill everything to the best of my ability, such that on a subsequent launch the program runs from the beginning again. I realise this is not the 'recommended' approach. Thoughts?

A:
Thoughts?

Don't do it. Instead you should put a FAQ entry on your apps website that says.

Q: My app does not run anymore. HELP!
A: First you should try to restart the app. If that doesn't work feel
  free to contact me.
Here is how you do this on the iPhone,
  iPad or iPod.
double press the home button. the
  multi tasking bar appears.
[ some screen shots ]
long press the app icon and press the
  little x that appears on the icon.
[ more screenshots ]

If you want to put buttons for functions that are not obvious for many users you end up with a button for everything. And I (as somebody who knows every function) don't want a button cluttered user interface.
You would be surprised how many emails I get about "how can I zoom?" (A: Pinch your fingers) or "how do I delete an entry (in a tableview)" (A: Swipe your finger over the entry from left to right, and press the red delete button).
If I get an email about this I just point them to the faq which has some nice screenshots.

Btw, if the "broken state" happens so often that you would consider adding a special button I would check my code for bugs again.


text:
Q: Use existing sql-alchemy model class as flask-restplus api.model? I am developing a CRUD application using vue.js and vuetify as frontend (view) and python flask-resplus and sqlAlchemy as backend (controler and model).
app/main/model/person.py
from sqlalchemy import Column, Integer, String, Date
from app.main.repository.base_repository import Base

    class Person(Base):
        __tablename__ = 'person'

        id = Column(Integer, primary_key=True)
        name = Column(String)
        date_of_birth = Column(Date)

        def __init__(self, name=None, date_of_birth=None):
            if name is not None:
                self.name = name
            if date_of_birth is not None:
                self.date_of_birth = date_of_birth

app/main/controller/person_controller.py
from flask_restplus import Namespace, fields, Resource, cors
from flask import request
from app.main.service.person_service import PersonService
from app.main.model.person import Person

api = Namespace('persons', description='Person related operations')

persServ : PersonService = PersonService()

model = api.model('Person', {
    'id': fields.Integer,
    'name': fields.String,
    'date_of_birth': fields.Date
})

@api.route("/persons/all")
class PersonList(Resource):
    @api.marshal_with(model)
    def get(self, **kwargs):
        return persServ.get_persons()
        # return Person(name="Test", date_of_birth=date(1984, 10, 20))

@api.route("/person/<int:id>")
class PersonReturn(Resource):
    @api.marshal_with(model)
    def get(self, id):
        return persServ.get_person(id)

@api.route("/person/<int:id>")
class PersonUpdate(Resource):
    @api.marshal_with(model)
    def put(self, id):
        data = request.json
        #TODO marshalling currently still error
        return persServ.update_person(pers=data)

@api.route("/person")
class PersonCreate(Resource):
    @api.marshal_with(model)
    def post(self):
        data = request.json
        #TODO: check why person is not correctly linked to sql alchemy when reated here, make sure that model.Person is created
        # pers = Person()
        # pers.name = data['name']
        # persServ.create_person(pers)
        return persServ.create_person_02(data['name'])

@api.route("/person/<int:id>")
class PersonDelete(Resource):
    def delete(self, id):
        persServ.delete_person(id)
        return '', 204

Questions also after implementing a spring java backend :
1) Is it necessary to provide an api.model in person_controller.py or can I annotate properties in person.py? Could you kindly guide me to a tutorial annotating an existing object?
2) Naming conventions flask api classes: In my eyes it definitely makes sense to use PersonList and Person instead of PersonUpdate, PersonCreate to ease API documentation as described in the flask-resPlus full example: https://flask-restplus.readthedocs.io/en/stable/example.html
However, I already have an existing Person class in person.py. I am thinking about having two person classes, a Person(Resource) in person_controller.py for Post, Put and Get operations and a Person in person.py as domain specific person object. However, I do not want to cause confusion and adhere to naming and orgainization good practices. What is the suggested naming approach? Is there a good example tutorial?


text:
Q: How to keep Midnight Commander running after you open a file? mc (Midnight Commander) is an excellent CLI file manager, but I have really struggled with this problem:
How to get mc to keep running after you choose to open a file?
For example, when I navigate to a particular file on mc (say a jpeg file), and click on it, it opens the image in image viewer, but mc itself becomes inaccessible unless I close the image file. I would like to keep using mc even after I open the image file (or any file).
Similar to using the detach option on linux terminal (where any command after detach will run in the background and will not affect the current terminal session), I want to configure mc so that I can keep browsing through mc after opening a file. This is the default behavior in the nnn file manager, but mc has so many more features that I love, so I'd love to keep using it.
The important thing is I'd like this to happen for all files/extensions (not just when opening particular file types on mc).
My operating system is Arch Linux on i3 windows manager.
Thank you!

A: When you press Enter on a file, Midnight-Commander looks for a match in
~/.config/mc/mc.ext (if it is missing, grab a copy from the installation path,
typically /etc/mc). Read and understand the comments and the structure of that file.
For example, mine has this entry:
type/image
 Open=xfimage %f &

A image file matches the image type, as file -i filename will show,
so xfimage will open with the selected file (%f).
Because of the trailing &, Xfimage is backgrounded, i.e., MC will not block.
Notes:

*

*Remember that the first match will take precedence (besides type match, there is also shell pattern and regex matches).

*Add 2>/dev/null to the "Open" command if the command prints diagnostic
messages that garble MC's screen.

*%s macro can be used instead of %f to pass all the marked files
to the program. My answer in U&L shows a use-case.

*If the command is complicated enough, just write a separate script
and use that for "Open". Also to be found on that link.


text:
Q: Scalebox method returns error while using binom $\scalebox{2}{\binom{2}{3x+3}}$

The code works if I use mathlarger, but curious to know why scalebox doesn't work here and what's wrong with my code as I've been working on this for an hour but didn't work.
Thanks

A: You need to replace
$\scalebox{2}{\binom{2}{3x+3}}$

with
\scalebox{2}{$\binom{2}{3x+3}$}

Why? Because the argument of \scalebox is in text mode by default, whereas \binom needs to be processed in math mode.

It's not clear to me why one would ever consider embedding a \binom expression in a \scalebox. If your use case is simply that you need to enlarge the binom expresson while in inline math mode, you should definitely not be using \scalebox{$\binom{2}{3x+3}$}; instead, do write either $\displaystyle\binom{2}{3x+3}$ or, more succinctly, $\dbinom{2}{3x+3}$. (\dbinom and \tbinom are to \binom as \dfrac and \tfrac are to \frac.)
\documentclass{article}
\usepackage{amsmath,graphicx}
\begin{document}
$\binom{2}{3x+3}$ vs.\
\scalebox{2}{$\binom{2}{3x+3}$}
\qquad
$\displaystyle\binom{2}{3x+3}$ vs.\
\scalebox{2}{$\displaystyle\binom{2}{3x+3}$}
\end{document}


text:
Q: Rails form not submitting if too many POST parameters I have a very strange problem. I have a form which have around 150 - 160 fills(text fields and check boxes). I tried placing a Rails.logger.info("Params: #{params[:filterrific]}) where the form would point to once submitted to see if the parameters are being displayed.
On my development machine, All the parameters showed up perfectly but when I tried submitting on my server(production environment), the form doesn't seem to be submitted as the logger does not display the parameters. I tried disabling 10 - 20 of those fields and tried again and surprisingly it works this time. I really have no idea where the problem is and would be great if anyone could help me with this.


text:
Q: Tensors in a two-dimensional Euclidean plane Consider a two-dimensional Euclidean plane with coordinates $(x^1,x^2)$
If we define a set of new coordinate $z^1$ and $z^2$
$$z^1=x^1+ix^2$$
$$z^2=x^1-ix^2$$
A question is if a symmetric tensor $T^{\mu\nu}$ satisfies the equation
${T^\mu}_\mu=0$ then what are the consequences
for its co-variant components?
I don't really get the question, can anyone help?

A: It's page 20 of the book.
Anyways, let's first work out things in $(x^1,x^2)$ coordinates. We are starting with
$$
T^{\mu\nu} = \begin{pmatrix}T^{11}&T^{12}\\T^{21}&T^{22}\end{pmatrix}
$$
Since the plane is Euclidean, we also know that
$$
g_{\mu\nu} = \begin{pmatrix}1&0\\0&1\end{pmatrix}
\quad,\quad
g^{\mu\nu} = \begin{pmatrix}1&0\\0&1\end{pmatrix}
$$
In terms of contravariant coordinates, the traceless tensor obeys:
$$
T^{\mu}_{\;\;\mu} = T^{\mu\nu} g_{\mu\nu} = T^{11} + T^{22} = 0
$$
Now, let's calculate the covariant components.
$$
T_{\mu\nu}
\stackrel{\text{def.}}{=}\begin{pmatrix}T_{11}&T_{12}\\T_{21}&T_{22}\end{pmatrix}
\stackrel{\text{def.}}{=}g_{\mu\rho}g_{\nu\sigma}T^{\rho\sigma}
=
\begin{pmatrix}T^{11}&T^{12}\\T^{21}&T^{22}\end{pmatrix}
$$
Keep in mind that the latter equality holds due to the particular form of the metric. Had we chosen it to be Lorentzian, we would end up with ${\{T_{11}=T^{11},T_{12}=-T^{12},T_{21}=-T^{21},T_{22}=T^{22}\}}$. Anyways, from the latter equation we conclude that ${\{T_{11}=T^{11},T_{22}=T^{22}\}}$. Therefore for covariant coordinates one has
$$
T^{\mu}_{\;\;\mu} = T_{11} + T_{22} = 0
$$
We now want to switch to $(z^1,z^2)$ coordinates. The partial derivatives will be calculated according to
$${x^1=\dfrac{1}{2}(z^1+z^2)
\quad,\quad
x_2=\dfrac{1}{2i}(z^1-z^2)}$$
The covariant components of the tensor in the new basis are:
$$
T_{\alpha\beta} = \dfrac{\partial x^\mu}{\partial z^\alpha}
\dfrac{\partial x^\nu}{\partial z^\beta} T_{\mu\nu} =
\dfrac{1}{4}\begin{pmatrix}T_{11}-i(T_{12}+T_{21})-T_{22}&T_{11}+T_{22}\\T_{11}+T_{22}&T_{11}+i(T_{12}+T_{21})-T_{22}\end{pmatrix}
$$
Wherefrom it follows that the condition $T^{\mu}_{\;\;\mu} = T_{11} + T_{22} = 0$ implies vanishing of non-diagonal components in the $(z^1,z^2)$ basis.


text:
Q: Failed to save settings . Please restart IntelliJ IDEA 2020.1 linux pc I am using IntelliJ IDEA 2020.1 in my linux pc and I have a problem with the auto-saving.  When I close IntelliJ and reopen my IDE, it doesn't save my configuration and shows me this message:
Unable to save settings : Failed to save settings . Please restart IntelliJ IDEA
what should I do for this.

A: Check the full error in idea.log file (Help | Show Log in ... action). Usually it contains the reason.
It may help to re-open the project using File | New | Project from Existing Sources and select to delete existing project configuration files.


text:
Q: How would use a get() method to access an element in an arrayList? This is my code I have so far but I don't know how to access an element in the Array myList?
And is the inex of an array list start at 0 or 1?
I have just found out about array lists and i need a few pointers and some help
ArrayList<String> myList = new ArrayList<String>();

        myList.add("hello");
        myList.add("5");
        myList.add("3");
        myList.add("8");
        int totalElements = myList.size();
        System.out.println(totalElements);

private String[] myList;
    public String getList() {
        return this.myList[0];

A: String a = myList.get(0); //a = "hello"
String b = myList.get(1); //b = "5"

A: In java, array's index is start from 0.
To access the nth element in one list, you can call list.get(n).

A: All you have to do is:
myList.get(Index);

This would return you the type of Object you used while creating the ArrayList. In your case it will return a String. Hence, what you can do is:
String firstElement = myList.get(0); //This would return "Hello"

This also shows that ArrayList indices start with 0


text:
Q: What changes have been made to my cpanel? What is the most easily accessible way to track changes made to cPanel?
Ideally I would like to create a script which gathers information from the cPanel logs, but are there any scripts already created to do this?

A: Not entirely sure this is what you want, but it might help you:
If you have logwatch installed, go to /etc/log.d/conf/logwatch.conf
Inside change mailto to your own e-mail address. There will also be an option to change the level of detail to either Low, Medium or High.
You should be able to run a test with: ./usr/share/logwatch/scripts/logwatch.pl --range today.


text:
Q: Is there a suitable table design to store SQL queries? For example,
I want to save the query condition
where a=1 or b=2

or

where a=1 and b=2 and c=4

by structuring the columns of the table rather than the raw sql text. Do you have a good table design?


text:
Q: How to calculate number combinations of formulas for a number of propositions I can see, using a paper, that the number of different combinations of forumals (in the sense extensively discussed in the comments) that one proposition can have is $4$, and even that the number for two propositions is $16$.
EDIT: These are the ones for one proposition:
p
0 0 0  1 1
1 0 1  0 1
We could basically see the second colum (first of combinations) as the function 0, the third as p, the fourth as -p and the fifth as 1
And I can understand that for $4$ would be $256$ and for $4$ $65536$. Because basically it's squaring the previous.
But not sure how does that fit into combinations, variations, etc... I mean, I kind of guess, by observations but wouldn't be able to phrase that in a way of saying "the number of truth tables for a given number of propositions is the equal to the combination (or whatever is applicable) of those numbers..."
Is there an easy way to state that.
Thanks

A: To write down a truth table for $n$ propositions, you have to assign True or False to each of the $2^n$ possible combinations of truth values that those propositions can take.
Thus you have to choose True or False $2^n$ times; the number of ways to do this is $2 \times 2 \times \cdots \times 2$, where there are $2^n$ factors, or $2^{2^n}$.


text:
Q: PHP match JSON/CSV into SQL database with many adjustments (cakePHP) I want to insert a JSON file (also available as CSV) into a mySQL database using the cakePHP framework. The basics are clear, but the surrounding requirements make it difficult:

*

*The JSON/CSV file is large (approx. 200 MB and up to 200.000 lines).

*The file contains several fields. These fields need to be mapped to fields with different names in the mySQL database.

*The CSV contains a field named art_number. This field is also present in the mySQL database. The art_number is unique, but not the primary key in mySQL. I want to update the mySQL record if CSV and database have the same art_number. If not a new record should be created.

*Several fields of the CSV file need to be processed before they are stored. Also additional fields need to be added.

*The CSV contains an image_URL. If it is a NEW record (unknown art_number) to the database, this image should be copied, modified (with imagick) and stored on the server.

*The whole job needs to run on a daily basis.

As you can see there is a lot going on with some limitations (memory, runtime etc.). But I am not sure how to approach this from an architecture point of view. E.g. should I first try to insert everything into a seperate "import" database table and then run through the steps seperately? What is a good way to get the IDs from the database mapped to the CSV lines? Cakephp is able to perform either creating a new or updating an existing record if I am able to map the ID based on the art_number. Also changing and copying up to 200.000 images seems to be a big issue. So how to break this down into smaller chunks?
I would appreciate if you could help find the right strategy here. What do I need to consider in terms of memory and speed? Doe sit make sense to split the process into different jobs? What/how would oyu do that?

A:
I would appreciate if you could help find the right strategy here. What do I need to consider in terms of memory and speed?

*

*Use a shell for the import

*Read the data in chunks of X lines or X amount of data to avoid memory problems and then process these chunks. It's a simple loop.

*If the processing is going to require a LONG time consider using a job queue like Resque. You can update the status of the progress to the user if needed.

Doe sit make sense to split the process into different jobs? What/how would oyu do that?

This depends on  the requirements and how long your processing will take and how much your system can process in parallel without going up to 100% CPU usage and effectively slowing down the site. If this happens move the processing to another machine or limit the CPU usage for that process using the nice command.


text:
Q: python program to remove duplicate elements from nested lists I am new to stack overflow so please excuse me if I am not clear.
aim: to write a program that would remove the elements that are present in preceding nested lists
here is the list:
gang=[[1], [7], [11], [13], [2, 4, 6, 8, 10, 12, 14], [3, 6, 9, 12, 15], [6, 12], [5, 10, 15]]
desired output: gang=[[1], [7], [11], [13], [2, 4, 6, 8, 10, 12, 14], [3, 6, 9, 15], [5, 10]]
attempt:
for i in range(1,len(gang)):
    elem=gang[i]
    for j in range(len(elem)):
        for hey in range(i):
            if elem[j] in gang[hey]:
                elem.pop(j)

explanation of the attempt:
1)to traverse through list gang, I used a for loop (range is 1,len(gang) bcs 0th element wont be changed as it is the first one in the list)
2)I have declared a variable, 'elem' which equates to gang[i] i.e. the elements of gang from gang[1] to gang[-1]
3)Now, to traverse through the elements of the elements i.e. the elements of each nested list, I have used another for loop
4)the last for loop (for hey in range(i)) is used so that I can confirm if elem[j] i.e. element of nested list, exists in preceding nested lists, and if the condition is satisfied elem[j] would be removed
expected output:
gang=[[1], [7], [11], [13], [2, 4, 6, 8, 10, 12, 14], [3, 6, 9, 15], [5, 10]]

output:
if elem[j] in gang[hey]:
IndexError: list index out of range

question: why is this error showing? potential fix for it? any better way to achieve aim?

A: Here it is.  You create a visited list, iterate backward through each sublist, and remove an element if it is already visited:
gang=[[1], [7], [11], [13], [2, 4, 6, 8, 10, 12, 14], [3, 6, 9, 12, 15], [6, 12], [5, 10, 15]]
visited = []
for lst in gang:
    for i in range(len(lst)-1, -1, -1):
        if lst[i] not in visited:
            visited.append(lst[i])
        else:
            lst.pop(i)
print(gang)
#[[1], [7], [11], [13], [2, 4, 6, 8, 10, 12, 14], [3, 9, 15], [], [5]]

A: The library itertools is very helpful in this case
import itertools
gang=[[1], [7], [11], [13], [2, 4, 6, 8, 10, 12, 14], [3, 6, 9, 12, 15], [6, 12], [5, 10, 15]]
gang.sort()#Sorting the list
gang = list(k for k,_ in itertools.groupby(gang))#This removes repetition
print (gang)

Check it on a repl here
https://repl.it/join/keztvujw-siddharthagraw2


text:
Q: call function inside
A: This is bad practice
You can explicitly make a variable a global, but modules appear to be loaded asynchronously so you need to wait until the module has been evaluated.
I'm using DOMContentLoaded here, but I don't know if that is reliable.

<script type="module">
  function do_something() { console.log("Something"); } window.do_something = do_something;
</script>

<script type="text/javascript">
  document.addEventListener('DOMContentLoaded', (event) => {
    do_something();
  })
</script>

Instead of doing that, you should design your JS to not need globals in the first place.
Use a module as the entry point into your program, not a non-module.

A: Short answer, no (unless you wish to pollute the global namespace).
MDN Guide on modules states this clearly.

Last but not least, let's make this clear — module features are imported into the scope of a single script — they aren't available in the global scope. Therefore, you will only be able to access imported features in the script they are imported into, and you won't be able to access them from the JavaScript console, for example. You'll still get syntax errors shown in the DevTools, but you'll not be able to use some of the debugging techniques you might have expected to use.


text:
Q: Leaflet - populate circle when clicking on the marker - based on csv data I've produced Leaflet map based on the CSV data as per the project below:
https://github.com/HandsOnDataViz/leaflet-map-csv
https://handsondataviz.org/leaflet-maps-with-csv.html
It works well, although I am stuck on one functionality. Namely, I would like to have the circle with a radius populated when clicking on the marker.
My code looks like this:
 $.get('survey.csv', function(csvString) {
        var data = Papa.parse(csvString, {header: true, dynamicTyping: true}).data;

        for (var i in data) {
            var row = data[i];

            var marker = L.marker([row.lat, row.lng], {
                opacity: 1
            }).bindPopup(' Name: ' + row.sp + '
 Phone: ' + row.phone).on('click', function(e) {
                console.log(data);
            });
            marker.addTo(map).on('click', addCircle).on('popupclose', removeCircle);

            function removeCircle() {
                map.eachLayer(function(layer){
                    if (layer instanceof L.Circle)
                    map.removeLayer(layer)
                });
            }

            function addCircle(e) {
                coords = e.latlng
                var radius = row.radius * 1560
                removeCircle()

                var circle = L.circle([coords.lat,coords.lng]).addTo(map)

                circle.setStyle({
                    color: 'black',
                    fillcolor: 'black'
                })
                circle.setRadius(radius)
            }
        }
    })

and it doesn't work, because I am getting an error:
Uncaught Error: Invalid LatLng object: (NaN, -0.351635159)
at:
  circle.setRadius(radius)

When the radius is defined as a number, everything is fine. When I try to assign the radius defined in my CSV file under column radius by calling row.radius, the error appears.
I tried to define the csv data again within the addCircle(e) function, but it didn't work either. How could I set the csv-based radius on my pop-up circle?

A: Problem is that you are defining functions addCircle() and removeCircle again and again in for (var i in data) loop within $.get('survey.csv', function(csvString) call.
Just move those definition outside:
function removeCircle() {
  map.eachLayer(function(layer){
  if (layer instanceof L.Circle)
    map.removeLayer(layer);
  });
}

function addCircle(e, row) {
  var coords = e.latlng
  var radius = row.radius * 1560
  removeCircle();

  var circle = L.circle([coords.lat,coords.lng]).addTo(map);

  circle.setStyle({
    color: 'black',
    fillcolor: 'black'
  });
  circle.setRadius(radius);
}

$.get('survey.csv', function(csvString) {
  var data = Papa.parse(csvString, {header: true, dynamicTyping: true}).data;
  for (var i in data) {
    var row = data[i];
    var marker = L.marker([row.lat, row.lng], {
        opacity: 1
    }).bindPopup(' Name: ' + row.sp + '
 Phone: ' + row.phone).on('click', function(e) {
      console.log(data);
    });
    marker.addTo(map).on('click', function(evt) {
      addCircle(evt, row);
    }).on('popupclose', removeCircle);
  }
});


text:
Q: How to add checkboxes in Android App toolbar? I need to add a Checkbox in Android App bar. my Menu_main as follow:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">

<item android:id="@+id/action_search"
    android:title="search"
    android:icon="@drawable/ic_search"
    app:showAsAction="ifRoom|collapseActionView"
    app:actionViewClass="android.support.v7.widget.SearchView" />

</menu>

Right now it's showing Title and search icon. How can I add  a Checkbox in Bar right next to Search icon?

A: There are two ways to add CheckBox in menu .
1. User direct class (Action View) e.g
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".tariff.ui.SearchOffersActivity">
    <item
        android:id="@+id/action_search"
        android:icon="@android:drawable/ic_menu_search"
        android:title="@string/search"
        app:actionViewClass="android.support.v7.widget.SearchView"
        app:showAsAction="collapseActionView|always" />
    <item
        android:id="@+id/action_checkbox"
        app:actionViewClass="android.widget.CheckBox"
        android:title="@string/filter"
        app:showAsAction="always" />
</menu>

2- You can use custom layout LINK


text:
Q: Tracking changes in a Google Spreadsheet via a Google apps script I'm trying to build a Google spreadsheet script to track changes in a range of cells say c10:y100, if any of those cells are changed and the user tries to leave the page, I'd like to have a confirm dialog saying "you need to update the revision number of this document".
I've looked at various ways of doing this but could not find the core function that would allow me to trigger this if a user tries to leave the page, with out manually changing the revision number, after making a change in that range.
Any ideas how I would do this?

A: Using Google Apps Script, there is no general feedback on how a user is behaving in the client-side UI - we can't tell if they close the browser tab or browser, for example. Without that, your objective can't be fully met.
You could get partway there by adapting the technique described in How to poll a Google Doc from an add-on to your spreadsheet, and applying a few other tricks...
You can get information about what spreadsheet content is "active":

*

*Spreadsheet.getActiveSheet() will tell you the active "tab"

*Sheet.getActiveCell() and Sheet.getActiveRange() can tell you where the user is on the active sheet. (Not much interest in this case, but still worth noting.)

An onEdit() function can note manual edits to the range you're interested in. It can also open the sidebar when a relevant edit is made! You could have the content of the sidebar encourage or even facilitate generation of your new revision number, for instance by providing a button to complete the task.
// onEdit function that opens sidebar if a particular cell is edited.
function onEdit(e) {
  if (e.range.getSheet().getName() === "Sheet1"
      && e.range.getA1Notation() === "A1") {
    // Edit was performed in our target range

    // First, make a note of the change.

    // Then open our tracking sidebar
    var html = HtmlService.createHtmlOutput('
Up-Revision required
')
                          .setTitle('Tracking sidebar')
                          .setWidth(300);

    var ui = SpreadsheetApp.getUi();
    ui.showSidebar(html);
  }

  // Ignore all other edits
}

Enforcement: There's not much you can do with any web application to stop users from getting up and walking away (or closing a window). Still, you will want to do your best to help them do the right thing.

*

*As mentioned earlier, make it easy for your users, by helping them to set a new revision number.

*If your sidebar poller notes the trigger condition (edit in C10:Y100 without up-versioning) when the user changed tabs, say, then it can open a modal dialog to enforce the up-versioning.

*If you've noted the un-revisioned change in a non-volatile way (using Document Properties, say), then you could have an onOpen() trigger function perform the test and open the sidebar &/or the modal dialog.


text:
Q: Issue in triggering my checkbox in order to make it appear in javascript I hope that  am able to explain my problem properly and you do not blame me!
I want to make a terminal with <pre> element and a text box  http://jsfiddle.net/LQg7W/2149/ obviuosly this jsfiddledoes not show anything because I could not put the ajax post server side inside it. I have a jquery ajax post and when a user write and press enter in a textbox this ajax triggers then it fetches a value from backend and show the result in a  html element.
The problem is that when the text box reaches to the end of  element it disppears from the scene so in order to make it appear I need to write sth on it then it appears. but I want it to always be available. how can I do that? I also added setfocus and scroll bar! but each time it disappears and I need to trigger it by writing in it. any idea?

A: I guess textarea can stand on your requirement, but you need to restrict the user to some maximum length.
<textarea type="text" id="textInput" name="" style="background: #222; color: #fff; border: none; width: 100%; height: 100px; overflow: hidden; resize: none;" autofocus></textarea>

Check this http://jsfiddle.net/LQg7W/2150/


text:
Q: Faced with Changing Hamburger Button to Home Button I faced with a problem. I have MainActivity with Fragment1 and Navigation Drawer. There is a button  in Fragment1 that replace Fragment1 and Fragment2. When Im replacing, I want to turn off Navigation Drawer, change Hamburger button to Home button("<"). So I have method changeTbOn in MainActivity and call it in onCreate Fragment2:
((MainActivity)getActivity()).changeTbOn();

My changeTbOn method:
public void changeTbOn(){
       toggle.setDrawerIndicatorEnabled(false);
        toggle.syncState();
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
       drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        setSupportActionBar(toolbar);
    }

When I did it, Navigation Drawer turn off, Hamburger button didnt changes to Home Button, but it works like Home Button. What I do wrong? I want change it to Home Button icon. Help Please!

A: SOLUTION:
Add this to my changeTbOn method:
 toggle.setHomeAsUpIndicator(R.drawable.back_icon);


text:
Q: Pivot Wider in R I have a dataframe like this
rest_id task_name quarter nc
123     labeling  1       TRUE
123     labeling  2       FALSE
123     labeling  3       FALSE
123     labeling  4       FALSE
123     cooking   1       TRUE
123     cooking   2       FALSE
123     cooking   3       TRUE
123     cooking   4       FALSE
123     cleaning  1       TRUE
123     cleaning  2       FALSE
123     cleaning  3       TRUE
123     cleaning  4       FALSE

I want to pivot it to look like this
rest_id quarter labeling  cooking  cleaning
123     1       TRUE      TRUE     TRUE
123     2       FALSE     FALSE    FALSE
123     3       FALSE     TRUE     TRUE
123     4       FALSE     FALSE    FALSE

I've tried this:
X <- pivot_wider(df,
                 names_from = task_name,
                 values_from = nc,
                 values_fill = list(nc=F))

But it doesn't give me my intended output.. can someone help me?

A: We don't need to create a vector of column names for the wide format.  The names_from  is selecting from the 'task_name' column in the dataset and it creates the wide column name from the unique values of that column
library(dplyr)
library(tidyr)
df %>%
   pivot_wider(names_from = task_name, values_from = nc,
           values_fill = list(nc = FALSE))
# A tibble: 4 x 5
#  rest_id quarter labeling cooking cleaning
#    <int>   <int> <lgl>    <lgl>   <lgl>
#1     123       1 TRUE     TRUE    TRUE
#2     123       2 FALSE    FALSE   FALSE
#3     123       3 FALSE    TRUE    TRUE
#4     123       4 FALSE    FALSE   FALSE

data
df <- structure(list(rest_id = c(123L, 123L, 123L, 123L, 123L, 123L,
123L, 123L, 123L, 123L, 123L, 123L), task_name = c("labeling",
"labeling", "labeling", "labeling", "cooking", "cooking", "cooking",
"cooking", "cleaning", "cleaning", "cleaning", "cleaning"), quarter = c(1L,
2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), nc = c(TRUE, FALSE,
FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
)), class = "data.frame", row.names = c(NA, -12L))


text:
Q: Laravel DB::raw() to take dynamic inputs I have query where I am getting the sum of price by suppliers. The below query works fine.
    private function integrationsSpendBySupplier(array $suppliers)
    {
        $totalBySupplier = DB::table('analytics')
            ->whereIn('source', $suppliers)->select(
                'source',
                DB::raw('sum(price) as total')
            )
            ->groupBy('source')
            ->get();

        return [
            'title' => 'Spend per Supplier',
            'rows'  => 12,
            'type'  => 'bar',
            'data'  => [
                'labels'   => $totalBySupplier->map(fn ($supplier) => $supplier->source),
                'datasets' => [
                    [
                        'label' => 'Total Spending',
                        'data'  => $totalBySupplier->map(fn ($supplier) => $this->stringToFloat($supplier->total))
                    ],
                ]
            ],
            'hasToolTip' => true
        ];
    }

However, I would also like to add more items to the DB::raw() call like so:
DB::raw('sum(price + shipping + tax + something_else) as total')

But these values will be dynamic so it could be all or none of additional params (price will always be there though).
Any thoughts?

A: You can build the SUM() string using basic PHP string and apply that string to the query.
for example
$price = '';
if (priceRequired())
  $price = "price ";

$shipping = '';
if (requiresShipping())
  $shipping  = ", shipping";

// $shipping = requiresShipping() ? ", shipping" : ""; if you're familiar with this syntax

...

DB::raw("sum($price $shipping ...etc) as total");

as a result, the final string should be like price, shipping, tax or price depending on the above conditions.
Note: be careful about the comma's place in the string, this may cause query exceptions


text:
Q: Host name issue with WSFederated Authentication I have configured Local STS with my web application (which is hosted in IIS 7 and has the host name as www.abc.com) and it can receive the claims from the STS and it can login. Now I have added another host name (www.xyz.com) to my web application. If user a login to a page in the application using www.abc.com/page1 and it redirects to local STS and it authenticates the user and adds the security token. Now if the user visits www.xyz.com/page2 it also redirects to the STS for authentication.
If a user either logged in www.abc.com or www.xyz.com they need to access the other domain page with out login. Is it possible? How do we achieve this?

A: In broad strokes, if you have two different relying parties, each needs to route the user to the IDP.  If the IDP is configured for single sign on, the user will only notice the routing to the IDP the first time. On the second routing, (assuming same browser session and that the routing is within the lifetime supported by the IDP) the user will be authenticated without seeing a page at the IDP and being required to present credentials.
So, part of your answer hinges around what you mean by login: if you mean "experience a challenge and enter credentials" by log in, you should be able to enable this by simply ensuring that the IDP is configured for single sign on.
On the other hand, if by login you mean the redirect to the IDP, then you need to make sure the application is able to share state across the different page names. Note that usual management of state is via cookies, and note that a cookie for abc.com will not be returned to a web page named xyz.com. There are a number of clever ways to resolve this, although i am not aware of any simple application configuration solutions. One example is to have some part of both the abc.com page and the xyz.com page accessed by the url shared.com. State cookies can then be set by the shared.com transaction when logging into abc.com and read by the shared.com transaction when subsequently accessing xyz.com.
I've never had to implement such a cross domain cookie solution and have only had off-hand conversations with colleagues about it: we've always found the silent redirect of single sign on to meet our requirements. Careful research into the privacy impact of such a solution and the likelihood that such cookies might be blocked should be considered before development.


text:
Q: Ruby On Rails: Storing collection_select values into an array I have a form that has multiple collect_select fields and I want to be able to store the selected values into an array or hash.
So for example:
<%= f.collection_select(:package_ids, Package.all, :id, :concatTitle, {:prompt => true}) %>
<%= f.collection_select(:package_ids, Package.all, :id, :concatTitle, {:prompt => true}) %>
<%= f.collection_select(:package_ids, Package.all, :id, :concatTitle, {:prompt => true}) %>

I want all the selected id's to be stored into the same field :package_ids. What would be the correct syntax to do this?


text:
Q: Scrolls up when submitting question even though there is no error When I'm writing a question, after I'm done I click the submit button and then I get scrolled up. I search around for the error but it doesn't seem like there is one, I click submit again and it works.
Seems like a strange behaviour. It would be expected if there was an error in submitting such as a missing tag or whatever.


text:
Q: Linked list traversal in Kernel I was using list_for_each_entry(datastructureptr , &mylinkedlist, head) to traverse a linked list i created. The output I got was last inserted item is printed first. Is it the expected output. Is there any macro/function to print it in the other way?

A: list_for_each_entry traverses a list from the first to the last item.
You must ensure that the items are inserted in the correct order and at the correct position.
list_add inserts at the start of the list; list_add_tail at the end.

A: struct private {
        char data[30];
    struct list_head head;
    };
.......
.....
static struct private mylinkedlist;
....
struct private *datastructureptr=&mylinkedlist;
...
   list_for_each_entry(datastructureptr , &mylinkedlist, head)
       printk( " %s->\n",datastructureptr->data);

prints items in fifo way


text:
Q: I need to include orcid ID in Latex beside the author affiliation, I tried many time, but it doesn't work \documentclass{svproc}

\usepackage{url}
\def\UrlFont{\rmfamily}

\usepackage{academicons}
\newcommand{\orcid}[1]{\href{https://orcid.org/#1}{\textcolor[HTML]{A6CE39}{\aiOrcid}}}

\begin{document}
\mainmatter
\title{The title}
%
\titlerunning{abbreviated title}

\author{Ivar Ekeland\inst{1} \and Roger Temam\inst{2}\orcid{0000-0002-5825-931X}}

\institute{XXX University\\
\email{email@email.edu},
\and
YYYY University,\\
\email{email@email.edu}}

\maketitle              % typeset the title of the contribution

\begin{abstract}
The abstract
\keywords{}
\end{abstract}

\section{Section 1}

\begin{thebibliography}{6}

\end{thebibliography}
\end{document}

A: Your test document cannot work because the definition of the \orcid macro contains the directives \textcolor and \href, which are defined by the xcolor and hyperref packages, respectively. Hence, you must load both xcolor and hyperref -- with suitably chosen options, if needed -- for \orcid to work.
Moreover, be sure to compile your document with either XeLaTeX or LuaLaTeX, as that's what is required by the academicons package. To quote from the package's user guide: "The academicons package provides access in (LA)TEX to 122 high quality icons of online academic profiles included in the free Academicons font. This package requires either the XƎ(LA)TEX or Lua(LA)TEX engine to load the Academicons font from the system, which requires installing the bundled academicons.ttf font file."
The following simplified form of your test code compiles fine. (However, I have no way of telling whether the hyperlink embedded in the icon works.)
% !TEX TS-program = xelatex  %% or: "... = lualatex"
\documentclass{svproc}
% 'svproc.cls' file obtained from https://www.springer.com/gp/authors-editors/conference-proceedings/conference-proceedings-guidelines
\usepackage{xurl}
\def\UrlFont{\rmfamily}

\usepackage{xcolor} % for 'HTML' color model and '\textcolor' macro
\usepackage[colorlinks]{hyperref} % for '\href' macro

% 'academicons' package requires either LuaLaTeX or XeLaTeX
\usepackage{academicons}
\newcommand{\orcid}[1]{\href{orcid.org/#1}{\textcolor[HTML]{A6CE39}{\aiOrcid}}}

\begin{document}
\orcid{0000-0002-5825-931X}
\end{document}


text:
Q: Change windows form app (exe) icon at runtime I found a lot of questions around this subject, but none answered mine.
I have a chat application, and it's required that I change the app icon in the task bar when a message is received and not yet seen, and change it back again when all messages are seen.
I was able to do this successfully when running the app from VS2013, using this code in the displayed form:
if (count == 0)
{
    this.Icon = Properties.Resources.Icon1;
}
else
{
    this.Icon = Properties.Resources.IconNotification;
}

however when I publish my app and run the exe, the icon is not being changed.
Note that app icon is mainly set from VS, Application bar in project's properties (Icon and manifest), but I added Icon1.ico and IconNotification.ico to application's resources (Build Action set to Embedded Resource).
What am I missing to make the icon in the task bar change from exe too?

A: Add Application.DoEvents() after updating the icon,
if (count == 0)
{
    this.Icon = Properties.Resources.Icon1;
    Application.DoEvents();
}
else
{
    this.Icon = Properties.Resources.IconNotification;
    Application.DoEvents();
}


text:
Q: Hikari CP DB connection not release in Async block I am using Spring Boot application which has API controller to generate reports . The actual service function is wrapped around @Async annotation and function makes DB calls and generates the csv reports . I am also using Hikari CP for connection pool management and JPA + QueryDSL for forming select queries .
I am seeing strange issue in that DB connections are not being released after the files are successfully generated. Every new call to the controller/service function creates new active connections and it remains active . Its not getting released because of which I am getting Connection is not available error from Hikari once my max pool size limit is reached.
Any suggestions why connection is not being released . The service function issues only select queries , no updates or inserts.
Hikari CP configs:
spring.datasource.hikari.maximum-pool-size: "80"
spring.datasource.hikari.idle-timeout: "300000"
spring.datasource.hikari.connectionTimeout: "600000"
spring.datasource.hikari.minimum-idle: "15"

My service function
@Async
@Override
public void exportListing(String[] filter) {
        try {
}
catch(Exception e)
{
}

A: I fixed it by wrapping it within @Transactional block which ensures that DB connections are closed once the function completes.


text:
Q: Proof Verification: Sum of suprema
For $\nu=1, 2, ..., n$, let $X_\nu$ be set of real numbers. If there is a number $\xi$ such that
$$ \sum_{\nu=1}^n x_\nu \leq \xi, $$
for any $x_\nu\in X_\nu$, then
$$ \sum_{\nu=1}^n \sup X_\nu \leq \xi. $$

Proof. We proceed by induction on $n$. The statement evidently holds for $n=1$. Suppose that the statement holds for $n-1\geq0$. Fix an $x_n\in X_n$, we then have
$$ \sum_{\nu=1}^{n-1} x_\nu \leq \xi-x_n $$
for any $x_\nu\in X_\nu$, $\nu=1, 2, ..., n-1$; hence
$$ \sum_{\nu=1}^{n-1} \sup X_\nu \leq \xi-x_n,$$
or
$$ x_n\leq \xi - \sum^{n-1}_{\nu=1}\sup X_\nu. $$
Since $x_n$ is arbitrary,
$$ \sup X_n \leq \xi - \sum_{\nu=1}^{n-1} \sup X_\nu, $$
as was to be proved.

Let $\{x_n\}$, $\{y_n\}$, and $\{z_n\}$ be sequences of real numbers. Then
$$ \limsup\limits_{n\rightarrow\infty} x_n+y_n+z_n\leq \limsup\limits_{n\rightarrow\infty}x_n+\limsup\limits_{n\rightarrow\infty}y_n+\limsup\limits_{n\rightarrow\infty}z_n. $$

Known properties of limit superior:

*

*If $x>\limsup\limits_{n\rightarrow\infty}x_n$, then $x>x_n$ for all sufficiently large $n$.

*If $x<\limsup\limits_{n\rightarrow\infty}x_n$, then $x<x_n$ for infinitely many $n$.

*If $x_n < y_n$ for all sufficiently large $n$, then $\limsup\limits_{n\rightarrow\infty}x_n\leq\limsup\limits_{n\rightarrow\infty}y_n$.

Proof. Observe that $\limsup [ x_n + c ] = \limsup x_n + c $ for any contant $c$. Let $\epsilon>0$. Then
$$ x_k < \limsup x_n + \epsilon $$
and hence
$$ x_k + y_k < y_k + \limsup x_n + \epsilon $$
for all sufficiently large $k$. Letting $k$ increase without limit, we obtain
$$ \limsup [ x_n + y_n ] \leq \limsup x_n + \limsup y_n + \epsilon; $$
now let $\epsilon\rightarrow0$ so that
$$ \limsup [ x_n + y_n ] \leq \limsup x_n + \limsup y_n. $$
Therefore
$$ \limsup [x_n+y_n+z_n] \leq \limsup [x_n+y_n] + \limsup z_n \leq \limsup x_n + \limsup y_n + \limsup z_n.$$


text:
Q: How to send SMS automatically in flutter I want to send sms to a particular phone number in my flutter application. I tried all flutter packages regarding this issue and github repos but I screw up and did not find any useful source.
Here's my last attempt code.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:sms/sms.dart';

void main() {
 runApp(new MaterialApp(
title: "Send sms Demo",
home: new SendSms(),
 ));
 }

   class SendSms extends StatefulWidget {
  @override
  _SendSmsState createState() => new _SendSmsState();
 }

    class _SendSmsState extends State<SendSms> {
    Future<Null> sendSms()async {
SmsSender smsSender = new SmsSender();
smsSender.sendSms(new SmsMessage('+*****7337544', 'test send sms')); //instead xxx... to receiver
 phone
 }

  @override
 Widget build(BuildContext context) {

return new Material(
  child: new Container(
    alignment: Alignment.center,
    child: new FlatButton(onPressed: () => sendSms(), child: const Text("Click here to Send SMS")),
  ),
);
}
}

And I put this in AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.SEND_SMS"/>

A: I've recently uploaded a sample project on Github that make use of the telephony package, which request for SEND_SMS permissions and dispatch SMS.
Here is the repo
In this sample you have to fire the message with a button, but you can do it automatically if you want to.


text:
Q: Converting from 2019-08-08T20:41:00-1000 to Aug 08, 2019, 08:41 PM HST I want to convert 2019-08-08T20:41:00-1000 to MMM dd, yyyy, hh:mm a z(Aug 08, 2019, 08:41 PM HST) format. I did not find any solution for this.. please help me out
I tried to get offset from that date and converting to date object but it is always showing aug 09, 2019, 12:32 PM GMT+5. which is wrong output...
expected Output is  Aug 08, 2019, 08:41 PM HST

A: Try using angular's date pipe.
{{ value_expression | date [ : format [ : timezone [ : locale ] ] ] }}
https://angular.io/api/common/DatePipe

A: I followed this link How can I deal with the timezone issue with the Angular 4 date pipe?  it solves my issue {{ competition.compStart | date: 'short' : '-120'}}


text:
Q: Probabilty of drawing atleast 1 red ball in 3 attempts. A bag contains 15 balls, of which
5 balls are red,
5 balls are green, and
5 balls are blue.
We are given 3 attempts to draw a ball from this bag randomly, after each attempt, the drawn ball would be kept back in the bag so during each attempt the total balls in the bag would always be 15. My question is, what is the probability of drawing atleast 1 red ball in 3 attempts.

A: The probability of drawing a non-red ball from one attempt is $\frac{10}{15} = \frac{2}{3}$.
Thus the probability of drawing only non-red balls from three attempts is $(\frac{2}{3})^3 = \frac{8}{27}$.
Therefore the probability of drawing at least one red ball from three attempts is:
$$1 - \frac{8}{27} = \frac{19}{27}$$


text:
Q: Sonarqube LDAP: error code 1 and 49 I got these errors when trying to connect to LDAP via sonarqube:

2016.09.13 09:35:16 DEBUG web[o.s.p.l.LdapUsersProvider] Requesting details for user sonartester
  2016.09.13 09:35:16 DEBUG web[o.s.p.l.LdapSearch] Search: LdapSearch{baseDn=cn=Users,dc=mydomain,dc=com, scope=subtree, request=(&(objectClass=user)(sAMAccountName={0})), parameters=[sonartester], attributes=[mail, cn]}
  2016.09.13 09:35:16 DEBUG web[o.s.p.l.LdapContextFactory] Initializing LDAP context {java.naming.provider.url=ldap://myip:389, java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory, com.sun.jndi.ldap.connect.pool=true, java.naming.security.authentication=simple, java.naming.security.sasl.realm=mydomain.com, java.naming.referral=follow}
  2016.09.13 09:35:16 DEBUG web[o.s.p.l.LdapUsersProvider] [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C090728, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v2580]
  javax.naming.NamingException: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C090728, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v2580]
....
2016.09.13 09:35:16 DEBUG web[o.s.p.l.LdapUsersProvider] User sonartester not found in
  2016.09.13 09:35:16 ERROR web[o.s.s.a.RealmAuthenticator] Error during authentication
  org.sonar.api.utils.SonarException: Unable to retrieve details for user sonartester in
  2016.09.13 09:35:16 DEBUG web[o.s.p.l.LdapUsersProvider] User sonartester not found in
  2016.09.13 09:35:16 ERROR web[o.s.s.a.RealmAuthenticator] Error during authentication
  org.sonar.api.utils.SonarException: Unable to retrieve details for user sonartester in

I've created user SONARTEST found in the Users OU and member of the my-group.
The group is also found in the Users OU.
Here is my config:
sonar.security.realm=LDAP
sonar.authenticator.createUsers=true
ldap.url=ldap://myip:389
ldap.bindDn.=cn=someusername,ou=Users,o=mydomain
ldap.bindPassword.=somepassword
ldap.authentication=simple
ldap.realm=mydomain.com

ldap.user.baseDn=cn=Users,dc=mydomain,dc=com
ldap.user.request=(&(objectClass=user)(sAMAccountName={login}))
ldap.user.realNameAttribute=cn

ldap.group.baseDn=ou=Users,dc=mydomain,dc=com
ldap.group.request=(&(objectClass=my-group)(member={dn}))
ldap.group.idAttribute=sAMAccountName

The user used for the bind has all necessary rights, and is found in the Users OU also. I used the same user to connect to ldap on confluence and everything went fine.
Greatful if someone could help me.
Thaks

Thanks Nicolas for your reply
Removing the dots gives another error while restarting the service which is unable to start.
2016.09.13 15:46:00 INFO  web[org.sonar.INFO] Security realm: LDAP
2016.09.13 15:46:00 INFO  web[o.s.p.l.LdapSettingsManager] User mapping: LdapUserMapping{baseDn=cn=Users,dc=mydomain,dc=com, request=(&(objectClass=user)(sAMAccountName={0})), realNameAttribute=cn, emailAttribute=mail}
2016.09.13 15:46:01 INFO  web[o.s.p.l.LdapSettingsManager] Group mapping: LdapGroupMapping{baseDn=ou=Users,dc=mydomain,dc=com, idAttribute=sAMAccountName, requiredUserAttributes=[dn], request=(&(objectClass=mygroup)(member={0}))}
2016.09.13 15:46:01 DEBUG web[o.s.p.l.LdapContextFactory] Initializing LDAP context {java.naming.provider.url=ldap://myip:389, java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory, java.naming.security.principal=cn=someusername,ou=Users,o=mydomain, com.sun.jndi.ldap.connect.pool=true, java.naming.security.authentication=simple, java.naming.security.sasl.realm=mydomain.com, java.naming.referral=follow}
2016.09.13 15:46:02 INFO  web[o.s.p.l.LdapContextFactory] Test LDAP connection: FAIL
2016.09.13 15:46:02 ERROR web[o.a.c.c.C.[.[.[/]] Exception sending context initialized event to listener instance of class org.sonar.server.platform.PlatformServletContextListener
java.lang.IllegalStateException: Unable to open LDAP connection
        at org.sonar.plugins.ldap.LdapContextFactory.testConnection(LdapContextFactory.java:146) ~[na:na]
        at org.sonar.plugins.ldap.LdapRealm.init(LdapRealm.java:64) ~[na:na]
        at org.sonar.server.user.SecurityRealmFactory.start(SecurityRealmFactory.java:84) ~[sonar-server-6.0.jar:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_91]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_91]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_91]
        at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110) ~[picocontainer-2.15.jar:na]
        at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89) ~[picocontainer-2.15.jar:na]
        at org.sonar.core.platform.ComponentContainer$1.start(ComponentContainer.java:320) ~[sonar-core-6.0.jar:na]
        at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84) ~[picocontainer-2.15.jar:na]
        at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169) ~[picocontainer-2.15.jar:na]
        at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132) ~[picocontainer-2.15.jar:na]
        at org.picocontainer.behaviors.Stored.start(Stored.java:110) ~[picocontainer-2.15.jar:na]
        at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016) ~[picocontainer-2.15.jar:na]
        at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009) ~[picocontainer-2.15.jar:na]
        at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767) ~[picocontainer-2.15.jar:na]
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:141) ~[sonar-core-6.0.jar:na]
        at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:84) ~[sonar-server-6.0.jar:na]
        at org.sonar.server.platform.platformlevel.PlatformLevel4.start(PlatformLevel4.java:687) ~[sonar-server-6.0.jar:na]
        at org.sonar.server.platform.Platform.start(Platform.java:216) ~[sonar-server-6.0.jar:na]
        at org.sonar.server.platform.Platform.startLevel34Containers(Platform.java:190) ~[sonar-server-6.0.jar:na]
        at org.sonar.server.platform.Platform.doStart(Platform.java:113) ~[sonar-server-6.0.jar:na]
        at org.sonar.server.platform.Platform.doStart(Platform.java:99) ~[sonar-server-6.0.jar:na]
        at org.sonar.server.platform.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:44) ~[sonar-server-6.0.jar:na]
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) [tomcat-embed-core-8.0.32.jar:8.0.32]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) [tomcat-embed-core-8.0.32.jar:8.0.32]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [tomcat-embed-core-8.0.32.jar:8.0.32]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) [tomcat-embed-core-8.0.32.jar:8.0.32]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) [tomcat-embed-core-8.0.32.jar:8.0.32]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_91]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_91]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_91]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91]
Caused by: javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903C5, comment: AcceptSecurityContext error, data 52e, v2580]
        at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3135) ~[na:1.8.0_91]
        at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3081) ~[na:1.8.0_91]
        at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2883) ~[na:1.8.0_91]
        at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2797) ~[na:1.8.0_91]
        at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:319) ~[na:1.8.0_91]
        at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:192) ~[na:1.8.0_91]
        at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:210) ~[na:1.8.0_91]
        at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:153) ~[na:1.8.0_91]
        at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:83) ~[na:1.8.0_91]
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684) ~[na:1.8.0_91]
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313) ~[na:1.8.0_91]
        at javax.naming.InitialContext.init(InitialContext.java:244) ~[na:1.8.0_91]
        at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:154) ~[na:1.8.0_91]
        at org.sonar.plugins.ldap.LdapContextFactory.createInitialDirContext(LdapContextFactory.java:95) ~[na:na]
        at org.sonar.plugins.ldap.LdapContextFactory.createBindContext(LdapContextFactory.java:83) ~[na:na]
        at org.sonar.plugins.ldap.LdapContextFactory.testConnection(LdapContextFactory.java:142) ~[na:na]
        ... 33 common frames omitted
2016.09.13 15:46:02 ERROR web[o.a.c.c.StandardContext] One or more listeners failed to start. Full details will be found in the appropriate container log file
2016.09.13 15:46:02 ERROR web[o.a.c.c.StandardContext] Context [] startup failed due to previous errors
2016.09.13 15:46:02 WARN  web[o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Object.wait(Native Method)
 java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
 com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43)
2016.09.13 15:46:02 INFO  web[o.a.c.h.Http11NioProtocol] Starting ProtocolHandler ["http-nio-0.0.0.0-9000"]
2016.09.13 15:46:02 INFO  web[o.s.s.a.TomcatAccessLog] Web server is started
2016.09.13 15:46:02 INFO  web[o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000
2016.09.13 15:46:02 WARN  web[o.s.p.ProcessEntryPoint] Fail to start web
java.lang.IllegalStateException: Webapp did not start
        at org.sonar.server.app.EmbeddedTomcat.isUp(EmbeddedTomcat.java:84) ~[sonar-server-6.0.jar:na]
        at org.sonar.server.app.WebServer.isUp(WebServer.java:47) [sonar-server-6.0.jar:na]
        at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:105) ~[sonar-process-6.0.jar:na]
        at org.sonar.server.app.WebServer.main(WebServer.java:68) [sonar-server-6.0.jar:na]
2016.09.13 15:46:02 INFO  web[o.a.c.h.Http11NioProtocol] Pausing ProtocolHandler ["http-nio-0.0.0.0-9000"]
2016.09.13 15:46:03 INFO  web[o.a.c.h.Http11NioProtocol] Stopping ProtocolHandler ["http-nio-0.0.0.0-9000"]
2016.09.13 15:46:03 INFO  web[o.a.c.h.Http11NioProtocol] Destroying ProtocolHandler ["http-nio-0.0.0.0-9000"]
2016.09.13 15:46:03 INFO  web[o.s.s.a.TomcatAccessLog] Web server is stopped
2016.09.13 15:46:03 INFO  app[o.s.p.m.Monitor] Process[es] is stopping
2016.09.13 15:46:04 INFO   es[o.s.p.StopWatcher]  Stopping process
2016.09.13 15:46:04 INFO   es[o.elasticsearch.node]  [sonar-1473767147543] stopping ...
2016.09.13 15:46:04 INFO   es[o.elasticsearch.node]  [sonar-1473767147543] stopped
2016.09.13 15:46:04 INFO   es[o.elasticsearch.node]  [sonar-1473767147543] closing ...
2016.09.13 15:46:04 INFO   es[o.elasticsearch.node]  [sonar-1473767147543] closed
2016.09.13 15:46:04 INFO  app[o.s.p.m.Monitor] Process[es] is stopped
<-- Wrapper Stopped

telnet to the IP and port 389 works

I've created a new user with a simpler password (no special characters)
The error changed to the following:

Caused by: javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903C5, comment: AcceptSecurityContext error, data 52e, v2580]

A: changed the part

ldap.bindDn =cn=someusername,ou=Users,o=mydomain

to

ldap.bindDn =someusername@mydomain.com

and it worked

A: First issue
This is the real problem in your error:

In order to perform this operation a successful bind must be completed on the connection

As per LDAP Plugin documentation these are the properties that you should configure for SonarQube to bind to your server: ldap.bindDn and ldap.bindPassword .
But then, looking at your config:
ldap.bindDn.=cn=someusername,ou=Users,o=mydomain
ldap.bindPassword.=somepassword

See those trailing dots right there ? Removing them should let the bind operation work better.

Second issue
Your Active Directory is returning a detailed error:

[LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903C5, comment: AcceptSecurityContext error, data 52e, v2580]

error code 49 (data 52e) is the interesting part. A bit of googling on LDAP error codes brings you here for example:

49 - LDAP_INVALID_CREDENTIALS - Indicates that during a bind operation one of the following occurred: The client passed either an incorrect DN or password, or the password is incorrect because it has expired, intruder detection has locked the account, or another similar reason. See the data code for more information.

Bottom line: fix the credentials.


text:
Q: How to extract Corresponding td values for a row in a HTML Table I have a HTMl as shown below

            Screen Name

            Convinience Charges

            Minium

            Action

FirstScreen

11

32

              Edit

SeccondScreen

12

56

              Edit

how can i fetch the  value as FirstScreen , 11  , 32  , anchor id value (566) when clicked on its corresponding Edit Button
Similarly SeccondScreen , 12 , 56 ,   anchor id value (345) when clicked on its corresponding Edit Button
I have tried this way
$(document).on("click", ".editscreeen", function (e) {
        $(this).closest.find('
').each(function(){
          var value = $(this).find("p").html();

        });
});

http://jsfiddle.net/c9qrvrqx/2/
If needed i can add the attributes  for the p tag .
could anybody please help me

A: You need to remodel a little bit your script because you have errors inside like closest is a function so it needs to be like this closest(), then you don't add <> to a tr element inside jQuery, you need just tr etc...
Here is a working example http://jsfiddle.net/c9qrvrqx/3/
$(document).on("click", ".editscreeen", function (e) {
    e.preventDefault();
        $(this).closest('tr').find('td p').each(function(){
          var value = $(this).html();
            alert(value);
        });
});

Or to get all values in array just change the script like this http://jsfiddle.net/c9qrvrqx/7/
$(document).on("click", ".editscreeen", function (e) {
    e.preventDefault();
    var pValue = [];
        $(this).closest('tr').find('td p').each(function(){
          var value = $(this).html();
            pValue.push(value);
        });
    pValue.push('anchor id value ('+$(this).attr('id')+')' );

    alert(pValue); // Do what you need with the values
});

pValue will contain the array in this order
FirstScreen , 11 , 32 , anchor id value (566)  etc..

A: Fairly easy when using .map, which loop through the selected elements and create an array with the returned value
$(document).on("click", ".editscreeen", function (e) {
    var result = $(this).closest('tr').find('td:not(":last-child")').map(function(){ //Loop all the td except the last child
      return $(this).text(); //Get the text value
    }).get(); //Transform the jQuery array like object into an array

    result.push(this.id); //Add the current anchor id.
});

http://jsfiddle.net/c9qrvrqx/4/
To remove the white-space, you can use $.trim().

A: Please find the Changed Fiddle below
DEMO LINK
$(document).on("click", "#tablebody tr", function (e) {

    $(this).find('p').each(function(){
      var value = $(this).html();
    alert(value);
    });
});


text:
Q: Hibernate. Optimistic lock. Selects version even though it generates it I have an entity:
<class name="name.dargiri.model.Entity" table="ENTITY" optimistic-lock="version">
  <version name="version" column="ver" type="long" />
</class

If the Entity is saved no matter how many times, in the end of transaction Hibernate selects for the version of the object. Why? Hibernate generates this version when it stores the object, so it knows it. I found out that this method invokes this:
EntityVerifyVersionProcess#getCurrentVersion()

Hibernate generates this in logs:
Hibernate:
    /* update
        name.dargiri.model.Entity */ update
            ENTITY
        set
            ver=?,
            USERNAME=?,
            lucky_number=?
        where
            id=?
            and ver=?
Hibernate:
    /* get version name.dargiri.model.Entity */ select
        ver
    from
        ENTITY
    where
        id =?

I use MySQL and Session#save().

A: Hibernate performs an extra SQL statement to retrieve the version number after the update has been made because the version number is managed by the database. For more details, I suggest you take a look at this article which explains this very well.

A: Okay, so what I didn't write about and what appeared to be the problem is using LockMode.OPTIMISTIC:
session.get(Entity.class, 1L, LockMode.OPTIMISTIC);
It appeared that this is how this lock mode works - it checks at the end of the transaction whether no one changed the version of the object so far. And this happens not while flushing, because Hibernate will anyway do the check, but by the end of the transaction, which is, I think, additional option to be more careful about overwriting data.


text:
Q: FP precision error on converting XML -> Table & processing it In SQL Server 2008, I have the value "0.01" in an XML attribute. Using OPENXML, I shred the XML into a temp table. If the applicable column is of type real (single precision), it comes out as 0.01 in the table. Good. However, if the precision is float (double precision), it comes out as 0.00999999977648258. This makes no sense. Why is it doing this?
My next question is that regardless of how the value is represented in the temp table, when I run an aggregate function on it, it always comes back as 0.00999999977648258. This is causing validation errors: the procedure is reporting the input is too small (< 0.01), which is not true.
Any ideas why these rounding errors are happening and how to overcome them?
Already tried: make the column a varchar.
EDIT2:
Based on answers, I understand the problem is due to the fact that IEEE numbers cannot represent 0.01 exactly. Therefor my next question:

"WHERE {computed} < 0.01", why is that
  0.01 not also being rounded here? If it were, the equation would eval as
  expected (i.e. 0.00999999977648258 is
  not < 0.00999999977648258)

EDIT: Sample code shown
This code will produce the error. Change the indicated float to real & the error "disappears". At least so far as the temp table goes.
DECLARE @XMLText varchar(max)

SET @XMLText =
'<query prodType="1">
  <param type="1" lowMin="10" hiMax="300">
    <item low="18" hi="20" mode="1" weight="1" />
    <item low="220" hi="220" mode="0" weight="1" />
  </param>
  <param type="2" lowMin="4" hiMax="6">
    <item low="5" hi="5" mode="1" weight="1" />
    <item low="6" hi="6" mode="0" weight="0.01" />
  </param>
  <param type="3" lowMin="0" hiMax="300">
    <item low="34" hi="34" mode="1" weight="0.75" />
    <item low="40" hi="60" mode="1" weight="0.25" />
  </param>
</query>'

DECLARE @hxml int, @sp INT, @StartXCount int

EXEC sp_xml_preparedocument @hxml OUTPUT, @XMLText

IF @sp != 0 BEGIN
    SET @Result = '0'
    RETURN
END

DECLARE @t table (
    LowMin         real,
    HiMax          real,
    ParamTypeID    int,
    ParamWeight    float, -- real <<<
    Low            real,
    Hi             real,
    Mode           tinyint
)

INSERT INTO @t
SELECT      *
FROM        OPENXML (@hxml, '/query/param/item', 2)
WITH        (
                LowMin       real     '../@lowMin',
                HiMax        real     '../@hiMax',
                ParamTypeID  int      '../@type',
                ParamWeight  real     '@weight',
                Low          real     '@low',
                Hi           real     '@hi',
                Mode         tinyint  '@mode'
            )

SELECT * FROM @t

A: 0.01 can't be stored exactly in an IEEE type, since it's not representable with a fraction with a power of 2 in denominator.
However, what I can reproduce is the opposite of what you are saying:
SELECT  CAST(0.01 AS FLOAT) AS value
FOR XML PATH(''), TYPE

<value>1.000000000000000e-002</value>

SELECT  CAST(0.01 AS REAL) AS value
FOR XML PATH(''), TYPE

<value>9.9999998e-003</value>

Could you please post your exact query?
Update:
I get the same results with your code: 0,01 when ParamWeight is FLOAT, 0,00999999977648258 when it's REAL.
Update 2:
IEEE types are stored as a sign, mantissa and a significand. For a 32-bit value, mantissa is the binary logarithm of the greatest power of 2 (least than the value), and a significand is a 23-bit binary fraction (a number from 1 to 2, the leading 1 is not stored.).
In your case it's -7 for the mantissa (2^-7 = 1/128 = 0,0078125), and 1.01000111101011100001010 for the significand (= 1 + 2348810 / 8388608 = 1,2799999713897705078125).
The resulting number is a product of these numbers which is close to 0.01 but still not close enough to avoid errors in 15'th digit (which precision SQL Server considers important)

A: The error is caused because the computer CANNOT represent the value 0.01 in floating point both in single and double precision. This value is rounded to the nearest representable value both in float and in double. So in both cases it's not 0.01, but only displayed to you as 0.01 in the real case (I don't know how does the ToString algorithm for floating point work, so can't tell you why it is converted to 0.01 in one case and 0.00999999977648258 in another).
The only thing I can tell you for sure - in the real case it was rounded to a representable value ABOVE 0.01 and in the double case it was rounded to a representable value BELOW 0.01. Therefore validation failed in the double precision case.
To overcome this problem you can change your validation test to be "smaller than 0.01 - epsilon" for some very small epsilon.


text:
Q: git-bundle only some of the files in my repository I have a library that I wrote for my app but now want to use it in all apps my company is going to write. The app and library both live in a git repository (repository A) with history that I really would like to preserve. The library sits in it's own subfolder.
I also have a second repository (repository B) that contains some other shared code - this is used as a git-submodule in apps that we write.
I would like to take the libraries subfolder from repository A and place it into repository B without losing it's history.
I've looked at git-bundle but don't seem to be able to specify files, only branches.
I've also looked at copying the repository and removing the files I don't want (like this) but the libraries files started out with different names and in different folders so I'm just not sure how that would work.
Does anyone have any ideas of the best way that this could be done?

A: You're looking for git filter-branch. See this question and answer (be sure to note the additional section marked 'edit', too).

A: Note that, with Git 2.36 (Q2 2022, eleven years later), git bundle itself will support your use case: the bundle file format gets extended to allow a partial bundle, filtered by similar criteria you would give when making a partial/lazy clone.
See commit 86fdd94, commit 4f39eb0, commit f18b512, commit c4ea513, commit 105c6f1, commit f0d2f84, commit 3e0370a, commit 09d4a79, commit 7940941, commit ffaa137, commit 4a4c3f9, commit 1f52cdf (09 Mar 2022) by Derrick Stolee (derrickstolee).
See commit 4f33a63 (09 Mar 2022) by Ævar Arnfjörð Bjarmason (avar).
(Merged by Junio C Hamano -- gitster -- in commit 7391ecd, 21 Mar 2022)

bundle: create filtered bundles
Signed-off-by: Derrick Stolee

A previous change allowed Git to parse bundles with the 'filter' capability.
Now, teach Git to create bundles with this option.
Some rearranging of code is required to get the option parsing in the correct spot.
There are now two reasons why we might need capabilities (a new hash algorithm or an object filter) so that is pulled out into a place where we can check both at the same time.
The --filter option is parsed as part of setup_revisions(), but it expected the --objects flag, too.
That flag is somewhat implied by 'git bundle'(man) because it creates a pack-file walking objects, but there is also a walk that walks the revision range expecting only commits.
Make this parsing work by setting 'revs.tree_objects' and 'revs.blob_objects' before the call to setup_revisions().

And, still with Git 2.36 (Q2 2022):
See commit 5cb2827 (28 Mar 2022) by Ævar Arnfjörð Bjarmason (avar).
See commit 8ba221e, commit 017303e, commit 831ee25, commit 80f6de4, commit cc91044 (22 Mar 2022) by Derrick Stolee (derrickstolee).
(Merged by Junio C Hamano -- gitster -- in commit 3928e90, 04 Apr 2022)

bundle: move capabilities to end of 'verify'
Signed-off-by: Derrick Stolee

The 'filter' capability was added in 105c6f1 ("bundle: parse filter capability", 2022-03-09, Git v2.36.0-rc0 -- merge listed in batch #13), but was added in a strange place in the 'git bundle verify'(man) output.
The tests for this show output like the following:
The bundle contains these 2 refs:
<COMMIT1> <REF1>
<COMMIT2> <REF2>
The bundle uses this filter: blob:none
The bundle records a complete history.

This looks very odd if we have a thin bundle that contains boundary commits instead of a complete history:
The bundle contains these 2 refs:
<COMMIT1> <REF1>
<COMMIT2> <REF2>
The bundle uses this filter: blob:none
The bundle requires these 2 refs:
<COMMIT3>
<COMMIT4>

This separation between tip refs and boundary refs is unfortunate.
Move the filter capability output to the end of the output.
Update the documentation to match.

git bundle now includes in its man page:

Then, 'git bundle' prints a list of missing commits, if any.
Finally, information about additional capabilities, such as "object
filter", is printed.
The exit code is zero for success, but will
be nonzero if the bundle file is invalid.


text:
Q: css/html - Opaque layout I'm creating my portfolio, I drew some layout but now I've problem with code. As You can see on the image.
Visualisation:

*

*the black area will be a photo

*the white area will be a normal bacround color / maybe also image i'll see.
Full width scalable
I want to use background image  that will be scalable and the problem is that I've no idea how to resolve problem with the links (grey field). Because I want link gaps to start at the end of the screen and end before the white background (at the boarder).

I was thinking about the image maps but it is not a good solution... Maybe You've got an idea.
I've found similiar problem (about positioning link gaps according to background position - scaleable) - Link is here - stackoverflow
Now I have the same problem like in the question above - it is working if I won't use proportional background scaling.

A: It's a tricky layout.. BUT! (I assume full-width scaleable and fixed aspect ratio)
Since you know the angle of the intersection of the areas will be the same. If you put your links at known y-axis percentages from top corner you will have a fixed precentage in the x-axis.
Then if you choose to go full browser width you could use 'position: fixed'(CSS) for the links together with scaling and top/bottom/left/right(CSS).
Otherwise i believe you could use relative positioning with the same principle.
Hope that will get you on your way!