text:
Q: Delete row in tkinter treeview with identified "cell" I made a treeview with tkitner and I made it si that you can identify a "cell" inside the treeview with a button click, I used tree.identify_region(event.x, event.y) == ' cell'.
The "cell" is identified with one button click (i have used bind function <Button-1>). I want to make a function that will delete the row (selected row), but the function does not work. It does not show any error.
I think that the problem is because even if the row is selected, its also a "cell" thats selected.
I posted a full code (even if its long) because I think that you need to see what I have done to make this
This is the code:
from tkinter import *
from tkinter import ttk
import math
from tkinter import messagebox

def edit(event):

    def double(event): # funkcija koja kreira celiju kada se klikne dupli klik
        try:
            if tree.identify_region(event.x, event.y) == 'cell':
                # the user clicked on a cell

                def ok(event):
                    """Change item value."""
                    tree.set(item, column, entry.get())
                    entry.destroy()

                column = tree.identify_column(event.x)  # identify column
                item = tree.identify_row(event.y)  # identify item
                x, y, width, height = tree.bbox(item, column)
                value = tree.set(item, column)

            elif tree.identify_region(event.x, event.y) == 'heading':
                # the user clicked on a heading

                def ok(event):
                    """Change heading text."""
                    tree.heading(column, text=entry.get())
                    entry.destroy()

                column = tree.identify_column(event.x) # identify column
                # tree.bbox work only with items so we have to get the bbox of the heading differently
                x, y, width, _ = tree.bbox(tree.get_children('')[0], column) # get x and width (same as the one of any cell in the column)
                # get vertical coordinates (y1, y2)
                y2 = y
                # get bottom coordinate
                while tree.identify_region(event.x, y2) != 'heading':
                    y2 -= 1
                # get top coordinate
                y1 = y2
                while tree.identify_region(event.x, y1) == 'heading':
                    y1 -= 1
                height = y2 - y1
                y = y1
                value = tree.heading(column, 'text')

            elif tree.identify_region(event.x, event.y) == 'nothing':
                column = tree.identify_column(event.x) # identify column
                # check whether we are below the last row:
                x, y, width, height = tree.bbox(tree.get_children('')[-1], column)
                if event.y > y:

                    def ok(event):
                        """Change item value."""
                        # create item
                        item = tree.insert("", "end", values=("", ""))
                        tree.set(item, column, entry.get())
                        entry.destroy()

                    y += height
                    value = ""
                else:
                    return
            else:
                return

            # display the Entry
            entry = ttk.Entry(tree)  # create edition entry
            entry.place(x=x, y=y, width=width, height=height, anchor='nw')  # display entry on top of cell
            entry.insert(0, value)  # put former value in entry
            entry.bind('<FocusOut>', ok)  #validate when you click on other cell
            entry.focus_set()

        except IndexError:

            Error=messagebox.showinfo("Error!","You have 0 rows. Please add a new row.")
            pass

    tree.bind('<Button-1>', double) #kreiranje celije za unos i novi red sa duplim klikom

    def deleterow(event):   # funkcija za brisanje izabranog reda sa delete i backspace dugmicima
        try:
            SelectedRow= tree.selection()[0]
            tree.delete(SelectedRow)

        except IndexError:
            Error=messagebox.showinfo("Error!","Please seleect the project that you want to delete")
            sys.exit() #za resavalje greske
            pass

        except ValueError:
            Error=messagebox.showinfo("Error!","Please seleect the project that you want to delete")
            sys.exit() #za resavalje greske
            pass

    tree.bind("<Delete>", deleterow)
    tree.bind("<BackSpace>", deleterow)

myApp = Tk()
myApp.title(" Program ")
myApp.geometry("1900x1000")

tree = ttk.Treeview(myApp, height=20)
tree['show'] = 'headings'

sb = ttk.Scrollbar(myApp, orient="vertical", command=tree.yview)
sb.grid(row=1,column=12,sticky="NS")

tree.configure(yscrollcommand=sb.set)

tree["columns"]=("1","2")

tree.column("1", width=50)
tree.column("2", width=50)

tree.heading("1", text="Project Name")
tree.heading("2", text="Size [m2]")

item = tree.insert("", "end", values=("",))
tree.item(item, tags=item)
tree.bind('<1>', edit)

tree.grid(row=1 ,column=0,pady=5)

myApp.mainloop()

If I identify the "cell" with <Double-Button-1>, then it works because with 1 click I just identify the row, not the cell.
Is there any way you do this if I use <Button-1> for cell identification?

A: This was a bit difficult as I have little experience with Treeview. I tried to isolate different functions and I also removed a lot of code that was unnecessary for basic understanding. I think I got a working concept but I have structured my code quite differently from yours. Have a look and see what you think:
from tkinter import *
from tkinter import ttk

def cell(event):
    '''Identify cell from mouse position'''
    row, col = tree.identify_row(event.y), tree.identify_column(event.x)
    pos = tree.bbox(row, col)       # Calculate positon of entry
    return row, col, pos

def single(event=None):
    '''Single click to select row and column'''
    global row, col, pos
    row, col, pos = cell(event)
    print('Select', row, col)

def ok(event=None):
    '''Validate entry as at loses focus'''
    tree.set(*item, typed.get())    # Set tree cell text
    entry.place_forget()            # Remove entry without deleting it

def double(event=None):
    '''Double click to edit cell'''
    global row, col, pos, item
    row, col, pos = cell(event)
    print('Edit', row, col)
    item = row, col                 # Remember which item you are editing
    typed.set(tree.set(row, col))   # Set entry text
    x, y, w, h = pos                # Place entry on tree
    entry.place(x=x, y=y, width=w, height=h, anchor='nw')
    entry.focus_set()               # Set focus in entry

def deleterow(event):
    '''Delete selected row'''
    print('delete', len(tree.selection()))
    if len(tree.selection()) != 0:
        row = tree.selection()[0]
    try:
        print('deleterow', row)
        tree.delete(row)
    except:
        print('no row selected')

myApp = Tk()
myApp.title(" Program ")
myApp.geometry("600x600+800+50")

tree = ttk.Treeview(myApp, height=20)
tree['show'] = 'headings'
sb = ttk.Scrollbar(myApp, orient="vertical", command=tree.yview)
sb.grid(row=1,column=12,sticky="NS")
tree.configure(yscrollcommand=sb.set)
tree["columns"]=("1","2")
tree.column("1", width=150)
tree.column("2", width=150)
tree.grid(row=1 ,column=0,pady=5)

tree.heading("1", text="Project Name")
tree.heading("2", text="Size [m2]")

item = tree.insert("", "end", values=("Project Alice","500 GB"))
tree.item(item, tags=item)

# Mouse & keyboard bindings
tree.bind('<1>', single)
tree.bind('<Double-Button-1>', double)
tree.bind("<Delete>", deleterow)

# Create entry in global scope
typed = StringVar()
entry = ttk.Entry(tree, textvariable=typed)
entry.bind('<FocusOut>', ok)

myApp.mainloop()

I have kept console printouts in the code so it's easier to see what is going on. I use globals to keep track of important variables. My choices of variable names could have been better...
Anyway, with this code I can select any row/column with singele or double click. Delete row seems to work just fine. I have not any function for adding new rows but that should not be difficult.


text:
Q: Botão contador com Update Estou com problemas em conseguir fazer um botão em javascript realizar um update sem dar refresh na página, no momento ele não está inserindo no banco e está fazendo refresh hehehe
na index.php
<form>
    <button data-id='$futid' class='botao-olho' style='background-color: red;color:#fff'><i class="far fa-thumbs-up"></i>Sim</button>
</form>
<script type="text/javascript">
    //pega-se o botão desejado e arzena na variável

    $(".botao-olho").on("click", function(){
        var $this = $(this);
        $.ajax({
            url: "update_intencao.php",
            data: {id: $this.data("id")},

        });
    });
</script>

Update.php
<?php

 include("conexao.php");

 $id = $_POST['id']
 $sql3 = "UPDATE fifa19futdados set intencoes = intencoes + 1 where Futbin_ID = $id";

 mysqli_query($conexao,$sql3);

 ?>

Se não for pedir muito, eu gostaria também que depos da ação ele sumisse o botão e aparecesse uma mensagem, sem refresh.
Obrigado!

A: Sem muita modificação no seu código e nem verificar o retorno do update, uma opção seria:
<script type="text/javascript">
$(".botao-olho").on("click", function(){
    var $this = $(this);
    $.ajax({
        url: "update_intencao.php",
        data: {id: $this.data("id")},
        success: function(response) {
            $this.remove();
        }

    });
});

Porém é aconselhável que você adote um protocolo de comunicação para tratar erros como JSON. Assim o seu uodate_intencao.php pode devolver respostas estruturadas ao javascript.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to send and show messages in AngularJS and Symfony2 project I'm trying to capture errors inside Symfony2 controller as this code shows:
public function indexAction($parent_id = 0) {
        $response['message'] = "";
        $breadcrumbs = array();

        $response['entities'] = array();

        if (!$entity) {
            throw $this->createNotFoundException('No se encontraron grupos de detalles');
        }

        ...

        return new JsonResponse($response);
    }

}

When !$entity is TRUE then as you see I generate a NotFoundException but I need to show a message to users in my AngularJS template. This is the code for the template:

Grupo de Meta-Detalles

Listar

Grupo de Meta-Detalles Listado.

            #
             Nombre
             Padre
             Descripción

            {% verbatim %}{{ item.id }}{% endverbatim %}
            {% verbatim %}{{ item.name }}{% endverbatim %}
            {% verbatim %}{{ item.parent }}{% endverbatim %}
            {% verbatim %}{{ item.description }}{% endverbatim %}

How I can achieve this? I mean if there is nothing to show (!entity) then show a message to users, any help or advice?

A: I have no AngularJS installed, so this is checked on JsFiddle :)
public function indexAction($parent_id = 0) {
    $response['message'] = "";
    $breadcrumbs = array();

    $response['entities'] = array();

    if (!$entity) {
        // Exception is replaced by message to your client-side script
        $response['message'] = 'No se encontraron grupos de detalles';
    }

    return new JsonResponse($response);
}

Make call to your symfony method (GET or POST):
$http.get("/api/index/?parent_id=666", {})
    .success(function(data, status, headers, config){
        // Would be nice to check status/message and to hide if no error
        $scope.ajaxResponse = data.message;
        // TODO: Handle your entities
    }).error(function(data, status, headers, config){
        $scope.ajaxResponse = status;
    });

In your view page (HTML) insert some Angular JS variable

{{ajaxResponse}}

       ...


text:
Q: MooTools Classes and Knockout.js I was trying to keep my code a bit cleaner by using the OOP patterns that MooTools provides in combination with Knockout.js
I can't seem to get it to work as Knockout returns some function (the property function, meh?) when it data binds the values. If the values are retrieved with javascript however, it works as exprected. I made a quick jsFiddle so you can test it out:
http://jsfiddle.net/tixz/JK2jt/
Thanks in advance!

A: In your current structure, the observables are created on the prototype of your class.  Knockout does not intend on them being on the prototype (they can't be shared as they keep private state), and an internal function ko.isObservable fails, because of it.   This causes the unwrapping code in KO does not realize that it needs to retrieve the underlying value for your observables.
You would have to write it like:
var ViewModel = new Class({
    initialize: function(secondVal){
        this.someProp = ko.observable('Here is my value');
        this.anotherProp = ko.observable(secondVal);
    }
});

http://jsfiddle.net/rniemeyer/JK2jt/9/


text:
Q: How to pass a value of form field filled using jquery autocomplete selection to a new page I am using Jquery Autocomplete. It all works well. All i need help with is that when it fills aid in one of the text fields on selection of particular name i want it to send that aid to profile.php?aid= so that if someone selects persons name, that person can view his/her profile.
profile.php is using $_GET['aid'] to get url parameter.
Code for your reference:

Here aid goes into a text field with id="aid" on selection of name.

Enter your friend's name

      Enter Name:
   <input id="frndsrch" name="srch">

Further Information

 <textarea name="info" cols="50" rows="10" disabled="disabled" readonly="readonly" id="project-desc">As soon as you select a name from above, further information will be displayed here.
   </textarea>

  <input type="text" name"aid" id="aid"/>

Now how and where do i add
    <a href="profile.php?aid=<?php echo $_GET['aid']; ?>View Profile

so that value from text field aid is passed to $aid.

A: First create form with action PHP_SELF (so when you submit the form, it reloads the page) and add a submit button with the name='submit' to post the form and work with it later on in PHP.
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">

Enter your friend's name

    Enter Name:
    <input id="frndsrch" name="srch">

Further Information

 <textarea name="info" cols="50" rows="10" disabled="disabled" readonly="readonly" id="project-desc">As soon as you select a name from above, further information will be displayed here.
    </textarea>

    <input type="text" name"aid" id="aid"/>

<input type="submit" id="submit" name="submit"/>

Now create the PHP code to GET the aid value and echo it in the ANCHOR tag url attribute:
<?php
if (isset$_GET['submit']) {
     $aid = $_GET['aid'];
     echo "View Profile";

}
?>


text:
Q: Where exactly do I put the source code header? My professor wants our code to include a source code header and I don't know exactly where to put it.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon May 22 21:31:16 2017

@author: noraasrar
"""
# Code starts here

The source code header looks like this:
###########################################################
#  Computer Project #5
#
#  Algorithm
#    prompt for an integer
#    input an integer
#    loop while not end-of-data
#       call function to count number of digits in integer
#       output the number of digits
#       prompt for an integer
#       input an integer
#    display closing message
###########################################################

A: The only real "restriction" to where you could put that is beneath the first two lines, the shebang and the line declaring the encoding. The first line helps your OS determine how to execute the file, and the second tells the Python executable what file encoding to use when it reads the script.
Since the "source code header" is just a comment block, this'll probably work:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon May 22 21:31:16 2017

@author: noraasrar
"""
###########################################################
#  Computer Project #5
#
#  Algorithm
#    prompt for an integer
#    input an integer
#    loop while not end-of-data
#       call function to count number of digits in integer
#       output the number of digits
#       prompt for an integer
#       input an integer
#    display closing message
###########################################################
# Code starts here


text:
Q: Vaadin 21 Flow + Spring Security OAuth2: Couldn't find route for 'oauth2/authorization/google' I am trying to implement Google Sign-In in Vaadin 21 application + Spring Security using available tutorial for Vaadin 14.
Login view:
@Route("login")
@PageTitle("Login")
@PermitAll
public class LoginView extends VerticalLayout {

    private static final String URL = "/oauth2/authorization/google";

    public LoginView() {
        addClassName("login-view");
        setSizeFull();

        setJustifyContentMode(JustifyContentMode.CENTER);
        setAlignItems(Alignment.CENTER);

        Anchor googleLoginButton = new Anchor(URL, "Login with Google");
        add(new H1("Test Application"), googleLoginButton);
    }
}

Security configuration:
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends VaadinWebSecurityConfigurerAdapter {

    private static final String LOGOUT_URL = "/logout";
    private static final String LOGOUT_SUCCESS_URL = "/";
    private static final String LOGIN_URL = "/login";

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        //super.configure(http);

        http.authorizeRequests()
                .requestMatchers(SecurityUtils::isFrameworkInternalRequest).permitAll()
                                 .and().authorizeRequests().anyRequest().authenticated()
                .and().csrf().disable().
                logout().logoutUrl(LOGOUT_URL).logoutSuccessUrl(LOGOUT_SUCCESS_URL)
                .and().oauth2Login().loginPage(LOGIN_URL).permitAll();

        //setLoginView(http, LoginView.class);
    }

    @Override
    public void configure(WebSecurity web) throws Exception {
        super.configure(web);
        web.ignoring().antMatchers(
                "/VAADIN/**",
                "/favicon.ico",
                "/robots.txt",
                "/manifest.webmanifest",
                "/sw.js",
                "/offline.html",
                "/icons/**",
                "/images/**",
                "/img/**",
                "/frontend/**",
                "/styles/**",
                "/h2-console/**",
                "frontend-es5/**",
                "frontend-es6/**");
    }
}

After clinking on 'Login with Google' link, I am getting this exception:
com.vaadin.flow.router.NotFoundException: Couldn't find route for 'oauth2/authorization/google'
    at com.vaadin.flow.component.internal.JavaScriptBootstrapUI.handleErrorNavigation(JavaScriptBootstrapUI.java:379) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.component.internal.JavaScriptBootstrapUI.renderViewForRoute(JavaScriptBootstrapUI.java:288) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.component.internal.JavaScriptBootstrapUI.lambda$connectClient$e368b2b7$1(JavaScriptBootstrapUI.java:141) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.component.internal.JavaScriptBootstrapUI.connectClient(JavaScriptBootstrapUI.java:149) ~[flow-server-8.0.4.jar:8.0.4]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
    at com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.invokeMethod(PublishedServerEventHandlerRpcHandler.java:207) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.invokeMethod(PublishedServerEventHandlerRpcHandler.java:184) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.invokeMethod(PublishedServerEventHandlerRpcHandler.java:137) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.handleNode(PublishedServerEventHandlerRpcHandler.java:125) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.server.communication.rpc.AbstractRpcInvocationHandler.handle(AbstractRpcInvocationHandler.java:66) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.server.communication.ServerRpcHandler.handleInvocationData(ServerRpcHandler.java:438) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.server.communication.ServerRpcHandler.lambda$handleInvocations$1(ServerRpcHandler.java:419) ~[flow-server-8.0.4.jar:8.0.4]
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1507) ~[na:na]
    at com.vaadin.flow.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:419) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:320) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:115) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1545) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:302) ~[flow-server-8.0.4.jar:8.0.4]
    at com.vaadin.flow.spring.SpringServlet.service(SpringServlet.java:109) ~[vaadin-spring-18.0.0.jar:na]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:750) ~[javax.servlet-api-4.0.1.jar:4.0.1]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:711) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:353) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:313) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.springframework.web.servlet.mvc.ServletForwardingController.handleRequestInternal(ServletForwardingController.java:141) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:177) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:51) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1064) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:665) ~[javax.servlet-api-4.0.1.jar:4.0.1]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:750) ~[javax.servlet-api-4.0.1.jar:4.0.1]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:327) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:121) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:115) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:105) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:218) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:212) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestRedirectFilter.doFilterInternal(OAuth2AuthorizationRequestRedirectFilter.java:178) ~[spring-security-oauth2-client-5.5.2.jar:5.5.2]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:110) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:211) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183) ~[spring-security-web-5.5.2.jar:5.5.2]
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) ~[spring-web-5.3.9.jar:5.3.9]
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) ~[spring-web-5.3.9.jar:5.3.9]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.9.jar:5.3.9]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.9.jar:5.3.9]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.9.jar:5.3.9]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1726) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
    at java.base/java.lang.Thread.run(Thread.java:830) ~[na:na]

I am not getting this exception in Vaadin 14 app.
Does anyone can tell me why I am getting it and how to solve it?
[UPDATED]
Adding Client Registration configuration set in application.properties:
# Oauth2 Google
spring.security.oauth2.client.registration.google.client-id=<client id>
spring.security.oauth2.client.registration.google.client-secret=<client secret>

A: This is the solution to the problem.
https://github.com/vaadin/vaadin-oauth-example/issues/6


text:
Q: Risks of using a laptop on battery after battery replace warning I am using a Dell Inspiron 5010 (Windows 7 Home Edition), which is 44 months old. About 2 months back, the laptop gave me a battery replacement warning. The LED which turned white when charging, instead started blinking orange. I went to the battery settings and configured the settings to ignore the battery warning. However, recently the battery has stopped getting charged as well and there are frequent warnings from the taskbar about battery issues.
My question is, what are the hazards of continuing to use the laptop on this battery?
Given the age of the laptop, I am considering getting a newer one but cannot afford one right now due to financial constraints (maybe won't be able to buy a new one for another 6 months or so). So I am curious to know how harmful it can be to continue with the laptop in its current state and whether I should spend to get a new battery in the interim.

A: The risk is, the battery backup will be less time than before. The Battery may suddenly fail. Nothing beyond this will happen. Its good to have a new battery on hands. If the old battery fails, you can replace with the new one


text:
Q: Behavior of Regex in javascript I am new to javascript and have not much idea about regular expressions. Please help me in understanding the following code.
var r = new RegExp("^.*?https://www\\.facebook\\.com/servlet/SignOn.*$","i");
var content = "https://www.facebook.com/servlet/SignOn?msg=You+are+not+authorized+to+vie…r+level+of+authority.&cm_sp=TopNav-_-servlet-_-MMM&goto=MembersMainMenu%3F";
console.log(content.search(r));// It gives me 0

But when I change the regex to
var r = new RegExp("^.*?https://www\\.facebook\\.com/servlet/SignOn?msg=.*$","i");
console.log(content.search(r));// It gives me -1 , why??

A: n? means n is optional you need n\?


text:
Q: Determine if SaveAs FileFormat is PDF I want to make changes to an Excel worksheet before it is saved to PDF and undo those changes after the copy has been created. I thought of using the Workbook_BeforeSave event to implement the changes and the Workbook_AfterSave event to return the worksheet to its original state.
The point at which I got stuck is when I want to determine the output format for the SaveAs instruction. It doesn't seem to be available in the Workbook_BeforeSave event, and I know of no event that I might capture the SaveAs dialog with unless I force the user to use a particular instance of this dialog.
I would like the user to choose SaveAs from Excel's UI and take action if he chose to save as PDF.

A: You can determine the file path and extension by controlling the msoFileDialogSaveAs like this:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

    Dim intChoice As Integer
    Dim strPath As String

    'make the file dialog visible to the user
    intChoice = Application.FileDialog(msoFileDialogSaveAs).Show

    'determine what choice the user made
    If intChoice <> 0 Then
        'get the file path selected by the user
        strPath = _
        Application.FileDialog(msoFileDialogSaveAs).SelectedItems(1)
        'displays the result in a message box
        Call MsgBox(strPath, vbInformation, "Save Path")
    End If

    SaveAsUI = False
    Cancel = True

End Sub

After you have the full path Cancel = True will stop the SaveAs action so you can choose to save or not.
Edit: You determine if the user pressed Save button or SaveAs with SaveAsUI. If Save pressed then SaveAsUI = False if SaveAs then SaveAsUI = True
Edit 2:
This is an example of how I would implement the above:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

    'cancel all default actions by excel application
    Cancel = True

    'if save was selected instead of SaveAs
    If (SaveAsUI = False) Then
        Cancel = False

    'if SaveAs was selected
    ElseIf (SaveAsUI = True) Then

        SaveAsUI = False
        Dim intChoice As Integer
        Dim strPath As String

        'make the file dialog visible to the user
        intChoice = Application.FileDialog(msoFileDialogSaveAs).Show

        'determine what choice the user made
        If intChoice <> 0 Then
            'get the file path selected by the user
            strPath = Application.FileDialog(msoFileDialogSaveAs).SelectedItems(1)

            'get file extention
            fileExt = Right(strPath, Len(strPath) - InStr(strPath, ".") + 1)

            'if pdf is the chosen format
            If (InStr(strPath, "PDF") > 0) Then

                'actions with pdf format
                Call MsgBox(strPath, vbInformation, "Save Path")
            Else

                With ActiveWorkbook
                    'on error resume next in case of extention macro free prompt no is selected
                    'see example by removing on error resume next and saving extention ".xlsx"
                    On Error Resume Next
                    .SaveAs strPath
                    On Error GoTo 0
                End With

            End If
        End If

    End If
End Sub


text:
Q: Check if visitor of my website likes a facebook page I am in the process of making a band website. I have a download of a song but I want it only to be available to the user if they have liked the bands Facebook page. I am aware there are similar questions to this already on here. I have tried some of them and they don't work, also none of them are very clear. Thank you for your help.

A: There are more than enough results which answer your question, for example Create Like-Gate for page
The most simple way to create this is using a Page Tab app (https://developers.facebook.com/docs/appsonfacebook/pagetabs/) and parsing the signed_request (https://developers.facebook.com/docs/reference/login/signed-request/) Facebook is sending when the page Tab is accessed.
The page object within the signed_request contains a field called liked which indicates whether the actual user liked the Page or not.


text:
Q: static landing page leading to author specific pages w/ "live" content My site has a static landing page with buttons to go to Cait's content or Shannons's content. Each author's page will feature their own posts, as well as a section with their social media streams. It is vital that these two author's content is kept separate.
Currently, I'm using conditional tags in the header to take care of this but I've ended up with nothing but blank author pages. Any ideas how I can rectify?
header.php-
<!DOCTYPE html>

    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <meta name="generator" content="Wordpress <?php bloginfo('version'); ?>" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
    <link rel="pingback" href="<?php bloginfo('pingback url'); ?>" />
    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" />
    <link rel="shortcut icon" href="<?php bloginfo('stylesheet_directory'); ?>/favicon.ico" />
    <?php wp_head(); ?>

outfit of the day

vlog

features

diy

contact

            <?php
                if (is_author(cait barker)) {
                echo do_shortcode("[ix_show_latest_yt ytid='caitbarker' width='280' height='170' autoplay='off' count_of_videos='1']");
                }
                if (is_author(shannon barker)) {
                echo do_shortcode("[ix_show_latest_yt ytid='shannonbarkerr' width='280' height='170' autoplay='off' count_of_videos='1']");
                }
            ?>

vlog

            <?php
                if (is_author(cait barker)) {
                $new_query = new WP_Query( 'cat=your_category_id&showposts=2' );
                if( $new_query->have_posts() ): while( $new_query->have_posts ): $new_query->the_post();

                the_post_thumbnail();

                endwhile;
                endif;
                wp_reset_query();
                ]
                if (is_author(shannon barker)) {
                $new_query = new WP_Query( 'cat=your_category_id&showposts=10' );
                if( $new_query->have_posts() ): while( $new_query->have_posts ): $new_query->the_post();

                the_post_thumbnail();

                endwhile;
                endif;
                wp_reset_query();
                ]
            ?>

outfit of the day

            <?php
                if (is_author(cait barker)) {
                echo do_shortcode("[instapress userid='caitbarkerr' piccount='6' size='73px']");
                ]
                if (is_author(shannon barker)) {
                echo do_shortcode("[instapress userid='shannonbarkerr' piccount='6' size='73px']");
                ]
            ?>

instagram

index.php-
<?php echo get_header();;?>
<?php
    if (is_author(cait barker)) {
    echo get_sidebar('cait');;
    }
    if (is_author(shannon barker)) {
    echo get_sidebar('shannon');;
    }
?>

        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

            <?php echo ravs_get_custom_image( get_post_thumbnail_id () ); ?>

<?php the_title() ;?>

                <?php the_excerpt('read more...'); ?>
                <?php endwhile; else: ?>

Sorry, no posts to list

                <?php endif; ?>

>> Posted on <?php the_date('M-d-y'); ?> >> <?php the_tags('tags: ', ', ', '
'); ?>

<?php get_footer(); ?>

A: You don't declare two post index pages, not any way that I am aware of anyway. And if there is a way, I still think what follows is the better solution, given your other conditions.
I guess you could hook to template_redirect and load different templates based on the author but the neater solution, and the one I'd recommend, would be to create a new post type for each author. Each type, and hence each author, would have its own index page and you could use the built in templating system to format the pages.
The two authors could share tags and categories, you could create new taxonomies for each author and keep those separated, or do both-- share some and keep others distinct.
You could also create sidebars specific to the post type, and hence specific to the authors.
I think that covers the issues you mentioned.

A: As i see your code in header.php and index.php looking messy (because of many if conditions).
If i'm understanding your problem then i do it like this

*

*create separate author.php for both authors their name like author-cait.php and author-shannons.php

*Give link like http://www.yousite.com/author/cait/ to button on static landing page.When user click on this,it takes him to author's specific author.php if exist

*create custom header.php for both authors name like header-cait.php and header-shannons.php

*create custom sidebar.php for both authors name like sidebar-cait.php
and sidebar-shannons.php

*complete your code in author specific author.php for example author-cait.php contain only cait's conditon,header and sidebar.

It makes your code looking beatiful,manageable, save from overloding of if conditions.


text:
Q: How to use Reactjs Datepicker when not using Webpack/Node? I am trying to build a reactjs page inside a VisaulForce Page(Salesforce) which means I can't easily setup webpack and all those great tools.
I been using babel-standalone which has helped alot but now I ran into the problem with trying to get a datepicker to work.
I have these scripts
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.5.4/react.min.js"> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.5.4/react-dom.min.js"> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.24.0/babel.min.js"> </script

Then all my code is in between
 <script type="text/babel" data-presets="es2017,react,stage-0" data-plugins="transform-decorators-legacy"> </script>

I tried to use this datepicker plugin but I get the following errors
Uncaught TypeError: (0 , _reactOnclickoutside2.default) is not a function
    at Object.module.exports (react-datepicker.js:1003)
    at __webpack_require__ (react-datepicker.js:30)
    at Object.module.exports (react-datepicker.js:573)
    at __webpack_require__ (react-datepicker.js:30)
    at Object.defineProperty.value (react-datepicker.js:65)
    at __webpack_require__ (react-datepicker.js:30)
    at Object.defineProperty.value (react-datepicker.js:50)
    at react-datepicker.js:53
    at webpackUniversalModuleDefinition (react-datepicker.js:9)
    at react-datepicker.js:10

and
Datepicker is undefined.

A: The code in your question looks ok, but you have not shown how you are referencing the DatePicker plugin from react-datepicker;
It is NOT enough to reference
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-datepicker/2.8.0/react-datepicker.js"></script>

You must also reference the dependencies of this library; classnames, date-fns, prop-types, react-onclickoutside, react-popper
Then write a console.log(window) to check if the window.DatePicker object has loaded properly, and you can continue from there.


text:
Q: Android: How to Encrypt and Decrypt a resource file and use in App I need to store resource files(text doc,imgaes,music etc) in my app in encrypted format and in runtime i need to decrypt the files and use it. Thanks in advance.

A:
Then how can i achieve this?

If you do not want the user to have access to the data, do not store it on the user's phone.
A sufficiently interested user can access anything on their device. This would include your code along with your resources. Any encryption algorithm and key that you use will be in your code; finding that and using that to decrypt your resources is not especially difficult.


text:
Q: Requests are making it to my app server, but not into node.js -- why? I detailed in this question on StackOverflow how some random requests are not making it from the client to my Node.js app server, resulting in a gateway timeout. In summary, identical requests are, at random, not even making it far enough to trigger a console.log() in my first line of express middleware.
I need to narrow down the problem, though, to find out WHERE the traffic is being lost and it was suggested that I try a packet sniffer on my app servers. Here's my setup:

*

*2x Load Balancers (m1.larges)

*2x node.js servers (also m1.large)

Here's what's interesting/unusual: the node.js servers started as PHP servers with an Apache stack and continue to serve PHP files for my domain (streamified.me). However, I use a little httpd.conf magic on the app servers so that requests to api.streamified.me get routed over port 8888 to the node.js server:
 RewriteCond %{HTTP_HOST} ^api.streamified.me
 RewriteRule ^(.*) http://localhost:8888$1 [P]

So, the request hits the load balancer => goes to an app server => gets routed to port 8888 if it's intended for the API => gets handled by node.js
So, in the same httpd.conf file, I turned on RewriteLogLevel 5 and then created a simple PHP+CURL script on my localhost to hit my api.streamified.me with a random URL (which should cause node.js to trigger a simple "not found" response) until it resulted in a Gateway timeout. Here, you can see that it has happened -- and the rewrite log shows that the request was definitely received by the app server and forwarded to port 8888... but it was never received by node.js (or, at least, the first line of code in the first line of middleware never gets it...)
Image Link: http://i.stack.imgur.com/3OQxS.png


text:
Q: Trying to convert each to while loop, creates TypeError. Why is it having a problem with symbols? I have a finished program, but now I need to convert an #Each loop to a #While loop. The loop should output almost the same information, but it throws me a 'directory.rb:24:in `print': no implicit conversion of Symbol into Integer (TypeError)' instead.
def input_students
  puts "Please enter the names of the students"
  puts "To finish, just hit return twice"
  students = []
  name = gets.chomp
  while !name.empty? do
    students << {name: name, cohort: :november}
    puts "Now we have #{students.count} students"
    name = gets.chomp
  end
  students
end

students = input_students

def print_header
  puts "The students of Villains Academy"
  puts "----------"
end

def print(students)
  students.each.with_index(1) do |students, index|
    puts "#{index} #{students[:name]}, #{students[:cohort]} cohort"
  end
end

def print_footer(names)
  puts "Overall we have #{names.count} great students"
end

print_header
print(students)
print_footer(students)

Works as expected. I'm trying:
def print(students)
  i = 0
  while i < students.length
    puts "#{students[:name]}, #{students[:cohort]} cohort"
  end
end

Why doesn't the #While loop work with similar input, and why is it trying to convert to an integer?

A: Because your #each loop was shadowing the students variable:
# v                              v
students.each.with_index(1) do |students, index|
  puts "#{index} #{students[:name]}, #{students[:cohort]} cohort"
end

you iterate an array called students and then assign each element in the array to a variable named students. When you get rid of the each loop, you didn't change the block to stop looking at students, so it's now looking at the array. To get a single element try:
def print(students)
  i = 0
  while i < students.length
    puts "#{students[i][:name]}, #{students[i][:cohort]} cohort"
  end
end

A:   while i < students.length
    puts "#{students[:name]}, #{students[:cohort]} cohort"
  end

students is an array. You can't address its elements with symbols. What you need to do is use i to fetch an element of students. You can call [:name] on that.
The mistake comes, I think, from poor naming in this snippet. And/or not understanding how each works.
students.each.with_index(1) do |students, index|
#                                ^^^^^^
#  This here is called `students`, but its value is a single student,
#  not a collection of students.


text:
Q: Why Boolean variable is not initialized by default in Android Studio? I switched from eclipse to android studio recently. During coding i got some strange behavior. I am having boolean variable where i am passing to if condition like this.
boolean permissionGranted;
if(permissionGranted){
//Do work
}else{
}

It works fine with eclipse. But in android studio it ask me to initialize boolean variable;

As per my understanding by default boolean varaible will be intialized to false. Still studio asking me to intialize by myself. What could be the reason behind this?


text:
Q: How to make the expected value of the difference in the values in paired data using ggplot2 I have a pair data as below and I want to make the expected value of the difference in the value (column called value) of pairs. In all the pairs, one has disease and the other one does not have disease as you can see from the data. In other words, the expected value of the difference of the value in one sibling compare to his/her sibling.
The description of the variable in the data are:
id = individual ID
family ID = family ID showing their dependency
status = 1 means disease and status = 0 means no-disease

Any guidance is appreciated.
d <- structure(list(id = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20),
                    familyID = c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10),
                    status = c(0,1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1),
                    value = c(29,26, 39, 22.3, 24, 41, 29.7, 24, 25.9, 21, 29,24,26,29, 15.2, 11, 35, 15.4,16, 13.4)),
            class = c("tbl_df","tbl", "data.frame"), row.names = c(NA, -20L))

A: I'm not certain if this is what you are looking for, but I used pivot_wider from tidyr to spread the values into two columns, though with status 0 and those with status 1. Then I used mutate to take a difference between the two columns, then plotted the familyID by the newly created difference with ggplot. Note that I removed the id column for the pivot_wider to work.
d <- structure(list(id = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20),
                    familyID = c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10),
                    status = c(0,1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1),
                    value = c(29,26, 39, 22.3, 24, 41, 29.7, 24, 25.9, 21, 29,24,26,29, 15.2, 11, 35, 15.4,16, 13.4)),
               class = c("tbl_df","tbl", "data.frame"), row.names = c(NA, -20L))

library(dplyr)
library(tidyr)
library(ggplot2)
d%>%
  select(-id)%>%
  pivot_wider(values_from = value, names_from = status)%>%
  mutate("Diff" = (`0`-`1`))%>%
  ggplot()+
  aes(as.character(familyID), Diff)+
  geom_point()

A: You can group by familyID, then use summarize() from the dplyr package to find the differences.
Also note the conversion of id, familyID, and status to factors, which may make life easier so they aren't confused with being integers.
library(dplyr)
library(forcats)
library(ggplot2)

d <- structure(list(id = as.factor(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)),
                    familyID = as.factor(c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10)),
                    status = as.factor(c(0,1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1)),
                    value = c(29,26, 39, 22.3, 24, 41, 29.7, 24, 25.9, 21, 29,24,26,29, 15.2, 11, 35, 15.4,16, 13.4)),
               class = c("tbl_df","tbl", "data.frame"), row.names = c(NA, -20L))

diffs <- group_by(d, familyID) %>%
         summarize(., diff = (value[status == 0] - value[status == 1]))

Reordering the families by difference can help get a sense of the distribution of differences
diffs$familyID <- fct_reorder(diffs$familyID, diffs$diff, .desc = TRUE)

ggplot(diffs, aes(x = familyID, y = diff)) +
  geom_bar(stat="identity")

If you really have a lot of families you may want to display a summary of the differences.
One option is with a histogram (modifying binwidth can control how fine the bins are):
ggplot(diffs, aes(x = diff)) +
  geom_histogram(binwidth = 3)

Similar to a histogram is a density plot:
ggplot(diffs, aes(x = diff)) +
  geom_density()

Finally, a boxplot is also a familiar summary. They're mostly meant for comparing multiple groups, but it works okay with just one. I've added the individual points using the geom_jitter() function.
ggplot(diffs, aes(y = diff)) + #If using multiple groups add x=group inside the aes() function.
  geom_boxplot() +
  geom_jitter(aes(x = 0))


text:
Q: PostgreSQL get date I have the following query which returns the date as dd/mm/yyyy hh:mm:ss, but I would like to extract the time and date as separate columns, how can I do this please?  I am new to PostgreSQL
Thanks
Kath
select
    up.mis_id,
    up.name,
    up.surname,
    es.created as "signed in",
    es1.created as "signed out",
    bb.name as "location"

from users_person as up

join users_role as ur on ur.id = up.role_id
join events_event as ee on ee.user_id = up.id
join events_swipe as es on es.id = ee.sign_in_id
join events_swipe as es1 on es1.id = ee.sign_out_id
join buildings_building as bb on bb.id = es.location_id

A: use explicit casting, for time:
es.created::time

and for date:
es.created::date

Eg:
t=# select now()::time(0) "Time",now()::date "Date";
   Time   |    Date
----------+------------
 08:19:59 | 2017-06-06
(1 row)

A: Use to_char. See Postgres documentation
select to_char(current_timestamp, 'HH12:MI:SS') as time,
       to_char(current_timestamp, 'mm/dd/yyyy') as date;
       time   |    date
    ----------+------------
     04:43:13 | 06/06/2017
    (1 row)


text:
Q: Multi Threading with ThreadPool while saving state Suppose I have 100 Runnable objects in Queue. If I use a ExecutorServicePool with some fixed size say 10, then atleast one of the 10 threads needs to be terminated for next Runnable object to be executed from the Queue. Is there any other way I can schedule the next Runnable from the Queue after a particular interval and save the current Runnable state to be saved at the end of the Queue somewhat like round robin fashion ?

A:
Is there any other way I can schedule the next Runnable from the Queue after a particular interval and save the current Runnable state to be saved at the end of the Queue somewhat like round robin fashion ?

I hope I understand the question here.  If this isn't what you are talking about then please edit your question and give more details.
If you are talking about saving state, the easy solution would be to use a ThreadLocal so that each of the threads running in your executor service can save their own state.
private final ThreadLocal<State> stateThreadLocal = new ThreadLocal<>() {
   // state initialization if needed
   protected State initialValue() { return new State(); }
};
...
public void run() {
   State state = stateThreadLocal.get();
   // now you can process the job with the state
}

However, this solution doesn't give you opportunities to control when the state is released if you need to close a http-client or something.
A better solution may be to use the executor-service to just start a static list of workers and then use your own BlockingQueue to inject jobs to the workers.
For example you could do something like:
private final static int NUM_WORKERS = 10;
private final ExecutorService threadPool = Executors.newFixedThreadPool(NUM_WORKERS);
...

final BlockingQueue<Job> queue = new LinkedBlockingQueue<>();
for (int i = 0; i < NUM_WORKERS; i++) {
    threadPool.submit(new WorkerWithState(queue));
}
// shutdown the queue once the last worker is submitted
threadPool.shutdown();
 ...
// then you submit a number of jobs to your own queue for the workers with state to run
queue.add(new Job(...));
...

Your workers would hold a local state field that they would hold between runs.
private class WorkerWithState implements Runnable {
   // some state held by the worker
   private SomeState state = new SomeState();
   private final BlockingQueue queue;
   public WorkerWithState(BlockingQueue queue) {
      this.queue = queue;
   }
   public void run() {
      while (!Thread.currentThread().isInterrupted()) {
         try {
            // wait for a job to process
            Job job = queue.take();
            // process the job here using the state
            processJob(job, state);
         } catch (InterruptedException ie) {
            // always a good pattern
            Thread.currentThread().interrupt();
            return;
         }
      }
   }
}

To terminate these workers, you can call threadPool.shutdownAll(true) on the thread-pool to interrupt them all or inject a constant QUIT_JOB to have them stop themselves once the job queue has been exhausted.


text:
Q: HTML, CSS Random Sized Self Aligning Justified Image Gallery I am creating an image gallery populated with a dynamic sized amount of images, the PHP and HTML are as follows;
<?php
$dirname = "Pictures/";
?>

<?php

$images = glob("" . $dirname . "*.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF}", GLOB_BRACE);

foreach ($images as $image)
{
    $File = pathinfo($image);
?>

    <a href="<?php echo $url.$image; ?>"><img src="<?php echo $url.$image; ?>" alt="">

<?php
}
?>

The css I have is as follows;
.gallery
{
    line-height: 0;
    -webkit-column-count: 5;
    -webkit-column-gap:   5px;
    -moz-column-count:    5;
    -moz-column-gap:      5px;
    column-count:         5;
    column-gap:           5px;
    align-content: stretch;
    list-style: none;
}

.gallery li
{
    width: 100% !important;
    height: auto !important;
    margin-bottom:5px!important;
    border:1px solid #dfe1e5;
}

.container img
{
    width: 100% !important;
    height: auto !important;
}

This code I have so far doesn't allow me to randomly display the images while justifying the bottom row so the whole gallery is more rectangular, as follows;
Justified Random Rows
Also, this code is in columns, what I would like is a more random flow instead of breaking things up into columns.
Can someone give some advice of a better way to achieve the goal of a random sized self aligning justified image gallery using CSS and HTML only.
I created a JSFiddle https://jsfiddle.net/awhe61kg/ for those who request.
As a side note, what I would like to achieve at the least is like the unitegallery theme https://unitegallery.net/index.php?page=tiles-justified, but without the use of Javascript if at all possible. The reason I don't want to use this gallery is because I've tried it and it is glitchy. Although it is a beautiful design which I would like to replicate in CSS and HTML.
** FIXED ISSUE BELOW **
I can nearly achieve the unitegallery behavior with CSS flex boxes alone as follows;
.gallery
{
    min-width:100%;
    max-width:100%;
    list-style: none;
    font-size:0;
    display:flex;
    flex-wrap: wrap;
    justify-content:flex-start;
    align-items: stretch;
}

.gallery li
{
    flex-direction: row;
    flex:20 20 auto;
    width: auto !important;
    height:200px;
    max-width:400px; <-----------causes the problem, remove and its fixed
    margin-bottom:5px!important;
    border:1px solid #dfe1e5;
}

.container img
{
    min-width: 100% !important;
    max-width: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
}

Although I'm having an issue currently with the top row not stretching correctly at certain widths in responsive design mode.
** FIXED **
Here is a JSFiddle with the flex box image gallery and the element which was causing the problem commented out https://jsfiddle.net/ag9s2qdt/.

A: The page you link to (here) just uses rows instead of columns. If you want justified rows of images with just HTML and CSS, you can do this:

.justified {
  text-align: justify;
}

.justified:after {
  content: "";
  display: inline-block;
  width: 100%;
}

.justified img {
  height: 100px;
  display: inline-block;
}

Of course, the gaps between each image can be wide, and you're responsible for making sure there isn't a weird amount of images on the last row. JavaScript would help tremendously with the calculations for actually getting a good result here, but to each his own.


text:
Q: Prevent a duplicate entry in database when form is sent I am trying to prevent a duplicate entry into my database. I have two select boxes on a form that are populated from two tables category and publisher. Using the UPDATE method below it duplicates the entry if I send the same value to the database. What changes can I make so entries are not duplicated when updated?
    $sqlQuery = "UPDATE records
                INNER JOIN category ON category.catID = records.catID
                INNER JOIN publisher ON publisher.pubID = records.pubID
                SET title=$title, year=$year, desc=$desc, price=$price, pub=$pub
                WHERE recID=$recID";

        $stmt = $dbConn->prepare($sqlQuery);
        $stmt->execute(array($sqlQuery));

A: You simply need to create a unique key using the columns that make a row unique...
ALTER TABLE records
ADD CONSTRAINT U_records UNIQUE (title,pub);

Here the example to make all records unique using title and pub columns. This means there can be multiple duplicate titles, but they'll need a different pub. Please modify to your use case, you can add as many columns as you want but keep it as low as possible for performance reasons.
Adding this constraint will produce an error from MySQL (a contraint violation if IRC?). You will need to catch it to tell the user.


text:
Q: Why we need custom bridge to communicate with others Dockers container using name? Why the default's bridge cannot do it please? I'm working on Docker container and I find it strange the default network prevent from communicate between container using the name,
thanks for any hint

A:
Containers on the default bridge network can only access each other by IP addresses, unless you use the --link option, which is considered legacy. On a user-defined bridge network, containers can resolve each other by name or alias.

From official docker documentation
Technically, there is nothing stopping docker to resolve the container names on default bridge network. I think it is just a decision that is made by docker team to force users to create bridge networks consciously. So that they know what they are doing and securely use it for production.


text:
Q: fileSystem.chooseEntry from package:chrome/app.dart generates runtime error Has anyone successfully used any fileSystem calls in package:chrome/app.dart? (This is the Chrome API package for Google Dart.)
Here's my code:
import 'package:chrome/app.dart';

void main() {
    fileSystem.chooseEntry();
}

Here's my pubspec.yaml file:
name: ChooseEntry
description: A sample chrome packaged application
dependencies:
  browser: any
  chrome: any
  meta: any

The other files were generated automatically by the Dart Editor and remain untouched by me.
The error I get from Dartium is:
Breaking on exception: 'package:chrome/src/common.dart': malformed type: line 72 pos 29: type 'js.Callback' is not loaded

When I compile to JS and run in Dartium or Chrome, I get this error:
Uncaught RuntimeError: Error: Cannot resolve 'Callback'.

So, my question is whether anyone has successfully used the chooseEntry API, or any API in fileSystem and, if so, what about what I did needs to be fixed. My guess is that I'm missing a package, but I can't identify what it might be.
I did add package "js" to pubspec.yaml, with no effect. I also tried making copies of all the packages, in case Dartium or Chrome didn't handle the symlinks correctly, and that didn't help either. (I doubt that that's the problem, as it found the code for fileSystem.chooseEntry just fine.)
I'm using:
Dart Editor version 1.0.0_r30798 (STABLE)
Dart SDK version 1.0.0.10_r30798

A: The chrome package appears not to be maintained anymore, consider using chrome_gen instead by replacing chrome with chrome_gen in pubspec.yaml and by editing the import statement like this:
import 'package:chrome_gen/chrome_app.dart';

main() {
  fileSystem.chooseEntry();
}

The difference between these two packages is that wrappers are hand-written in chrome and autogenerated in chrome_gen from the json and idl files from Chrome.
Links:
Pub Package: chrome_gen
Mailing List: What is the difference between chrome and chrome_gen ?


text:
Q: A versioned equivalent for SVN properties to be preserved during SVN -> Git migration For the purpose of versioning the content of all jar files released to our customers, for the last few years we've been releasing a text file within those jars that would hold File <-> CVS Version mapping for each java file contained in that jar. CVS repository was in use as our VCS.
Not questioning whether there was no better solution at that time, a couple months back we've decided to migrate to SVN and our solution to keeping the history for a long forgotten jar that might have been retrieved at any time from customer's production environment, was adding a custom svn property to each java file migrated.

E.g.:
My/Foo/Bar.java migrated at CVS Version 1.2.33.5 to SVN as svn-rev.5678 would receive the following property: svn:cvs = 1.2.33.5.
Last change to My/Foo/Bar.java (CVS version 1.2.33.4) was mapped to svn-rev.5145 which has the svn property set for our file to svn:cvs = 1.2.33.4.
SVN status / log for that file can be easily browsed so can be both, changes made to that file and the history of svn:cvs property values.
Now, when a new svn check-in comes to that file, say as svn-rev.5700, all that needs to be done is clearing the property.
Mission accomplished - we could have dropped CVS completely.

Moving to Git.
The next step on our path is merging some legacy TFS repository with SVN repository that we now have and, not going into much details, the approach we'd like to follow is migrating both of these straight to Git.
One major concern we have is how not to loose the svn:cvs properties introduced during our first migration. Being aware of gitattributes they may seem like the right way to go, but is there no better option? Is it really necessary to store .gitattributes files around the source code? (the global file wouldn't probably be practical). Also, generating these files and their history from svn properties doesn't sound like a trivial script to write.
Any hints will be well appreciated.

A: You should take a look at git-notes to see if that's something you would want to use. Normally notes are attached to commits, but they can be attached to any object, including a file object.
The problem with attaching notes to a file object is that whenever that file changes, the object changes as well, and its notes won't be copied over. However, you could also use a hook that automatically updates these notes whenever a file is changed.


text:
Q: Opening the same dialog multiple times with $dialog I created this plnkr when answering this question 'AngularJS - open controller in a dialog (template loaded dynamically)'.
All the example app does is launch a dialog box based on a template, with it's own controller.  The first time the dialog launches, everything works as expected.  However, if I try and re-launch the dialog, after dismissing it, the modal backdrop is shown but no dialog.  In the javascript console you can see that the then method on the promise returned by $dialog.open() is called immediately, but the backdrop isn't removed and no errors are reported.  I'm completely baffled.
The dialog can be opened and closed repeatedly on the angular-ui bootstrap documentation page.
Where did I go wrong?
HTML:
<!DOCTYPE html>

    <link data-require="bootstrap-css@*" data-semver="2.3.2" rel="stylesheet" href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" />

    <link rel="stylesheet" href="style.css" />

JS:
app.controller("DemoCtl", ["$scope", "$dialog", function($scope, $dialog){
  $scope.launch = function() {
    var d = $dialog.dialog({
      backdrop: true,
      keyboard: true,
      backdropClick: true,
      templateUrl: "dialog.html",
      controller: "DialogCtl"
    });

    d.open().then(function(result) { console.log("d.open().then"); });
  };
}]);

A: I've found the issue.  It has to do with using an  tag to open the dialog.  Clicking on the  tag causes a location change to be fired.  The dialog handles location change by closing itself as you can see below.
  this.handleLocationChange = function() {
    self.close();
  };

I'm not sure why this doesn't happen on the first click of the  tag, but it definitely happens on all subsequent calls.
You can see in this plunker that if you use a button, it opens correctly each time.
Hope this helps!  I'll try to figure out why it doesn't break on the first time.
EDIT
The location change is actually really bad.  It appears to be looping, to what I believe is the angular maximum of 10 digests. Still not sure why it doesn't do a location change on the first click.

A: It looks like if you put "javascript:;" in the href, then it works fine for the  tag.
Like this:
Open the dialog

Also, the  tag issue seems to be browser related.

A: The trouble is indeed with the  tag. Jason mentioned that he expected that the angular  directive would stop the location change. This is so, but it needs the href to be blank. the plunker was
Open the dialog

and should have been
Open the dialog

When I changed the plunker to that effect everything seemed okay


text:
Q: Check if a User Has Clicked on a Button What I would like to do is essentially check whether or not a user has clicked a certain link on a page. The idea behind the functionality is that a user can click "Thanks!" on a post created on the website, but they can only submit one "Thanks!" per post.
I have no problem creating a simple click counter for the "Thanks!" button, and save the count to a database using PDO, but I am not sure how I can assign a click to the user who's session is active.Also, posts are constantly being added to the site, so I would need a system which would scale to more posts automatically.
Any guidance is appreciated, thanks!
Note: I know I have not put any example code, but I believe this is simple enough for a good programmer to grasp quickly.
EDIT
On further thought, the IP can not be used to distinguish users, as this website will be used by many people on the same IP.

A: Are the users logged in or anonymous? If they are logged in just save their user id in a session variable and upload it with their vote to a table in your database.
I do something similar using an Ajax request to a .php page that inserts a row with the session user ID and the vote.
If they are anonymous you can save their ip but that leads to problems with users who share the same ip address. Another (bad) option is to use cookies but users can obviously just clear their cookies and vote again.


text:
Q: How to get video url using file_get_contents in php Im trying to get video and poster from another site
Lets call it othersite.com
other site.com has this parameters:

            <video style="width:100%; height:100%;"
               controls="controls"
               autobuffer="autobuffer"
               class="player-html5"
               preload="metadata"
               poster="http://othersite.com/img.jpg">
                <source src="http://othersite.com/video.mp4" type="video/mp4">
            </video>

with the below php I got the image from the opengraph tag but Im trying to get the mp4 url which I couldnt get yet
$Agent  = array('http' => array('user_agent' => 'Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D)'));
$String = file_get_contents('http://www.othersite.com/'. $video .'/', false, stream_context_create($Agent) );
preg_match("/<source src=\"(.*)\" controls type=\"video\/mp4\"/", $String, $VideoURL);
$VideoURL = $VideoURL[1];
$IMG = getstring($String,'<meta property="og:image" content="','"');

my php is getting the image only do you have any idea what Im doing wrong in preg_match and how to get the http://othersite.com/video.mp4

A: This can be done by using Preg_Match in the following way. It's pretty simple and it works extremely well!
$source = file_get_contents("That Page");

preg_match("'<source src=\"(.*?)\" type=\"video/mp4\">'si", $source, $match);
if($match) echo "result=".$match[1];

This should do what you want it to.
After a recent comment, I felt that I should also add that The si modifiers are making this regex looser.


text:
Q: Control last page filling It is possible to create a macro, which is determine a percentage of last page filling. Say, if the last page filled less than 3/4, then macro write a warning to the page!

A: A simple solution
\documentclass{article}
\usepackage{lipsum} % just for the example
\makeatletter
\AtEndDocument{\ifdim\pagetotal<.75\pagegoal\@latex@warning{the last page filled less than 3/4}\fi}
\makeatother
\begin{document}
\lipsum[1-17]
\end{document}


text:
Q: How to access tableau server without login I am new to tableau and I want to integrate tableau server in our application through Iframe, I am passing HTTP URL with authentication details like username and password but whenever I am accessing tableau it is asking for username and password.So please suggest me that how i can access tableau without redirecting to login page.

A: According to the Tableau community you can't do this through the URL:

There is no built-in mechanism to pass a username/password on the URL
  as doing so gives "bad people" a super-duper-easy way to hack into
  Tableau Server itself. As a hacker, all I'd have to do is "sit on the
  wire", watch requests go to Tableau, and I could harvest everyone's
  usernames and passwords. Scary stuff!

But there is a solution for built in credentials if you have a security mechanism on your end:

You might want to read up on Tableau Server's ability to do Trusted
  Tickets authentication. You could essentially tell Tableau Server to
  "Trust" whatever other security mechanism is authenticating your users
  (I assume you have one).  If you don't have another mechaism to
  authenticate users before they get to Tableau Server, there's not too
  much you can do.

More on Trusted Authentication from Tableau website:

Trusted authentication simply means that you have set up a trusted
  relationship between Tableau Server and one or more web servers. When
  Tableau Server receives requests from these trusted web servers it
  assumes that your web server has handled whatever authentication is
  necessary

Setting this up requires you to add the trusted IP addresses to your Tableau server. This is done by stopping tabadmin and then running the following command, followed by saving this config and restarting:
tabadmin set wgserver.trusted_hosts "<trusted IP addresses or host names>"

Once this is done you have to configure your web server so it can request tickets from Tableau server using a POST request to http://<server name>/trusted. These tickets must then be included into the script.
Hope this helps.


text:
Q: Task-like objects support in Kestrel I am trying to return task-like object from the controller action:
    [HttpGet("test")]
    public async FuncAwaitable<string> GetAsync() => "OK";

It works in the VS2019 wizard generated ASP.NET Core solution but fails with Kestrel:

The problem is somewhere in middleware:
ArgumentException
System.ArgumentException: 'this' type cannot be an interface itself.
   at System.RuntimeTypeHandle.VerifyInterfaceIsImplemented(RuntimeTypeHandle interfaceHandle)
   at System.RuntimeType.GetInterfaceMap(Type ifaceType)
   at System.Reflection.RuntimeReflectionExtensions.GetRuntimeInterfaceMap(TypeInfo typeInfo, Type interfaceType)
   at Microsoft.Extensions.Internal.AwaitableInfo.IsTypeAwaitable(Type type, AwaitableInfo& awaitableInfo)
   at Microsoft.Extensions.Internal.CoercedAwaitableInfo.IsTypeAwaitable(Type type, CoercedAwaitableInfo& info)
   at Microsoft.Extensions.Internal.ObjectMethodExecutor..ctor(MethodInfo methodInfo, TypeInfo targetTypeInfo, Object[] parameterDefaultValues)
   at Microsoft.Extensions.Internal.ObjectMethodExecutor.Create(MethodInfo methodInfo, TypeInfo targetTypeInfo, Object[] parameterDefaultValues)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerCache.GetCachedResult(ControllerContext controllerContext)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerProvider.OnProvidersExecuting(ActionInvokerProviderContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ActionInvokerFactory.CreateInvoker(ActionContext actionContext)
   at Microsoft.AspNetCore.Mvc.Internal.MvcAttributeRouteHandler.<>c__DisplayClass12_0.<RouteAsync>b__0(HttpContext c)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Shared.AspNetCore.CorrelationHeader.<>c__DisplayClass0_0.<<UseCorrelation>b__0>d.MoveNext() in C:\proj\ah\shared\src\Shared.AspNetCore\AspNetCore\CorrelationHeader.cs:line 16

Any ideas?


text:
Q: MongoDB atlas search is not as efficient as expected I have the problem that my search is not as efficient as expected. I've already checked out several options to improve the search, but unfortunately that didn't work. (For example, using other index and search Analyzer, wildcard search instead of text search, ...)
The search should only search certain fields and not the entire document. Unfortunately, other fields that were not specified are also searched.
What could be the reason for this?
Thanks in advance and best regards
Aggregation Query
[
    {
        "$search":{
            "compound":{
                "should":[
                    {
                        "text":{
                            "query":"*searchTerm*",
                            "path":[
                                "companyName",
                                "customerNameAddition"
                            ],
                            "score":{
                                "boost":{
                                    "value":3
                                }
                            }
                        }
                    },
                    {
                        "text":{
                            "query":"*searchTerm*",
                            "path":"customerNumber",
                            "score":{
                                "boost":{
                                    "value":2
                                }
                            }
                        }
                    },
                    {
                        "text":{
                            "query":"*searchTerm*",
                            "path":"email"
                        }
                    }
                ]
            }
        }
    },
    {
        "$limit":15
    }
]

Index Overview

A: You need to turn dynamic mapping to "off" in order to not dynamically index all of your fields.
Also for your email field, you may consider using uaxUrlEmail


text:
Q: How to pass values with php from function into an array I've read the Q&A regarding this topic, but it unfortunately doesn't answer my question, because I'm a Beginner in PHP.
I'm using a function to display a polygon on a google Map. That works all fine. The coords are stored in the following variable:
$polygon = array(
"43.231297 -79.813721",
"43.238438 -79.810768",
"43.230335 -79.809395",
"43.230312 -79.809296",
"43.240208 -79.808983",
"43.230225 -79.808884",
"43.240116 -79.808617",
"43.229823 -79.807388",
"43.231235 -79.802649",
"43.237137 -79.800774",
"43.231297 -79.813721"
);

I now want to get the latitude and longitude dynamically out of a MySQL database. My code below runs great and returns the desired coordinates:
            <?
                foreach ($BusinessAreaMunich as $item) {
                echo "new google.maps.LatLng(" .$item['AreaCoordLatitude'] . "," .$item['AreaCoordLongitude'] . "), \n";
            }
            ?>

However, I've tried to do the following:
$polygon = array(
    foreach ($BusinessAreaMunich as $item) {
    echo $item['AreaCoordLatitude'], $item['AreaCoordLongitude'];
}
);

Now I know that doesn't work, but I don't know how to solve my issue. Could you please give me an idea how to solve this?

A: Proper code is:
$polygon = array();  // define `$polygon` as array
foreach ($BusinessAreaMunich as $item) {
    // create `string` value as a result of concatenating coords and a space
    $coords = $item['AreaCoordLatitude'] . ' ' . $item['AreaCoordLongitude'];

    // append a `string` to `$polygon`
    $polygon[] = $coords;

    // or simply:
    // $polygon[] = $item['AreaCoordLatitude'] . ' ' . $item['AreaCoordLongitude'];
}

// output to see what you have
print_r($polygon);


text:
Q: HttpSession with only one Servlet I am creating a Webapp and struggeling with how to manage the Session on my app.
I have one Servlet which is requested by more HTML files via AJAX Calls.
When the user logs in want to create a session and manage this session for the whole app till he logs out.
How can i achieve this?
Shall i make a method on the server which every HTML files calls first after login where check if the session is not null or null?


text:
Q: Cocoa-Touch - Make a read-only UITextField become first responder I have a UITextField which I have set it's inputView to be of a UIPickerView so the user can choose between a few values there. However I'm having trouble making the textfield become first responder.
If I set my textfield userInteractionEnabled = NO then it won't become first responder but if I set it to YES it will become first responder but then I will have a blinking cursor in there which I do not want. So how to make a read-only UITextField become first responder?

A: From your question it looks you dont need a UITextField. So an alternative way to achieve this is to have a UILabel with a UIButton added on top, which will bring the picker. On selection of any value in picker, the UILabel text can be modified.


text:
Q: Converting an MVP ASP.NET app to Silverlight 3 - help me choose an architecture I've been given the ask of converting an MVP ASP.NET app to Silverlight. This will be my first Silverlight application and I'm struggling to determine how best to organise the architecture.
The app is very much a standard CRUD LOB app. I will also be using a GIS component but I dont think this makes a difference to the general architecture (please correct me if it does). I'll be using Subsonic as the DAL, but again I dont think this makes a difference to my architecture.
The original application is rather large, so if possible I would like to reuse as much of the model and the view as possible.
Reading around on the web its a little confusing as to what is considered 'best practices' for the architecture of Silverlight 3 LOB apps. Microsoft seems to be pushing this RIA framework - but its only in preview...is it production ready? I get the impression that Microsoft are pushing different architectural guidelines with Silverlight 3, but I'm struggling to find out what exactly these architectures are!
There is also Prism, and the Caliburn project.
Luckliy I have a very flexible deadline here, so I'd like to get as close to best practices even if it means a bit of a learning curve at the beginning.
I would greatly appreciate a friendly nudge in the right direction.
edit in response to answers so far

*

*The solution will be a 100% fullscreen Silverlight app. I am not interested in a mixed Silverlight-Asp.net frontend.

*With this in mind - I want to maximise the reuse of the model and view part of the codebase, but only if this is possible without making major sacrifices to the new architecture.

*The solution needs to come from Microsoft or at least be very well supported.

*If RIA is liable to change before release, its totally out of contention.
second edit
Thanks everyone for their excellent answers. I've upvoted everyone but the answer has to go to Steve because his answer was actually the series of questions I should have been asking myself.
I'll update the thread once I've had a good look at both Prism and CSLA.
I love you all.

A: So many options :-) Your choice probably depends on several factors:

*

*How much you want to reuse of the current solution

*Whether you want a full screen SL app, or just replace parts of the site with "richer" content

*How  your current app is structured, both visually and what your ActionMethods are returning

*Timescales

RIA services might be a decent fit, as it would allow you to at least reuse your model and validation (if you're using data annotations) but it's some way off and likely to change before release.
The other option is a ground up Silverlight app, for which I'd recommend taking a look at PRISM and MVVM for structuring it (if only to keep the initial payload down!). You could probably reuse your model, and there is support for data annotations in Silverlight, but you wouldn't be far off recreating a new application.
The third option, and one that you may love or hate, would be to build "islands" of rich functionality in SL for areas of your site. You could use your existing MVC app and potentially have ActionMethods return JSON (or XML if you'd prefer) which your SL areas could consume and render. You'd have decent code re-use and you could enhance areas of the site in isolation.
An open ended answer to an open ended question :-)
EDIT: Judging by your responses, if it were me, I'd be creating a PRISM app. If it's currently a web app it should "sit" quite well with the region model (although you wouldn't be actually reusing any view code), and the dynamic XAP loading will help with your initial payload if you want a  single full screen app. If it's a CRUD based app then you might want to take a look at the XAML Power Toys to quickly put data forms together.
Datawise you could either reuse your model and expose it via WCF or ADO.Net Data Services, wait for RIA services to stabilise (depending on your timescales) or still use the MVC action methods but return JSON from them for the SL app to consume.

A: You might want to take a look at the CSLA framework, while it's not for everyone, it is a nice, easy to use and powerful framework.
The author, Rockford Lhotka, also wrote a version just for Silverlight and provides a video series on how to create applications using CSLA and Silverlight, to help developers get up to speed quickly.
Some links for you to check out:

*

*Rockford Lhotka

*CSLA for Silverlight

A: I personaly would vote for prism for a sizable app, RIA does have "go live" licence but i would trust that just yet. Remeber that you can mix and match.
Check out http://compositewpf.codeplex.com/
and http://www.sparklingclient.com/prism-silverlight/

A: We've been going for a couple months now.  We're using Prism and RIA services.  I think that there is a bit of a learning curve, but I enjoy Prism and there is some support for it online.
RIA services is a bit more iffy, but I think it's worth using.  We started trying to use it soon after the July Preview, and there wasn't much documentation online to look at.  as these past few months have gone by, we've managed to make it do what we want, and there are more examples and solutions online that help.  Microsoft is pushing it, and I think that they'll come through in the end.


text:
Q: UIAlertView and cocos2d memory mangement I display a UIAlertView above my cocos2d layer.
I release it after I how it.
Is it really gone?  Do I have to somehow remove it from my UIView?

A: If you just do
UIAlertView* alert = [[UIAlertView alloc] initWithTitle...];
[alert show];
[alert release];

then there's no need to worry about it. However, if you set the alert's delegate to some object, make sure that object still exists when the user taps a button in the alert - otherwise your app will crash when the alert will try to call alertView:didDismissWithButtonIndex: delegate method.


text:
Q: Why return in forEach of Map doesn't interrupt In order to iterate a map in Typescript.
The forEach won't be interrupted. Strangely the key and value have to be inverted.
The for works correctly.
    const map = new Map<number, number>()
    const uniq = new Set<number>();

    // won't return anything if condition is true
    map.forEach( (v,k) => { // moreover , k and v are inverted
        if(uniq.has(v)) return false
        uniq.add(v)
    });

    // will work
    for (const [_, v] of map.entries()) {
        if(uniq.has(v)) return false
        uniq.add(v)
    }

Why forEach doesn't break or return ?

A: The .forEach method accept a function as argument that will be called on each element of the iterable.
The return keyword ends the current execution of it's function, this is why you can't exit from a forEach with a simple return, it will exit only the current function call with the element, it won't exit the forEach.


text:
Q: Ajax sourced data for datatable I need a datatable to be populated with data generated from another ajax call (user input). This is my code:
function get(){

        var getDates    = jQuery.noConflict();

        getDates.ajax({
            type: "POST",
            url: "ajax/report.php",
            data: "start="+getDates("#start").val()+"&end="+getDates("#end").val(),
            success: function(msg){
                //alert(msg);
                getDates('.ajax-sourced').dataTable().fnDestroy();

                //This code works:
                getDates('.ajax-sourced').DataTable(
                    {"data":[["2019-11-23","Test1"],["2019-11-23","Test2"]]}
                 );

                //This code does NOT work even though the returned msg is the same as the data above:
                //msg = {"data":[["2019-11-23","Test1"],["2019-11-23","Test2"]]}
                getDates('.ajax-sourced').DataTable(msg);
});

    }

Any idea why the  getDates('.ajax-sourced').DataTable(msg); does not work even if the returned msg is the same as the custom typed data?


text:
Q: Should I use var in Java 10? Given that I can't use var for non-denotable types (Nulls, Anonymous classes, Some Single Method Class and most importantly Intersecting Types), am I better off not using it for better readability and consistency (given that it's only for local types)?
I kind of feel that it would be abused:
var a = someObj.getSomeValue().getSomethingElse().returnsSomething();

A: Though this is probably primarily opinion-based, I'd say: No, it is not evil.
The var keyword is only allowed when the type of the variable is already clear at compile-time. Also, it will generate the same bytecode, so there is nothing to fear.
In some cases like null, var is not allowed.   This doesn't make it evil, but rather good. If this was not the case, Java would not be statically typed anymore.  (Note, however, it is allowed in most of the cases you've listed.)
Also I don't see any problem with your example. Since your .returnsSomething() would rather be something like .getPerson() in the real world, it would be clear to the reader that var is a Person.


text:
Q: sp_senddb_mail mail remaining unsent My SQL Server services (SQLSERVER and SQLAGENT) were running with account Domain\Account1 (for very long days). We were getting email notifications regularly.
Yesterday, I changed the service account for both the SQLSERVER and SQLAGENT to Domain\Account2. The services were restarted.
I have not received the expected emails so far. I checked the mails are in unsent state.
Select * from msdb.[dbo].[sysmail_unsentitems]

I added Domain\Account2 (full control as Domail\Account1 was having) to the path of DatabaseMail.exe. Still no result.
What are the other things I need to check?
I am using SQL Server 2014.

A: After a long investigation, I learned few things and fixed the issue.
The DatabaseMail.exe gets executed from SQL Server service is through member of an Administrator group. My account Domain\Account2 was member of Administrative group but still it was failing.
Because, the service was not restarted after adding Domain\Account2 to Administrator group (although I restarted after changing Domain\Account1 to Domain\Account2 in SQL Server Service)

A: After a long to check sysmail_log for Database mail:All mails have Unsent status .
I have execute below procedure and my issue has been resolved.
Procedure Name: sp_sysmail_activate
You can find this procedure in below script.
C:\Program Files\Microsoft SQL Server\ [Instance]\MSSQL\Install\sysdbupg.sql


text:
Q: Как перенаправить stdout в файл программно на Go? Заранее извиняюсь, если вопрос слишком простой. Имеется такая функция:
package main

import (
        curl "github.com/andelf/go-curl"
)

func json_get(link string) {
        easy := curl.EasyInit()
        defer easy.Cleanup()
        if easy != nil {
                easy.Setopt(curl.OPT_URL, link)
                easy.Perform()
        }
}

Как перенаправить STDOUT или даже сам CURL в файл? Перенаправить надо программно, т е без ./main > myfile.out. ОС - Linux.

A: Посмотрите список опций. Я, например, вижу OPT_STDERR, OPT_VERBOSE, OPT_FILE, OPT_NOPROGRESS - чтото из этого, думаю, должно помочь. Для прогресса там даже есть пример

Нужно использовать stdout/stderr/stdin as is, не переделывая. Переделкой вы сломаете ожидаемое поведение и вызовете негодование уже у специалистов. Правильный подход - обучить неопытных.
Если нужно писать логи, то пишите их в файл отдельно, не трогая стандартные потоки io.