text:
Q: JQuery animation does not work Well, I have an image which animates by moving to the left by 1000px. Once it stops, this image is replaced to another image. My code:
function image1() {
    $('#photo').animate({left: '1000px'}, 40000, function() {
        $('#photo').attr('src', 'image2.jpg');
       setTimeout(image1, "2000")
    });
}

The image doe move, but when it stops, it does not change.. :(

A: Try this:
setTimeout(image1, 2000)

instead of this
setTimeout(image1, "2000")

A: To start, the second argument to setTimeout should be a number (less than 2^31), not a string.
setTimeout(image1, 2000);

A: Use $(this) instead of repeating the selector.


text:
Q: Can I query GraphQL inside Google Map component? I'm playing around with Gatsby/Contentful and Google Maps.
I've created this component:
import React from 'react'
import { GoogleMap, Marker, InfoWindow } from 'react-google-maps'

const Map = (props) => {

    return (

        <GoogleMap
            defaultZoom={12}
            defaultCenter={{
                lat: 34.0522,
                lng: 118.2437
            }}
            >

            <Marker
                onMouseOver={() => {
                    setInfoWindow(true)
                }}
                onClick={() => props.setmodal(true)}
                position={{
                    lat: 34.0522,
                    lng: 118.2437
                }}
            />

        </GoogleMap>
    )
}

export default Map;

The map is showing and everything works fine. I've tried to access my Contentful data using this approach, but getting an error that allContentfulLocations are undefined. How can I query my Contentful data inside Google Maps?
Here was my approach which is failing.
import React from 'react'
import { GoogleMap, Marker, InfoWindow } from 'react-google-maps'
import { graphql } from "gatsby"

export const query = graphql`
{
    allContentfulLocations {
      nodes {
        id
        name
        location {
          lat
          lon
        }
      }
    }
  }
`

const Map = ({props, data}) => {

      const {
              allContentfulLocations: { nodes: locations },
            } = data

    const [infoWindow, setInfoWindow] = useState(false)

    return (

        <GoogleMap
            defaultZoom={12}
            defaultCenter={{
                lat: location.location.lat
                lng: location.location.lon
            }}
            >

            {locations.map(location => {
                return (
            <Marker
                onMouseOver={() => {
                    setInfoWindow(true)
                }}
                onClick={() => props.setmodal(true)}
                position={{
                    lat: 34.0522,
                    lng: 118.2437
                }}
                />
                )
              })}

        </GoogleMap>
    )
}

export default Map;

A: Use:
import React from 'react'
import { GoogleMap, Marker, InfoWindow } from 'react-google-maps'
import { useStaticQuery, graphql } from "gatsby"

const Map = (props) => {
  const data = useStaticQuery(graphql`
{
    allContentfulLocations {
      nodes {
        id
        name
        location {
          lat
          lon
        }
      }
    }
  }
`)
      const {
              allContentfulLocations: { nodes: locations },
            } = data

    const [infoWindow, setInfoWindow] = useState(false)

    return (

        <GoogleMap
            defaultZoom={12}
            defaultCenter={{
                lat: location.location.lat
                lng: location.location.lon
            }}
            >

            {locations.map(({location}) => {
                console.log(location);
                return (
            <Marker
                onMouseOver={() => {
                    setInfoWindow(true)
                }}
                onClick={() => props.setmodal(true)}
                position={{
                    lat: 34.0522,
                    lng: 118.2437
                }}
                />
                )
              })}

        </GoogleMap>
    )
}

export default Map;

If your component (Map) is not a page, you won't be able to use page queries and therefore you will be forced to use a static query
Notice the destructuring in the map loop:
locations.map(({location}) =>

In the way you were using the loop, location was the iterable variable, not the location object itself. You should access to location.location in your approach, you're avoiding that repetition, using a destructuring in the same declaration on the iterable object as I provided. I've also added a console.log() for debugging purposes, take a look at what's inside in both approaches.
In addition, if you look at your code:
const Map = ({props, data}) => {

You are destructuring props as props itself so. I've removed that destructuring and I've added it to:
  const {
          allContentfulLocations: { nodes: locations },
        } = props.data

redpajama_set_name: RedPajamaStackExchange


text:
Q: NelmioApiDocBundle set Response content type as file I am using NelmioApiDocBundle 4.0 to generate the documentation of my API. The problem started when i tried to set a response type as a file. I have a method that gets a file from database and returns it as StreamedResponse:
return new StreamedResponse(function () use ($consent) {
                    fpassthru($consent);
                    exit();
                }, 200, [
                    'Content-Transfer-Encoding', 'binary',
                    'Content-Type' => 'application/pdf',
                    'Content-Disposition' => sprintf('attachment; filename="%s.pdf"', 'filename'),
                    'Content-Length' => fstat($consent)['size'],
                ]);

This code works well and return the requested file but i can't set appropriate response type in the documentation.
I tried this way, so mi annotations look like this:
     * @OA\Response(
     *     response=200,
     *     description="My description",
     *     content="application/pdf",
     *     @OA\Schema(
     *      type="string",
     *      format="binary"
     *    )
     * )

but the response is:
Warning: Invalid argument supplied for foreach()

The problems starts when i set the content property, but without it
this is the result

A: You need to put @OA\Schema inside @OA\MediaType:
     * @OA\Response(
     *     response=200,
     *     description="My description",
     *     @OA\MediaType(
     *         mediaType="application/pdf",
     *         @OA\Schema(
     *            type="string",
     *            format="binary"
     *         )
     *     )
     * )


text:
Q: How to store state within a module between function calls? I have the following functions in a module:
pub fn square(s: u32) -> u64 {
    if s < 1 || s > 64 {
        panic!("Square must be between 1 and 64")
    }

    total_for_square(s) - total_for_square(s - 1)
}

fn total_for_square(s: u32) -> u64 {
    if s == 64 {
        return u64::max_value();
    }

    2u64.pow(s) - 1
}

pub fn total() -> u64 {
    u64::max_value()
}

This works fine when calling individual functions directly. However, I want to optimize it and cache values to total_for_square to speed up future look ups (storing in a HashMap). How should I approach where to store the HashMap so it's available between calls? I know I could refactor to put all of this in a struct, but in this case, I cannot change the API.
In other, higher level languages I have used, I would just have a variable in the same scope as the functions. However, it's not clear if that is possible in Rust on the module level.

A:
In other, higher level languages I have used, I would just have a variable in the same scope as the functions.

You can use something similar in Rust but it's syntactically more complicated: you need to create a global for your cache using lazy_static or once_cell for instance.
The cache will need to be thread-safe though, so either a regular map sitting behind a Mutex or RwLock, or some sort of concurrent map.
Although given you only have 64 inputs, you could just precompute the entire thing and return precomputed values directly.

A: The cached crate comes in handy:
use cached::proc_macro::cached;

#[cached]
fn total_for_square(s: u32) -> u64 {
    if s == 64 {
        return u64::MAX;
    }

    2u64.pow(s) - 1
}

Indeed, you only need to write two lines, and the crate will take care of everything.  Internally, the cached values are stored in a hash map.
(Note that u64::max_value() has been superseded by u64::MAX)

Side note: in this specific case, the simplest solution is probably to modify square so that it returns s * s.


text:
Q: Not fire queued jobs with no channels? Is there any way to suppress queued jobs from firing off a broadcast event when the channel is empty? Basically what I am noticing is that while no socket pushes will go off if broadcastOn returns [] it will still make a queued job. Is there any way to have queued jobs only get created when broadcastOn returns an array with at least one element?

A: You'll have to do a little manual subclassing to make this work. The queued job is created in the broadcastEvent method of Illuminate\Events\Dispatcher.
protected function broadcastEvent($event)
{
    if ($this->queueResolver) {
        $connection = $event instanceof ShouldBroadcastNow ? 'sync' : null;

        $queue = method_exists($event, 'onQueue') ? $event->onQueue() : null;

        $this->resolveQueue()->connection($connection)->pushOn($queue, 'Illuminate\Broadcasting\BroadcastEvent', [
            'event' => serialize(clone $event),
        ]);
    }
}

You can add a check here to only push the job onto the queue if $event->broadcastOn returns an array with at least one element.
Once subclassed, you will need to use the new dispatcher to fire the events. You can create a new service provider for this and bind it to the container. I'm not sure if you can overwrite the existing events instance created in Illuminate\Events\EventServiceProvider, but you can definitely create a new one.
public function register()
{
    $this->app->singleton('events-custom', function ($app) {
        return (new App\Provides\CustomDispatcher($app))->setQueueResolver(function () use ($app) {
            return $app->make('Illuminate\Contracts\Queue\Factory');
        });
    });
}

If you are using the Events facade, be sure to also update your config file to point to a new Facade that returns the key to your new CustomDispatcher. Unfortunately, the events() helper function will still return the original Dispatcher. I don't believe that can be overwritten. If you can somehow overwrite the existing events key set by Illuminate\Events\EventServiceProvider though, then you're all set.

A: It seems in Laravel 5.4 you can now add a new method on events, broadcastWhen. All that needs to be done:
public function broadcastOn() {
    return [];
}

public function broadcastWith() {
   return count($this->broadcastOn()) > 0;
}

You can read more about how broadcastWhen is handled in the source code.

Check if event should be broadcasted by condition.


text:
Q: Getting the correct headers automatically given a filetype in PHP Sorry - looks like this is a duplicate of: How to get the content-type of a file in PHP?

A few times I've run into situations where I'd like to be able to include a file using PHP, and depending on the included filetype, output the appropriate headers. In the past I've just done this manually by switch/casing the extension type with the appropriate content-type headers.
However what I'm wondering now is if there's a function like
get_header($filename)

or maybe
get_contenttype($extension)

For example if I wanted to route all requests for media through a php file, I could use that function to output the correct headers.

A: finfo_file might help. There some more info on this question.


text:
Q: How to reliably obtain, programmatically, the executable path corresponding to a process with a given pid, under linux? What is the best approach to implement filter by process name from a user mode application under Linux?
All methods that I am aware of rely on reading proc_fs:

*

*readlink on /proc/$PID/exe

*reading from /proc/$PID/cmdline, until the first null character

*parsing the Name field in /proc/$PID/status
The first method seems to be reliable, if combined with method #3. Unfortunately, the path gets a (deleted) suffix when the executable is removed from the system, which can be a suffix part of an ordinary file name. The filter can not be robust if such names are used for executables.
The second method is dependent on the shell that started the process. This is just the first (position 0) argument of the process, and IIUC, shells are free to set it in anyway they see fit. For example, bash prepends dash to login shells.
The third method relies on a name truncated to 15 characters, as taken directly from a field in the kernel task_struct. This is obviously not robust, but is the only name available for kernel processes, and thus must supplement the other two. (Apparently, if the name contains non-ASCII characters they appear as escape sequences, so the method is reliable in this way.)
Altogether, I can not come up with a robust, shell-independent way, to support filtering by process executable name (or ideally path), allowing arbitrary file names. I will probably resort to the leading command parameter in cmdline, since it may fit my purposes, but I would like to make sure that I understand the available options.
Note: Security, although an issue, is a different point. Checking the user identity of the process will be done if security is necessary. But what I desire for the name filter is just correctness. The aim is to implement a quality of service or per-process configuration reliably, and process name filtering will be involved.

A: The robustness of the first method (readlink /proc/$PID/exe) can be improved by doing a pair of stats on the link itself and the result of the readlink. If you get a matching st_dev and st_ino, they're the same file. If you don't get a match, or get an ENOENT, then check for " (deleted)" at the end of the string, strip it off and try again. Repeat until you get a match or run out of " (deleted)" instances.
If you don't get a match after all that, the executable file really has been deleted. (And you haven't really specified what you want to do in that case - which you should definitely think about. When you are insisting on robustness, you can't just ignore the fact that deleted files can be in use!)
There's still a race condition between the stats, so you might want to open both files and fstat them instead. Then if you get a device+inode match, you have a file descriptor that can be used with confidence that it actually belongs to the file that was exec'd in the target process, not some other file with a similar name.
The next difficulty is if the process itself goes away during your test, and the PID gets reused. If you care about that, you can read the process start time from /proc/$PID/stat at the beginning and end of the operation, to make sure you were dealing with the same process the whole way through. (Also, there's a way to keep a process from going away: attach to it as a debugger with ptrace.)
Then there's the question fo what you want to do if the process execs a different program while you're looking at it. /proc/$PID/exe will change. If it happens right after your final consistency check, you will return a value that was correct, but isn't anymore. You can't do much about that, except the ptrace, and that's more intrusive than you probably want.


text:
Q: How to have my two divs next to each other? This is my code and i just can't get the #eateries div and the #categories div to be next to eachother. I stripped down the webpage to only include relevant pieces. I've only had a couple months to learn html.
edit:
I tryed implementing what has been suggested but in the full site it doesn't work is there something different that needs to be done?

@charset "UTF-8";
 #contacts {
  background-color: #424040;
  text-align: center;
  padding-top: 5px;
  padding-bottom: 5px;
}
p {} #content {
  border: medium solid #FE4B3B;
  background-color: #FFFFFF;
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
}
#navigation {
  text-align: center;
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
  font-size: large;
  background-color: #424040;
  height: 60px;
  border-left-color: #FE4B3B;
  border-right-color: #FE4B3B;
  border-top-color: #FE4B3B;
  border-left-style: solid;
  border-right-style: solid;
  border-top-style: solid;
  border-left-width: medium;
  border-right-width: medium;
  border-top-width: medium;
}
#header #navigation ul li {
  list-style: none;
  display: inline;
}
#header {
  background-image: url(Assets/boston.jpeg);
  background-repeat: no-repeat;
  height: auto;
}
#options {} #contact_info {
  color: #FFFFFF;
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
}
#header_image {
  background-repeat: no-repeat;
  height: 250px;
  border-left-color: #FE4B3B;
  border-right-color: #FE4B3B;
  border-top-color: #FE4B3B;
  border-left-style: solid;
  border-right-style: solid;
  border-top-style: solid;
  border-left-width: medium;
  border-right-width: medium;
  border-top-width: medium;
}
.Nav_button a {
  background-color: #424040;
  margin-right: 50px;
  padding-right: 5px;
  padding-top: 5px;
  padding-left: 5px;
  padding-bottom: 5px;
  color: #FFFFFF;
  text-decoration: none;
  font-size: large;
}
#Title_image {
  text-align: center;
  width: 100%;
  height: 100%;
}
.Nav_button a:hover {
  color: #FFFFFF;
  background-color: #000000;
}
body {
  margin: 0 auto 0 auto;
  width: 1300px;
  background-image: url(Assets/Boston_Back_Bay_reflection.jpg);
}
#garden_img {
  width: 400px;
  height: auto;
}
#header_text {
  font-size: xx-large;
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
  font-weight: bold;
  color: #0C0D12;
  text-align: center;
}
.text_content {
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
  font-size: large;
}
#hall_img {
  width: 200px;
  height: auto;
  text-align: center;
}
.picture_div {
  width: auto;
  margin: auto;
  height: auto;
  text-align: center;
}
.navbar-fixed {
  top: 0;
  z-index: 100;
  position: fixed;
  width: 1294px;
  border: 0px;
  margin: 0 auto 0 auto;
}
#const:hover {
  background-color: #FE4B3B;
}
#mfa:hover {
  background-color: #FE4B3B;
}
#nathist:hover {
  background-color: #FE4B3B;
}
#mos:hover {
  background-color: #FE4B3B;
}
#categories {
  border: medium solid #000000;
  width: 200px;
}
#placestoeat {} #eateries {
  border: medium solid #000000;
  width: 400px;
}
<!doctype html>

  <meta charset="UTF-8">
  <title>index</title>
  <link href="styles.css" rel="stylesheet" type="text/css">

Home

History

Restraunts

Outdoors

Maps

Places To Eat

Boston is home to many restraunts, cafes, food vendors, and diners. There is a huge variety of cultural foods in boston such as Italian, French, Mediteranean, South American, German. Since boston is right on the water you will find many seafood focused
      restraunts with large selections of food. There is a huge variety of prices in boston with upscale fancy restraunts as well as small places offering up affordable food guaranteed to make your mouth water. Take a look at our long list of places to
      eat!

Seafood

Italian

French

Mediteranean

German

South American

American

Email: gerrickslonder037@email.com Phone: 123-456-7890 Mailing Address: 123 Fake Street, PA

A: Use display: inline-block for #categories and #eateries divs.

#categories {
 border: medium solid #000000;
 width: 200px;
    display: inline-block;

}
#placestoeat {
    display: block;
}

#eateries {
    display: inline-block;
 border: medium solid #000000;
 width: 400px;

}

Places To Eat

Boston is home to many restraunts, cafes, food vendors, and diners. There is a huge variety of cultural foods in boston such as Italian, French, Mediteranean, South American, German. Since boston is right on the water you will find many seafood  focused restraunts with large selections of food. There is a huge variety of prices in boston with upscale fancy restraunts as well as small places offering up affordable food guaranteed to make your mouth water. Take a look at our long list of places to eat!

Seafood

Italian

French

Mediteranean

German

South American

American

Email: gerrickslonder037@email.com Phone: 123-456-7890 Mailing Address: 123 Fake Street, PA

A:

#categories {
 border: medium solid #000000;
 width: 200px;
    display : inline-block;

}
#placestoeat {
 display: block;
}

#eateries {
 border: medium solid #000000;
 width: 400px;
    display : inline-block;
}

Places To Eat

Boston is home to many restraunts, cafes, food vendors, and diners. There is a huge variety of cultural foods in boston such as Italian, French, Mediteranean, South American, German. Since boston is right on the water you will find many seafood  focused restraunts with large selections of food. There is a huge variety of prices in boston with upscale fancy restraunts as well as small places offering up affordable food guaranteed to make your mouth water. Take a look at our long list of places to eat!

Seafood

Italian

French

Mediteranean

German

South American

American

Email: gerrickslonder037@email.com Phone: 123-456-7890 Mailing Address: 123 Fake Street, PA

A: #categories {
    border: medium solid #000000;
    width: 25%;
    float: left;
}
#eateries {
    border: medium solid #000000;
    width: 70%;
    float: left;
}

#contacts {
    display: inline-block;
}

Places To Eat

Boston is home to many restraunts, cafes, food vendors, and diners. There is a huge variety of cultural foods in boston such as Italian, French, Mediteranean, South American, German. Since boston is right on the water you will find many seafood  focused restraunts with large selections of food. There is a huge variety of prices in boston with upscale fancy restraunts as well as small places offering up affordable food guaranteed to make your mouth water. Take a look at our long list of places to eat!

Seafood

Italian

French

Mediteranean

German

South American

American

Email: gerrickslonder037@email.com Phone: 123-456-7890 Mailing Address: 123 Fake Street, PA

quick and dirty solution, should work  for this simple situation...

A: Add float: left or display: inline-block on #placestoeat > div
If have used display: inline-block on the example below:

#categories {
  border: medium solid #000000;
  width: 200px;
}

#placestoeat {
  display: block;
}

#placestoeat > div {
  display: inline-block;
}

#eateries {
  border: medium solid #000000;
  width: 300px;
  float:left;
}

Places To Eat

Boston is home to many restraunts, cafes, food vendors, and diners. There is a huge variety of cultural foods in boston such as Italian, French, Mediteranean, South American, German. Since boston is right on the water you will find many seafood focused
    restraunts with large selections of food. There is a huge variety of prices in boston with upscale fancy restraunts as well as small places offering up affordable food guaranteed to make your mouth water. Take a look at our long list of places to
    eat!

Seafood

Italian

French

Mediteranean

German

South American

American

Email: gerrickslonder037@email.com Phone: 123-456-7890 Mailing Address: 123 Fake Street, PA

A: @Eric Londern, just write css rule #placestoeat div { display: inline-block}


text:
Q: For loop integer AND string variable? Can someone tell me how I can change the values of x and y to '*' and '.'? Making the variables string doesn't help because I need N to be an integer as it is user input, and will conflict in loop.
import java.util.Scanner;

public class nvalue
{
public static void main(String[] args)
{
    int x, y, N;
    Scanner keyboard = new Scanner(System.in);
    System.out.print("Enter Value of N : ");
    N = keyboard.nextInt();

    for(x=2; x<=N; x++)
    {
        for(y=1; y<=5; y++)
        {
         System.out.println(y +" * "+ x + " = " + (x*y));
        }
        System.out.println("----------------------");
    }
}
}

Basically I need it to output this:
* * * * * *
. * * * * *
. . * * * *
. . . * * *
. . . . * *
. . . . . *

A: You can do :
for (int i = 0; i < N; ++i) {
  for (int j = 0; j < i; ++j) {
     System.out.print(".");
  }

  for (int j = i; j < N; ++j) {
     System.out.print("*");
  }

  System.out.println(); // Next line
}

Note the use of print and not println for printing without a line break.

A: for(x=0; x<N; x++){
    String ln = "";
    for(y=0; y<5; y++){
       ln += (y < x) ? "* " : ". ";
    }
    System.out.println(ln);
}

A: for(x=1; x<=N; x++)
{
    for(y=1; y<=5; y++)
    {
      if (y >= x) {
         System.out.print(" * ");
      } else {
         System.out.print(" . ");
      }
    }
    System.out.println();
}

A: public static void main(String[] args) {
    int x, y, N;
    Scanner keyboard = new Scanner(System.in);
    System.out.println("Enter Value of N : ");
    N = keyboard.nextInt();

    for(x=0; x<N; x++)
    {
        for(y=0; y<N; y++)
        {
            if (y >= x)    {
                System.out.print(" * ");
            }
            else {
                System.out.print(" . ");
            }
        }
        System.out.println();
    }

}

A: You can try this.
for(int x=0; x<N; x++){
  for(int y=0; y<N;y++){
   if(y<x){
      System.out.print(".");
    }else{
      System.out.print("*");
    }
   }
   System.out.println();
}

Damn, someone posted the same answer above me.


text:
Q: parse variables file in Python I wish to send Python script a definition file (with key and value pairs) which it should translate into an html table using templates.
For example:
say that the definitions file  def.txt contain the following lines:
build number: 5513
build date: 12/09/2011

I want it to be able to read it easily (iterate on each line) and create a data table.
something like:
<tbl>

  build number 	  5515

  build date 	  12/09/2011

</tbl>

I want it to work for N lines in definition file. I don't care about the definition file format...
Any suggestions?
Thanks.
Or.

A: >>> l = [i.split(": ") for i in open("def.txt")] #read and parse the input
>>> l #here is what we got
[['build number', '5513'], ['build date', '12/09/2011']]
>>> with open("out.txt", "w") as f: #open the out file
...    f.write("<tbl>\n")
...    for k, v in l: #iterate and write
...         f.write("
{}	{}
\n".format(k, v))
...    f.write("</tbl>\n")

A: config module


text:
Q: Circular Dependencies in XML file my android xml layout file keeps on Exception raised during rendering: Circular dependencies cannot exist in RelativeLayout
Exception details are logged in Window > Show View > Error Log
I cant figure out why? here is my code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.amandhapola.ribbit.LoginActivity"
    android:background="@drawable/background_fill" >

     <ImageView
         android:id="@+id/backgroundImage"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"
         android:scaleType="fitStart"
         android:src="@drawable/background"
         android:contentDescription="@string/content_desc_background"/>
       <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_above="@+id/subtitle"
        android:layout_centerHorizontal="true"
        android:textSize="60sp"
        android:layout_marginTop="32dp"
        android:textColor="@android:color/white"
        android:textStyle="bold"
        android:text="@string/app_name" />

     <TextView
        android:id="@+id/subtitle"
        android:layout_centerHorizontal="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/title"
        android:layout_above="@+id/usernameField"
        android:textSize="13sp"
        android:textColor="@android:color/white"
        android:textStyle="bold"
        android:text="@string/subtitle"/>

       <EditText
        android:id="@+id/usernameField"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/passwordField"
        android:layout_below="@+id/subtitle"
        android:layout_alignParentLeft="true"
        android:ems="10"
        android:hint="@string/username_hint" />

        <EditText
        android:id="@+id/passwordField"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/usernameField"
        android:layout_above="@+id/loginButton"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="43dp"
        android:ems="10"
        android:hint="@string/password_hint"
        android:inputType="textPassword" />

        <Button
        android:id="@+id/loginButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/passwordField"
        android:layout_above="@+id/signUpText"
        android:layout_alignParentLeft="true"
        android:text="@string/login_button_label" />

    <TextView
        android:id="@+id/signUpText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
       android:layout_marginTop="12dp"
        android:layout_centerHorizontal="true"
        android:textColor="@android:color/white"
       android:layout_below="@+id/loginButton"
        android:text="@string/sign_up_text" />

</RelativeLayout>

A: You have defined your title to be above your subtitle, and your subtitle to be below your title:
<TextView android:id="@+id/title" ... android:layout_above="@+id/subtitle" ... />
<TextView android:id="@+id/subtitle" ... android:layout_below="@+id/title" ... />

That's a circular reference: To position title, Android first needs to determine the position of subtitle. However, to position subtitle, it needs to determine the position of title first.
You need to make sure that Android can position your elements without getting into a depencendy loop. For example, positioning the title at the top, and then positioning the subtitle below the title would be fine.


text:
Q: Show that $x_1^2+x_2^2+(x_1-x_2)^3 \rightarrow \min$ has no solution How can I show (preferably using the Bolzano-Weierstrass theorem), that $x_1^2+x_2^2+(x_1-x_2)^3 \rightarrow \min$ has no solution? I can see that it is true, but how can I show it?

A: Change variables to $\xi := x_1-x_2$ and $\eta :=x_1+x_2$. Write the poly in these terms, and it will become clear it has no lower bound.

A: I don't really understand the Bolzano-Weierstrass connection, but fixing $x_1 = 0$ (say) reduces the function to $x_2^2(1-x_2),$ which is obviously going to $-\infty$ as $x_2$ goes to $\infty.$


text:
Q: Installing SymmetricDS service I have 2 machines. M1 is installed SymmetricDS on "C:\Program Files (x86)\Webstercare\MyFolder\Tools\Synchronisation". I shared this folder to everyone with full permission.
In M2 I map network drive the folder as a drive.
I run InstallSymmetricDS.bat then SymmetricDS is installed in M2 as well. But I can't start the service.
Can everyone tell me how to start the service? I would like to use as the same folder for as the same configuration. So I just edit one time for both M1 and M2.
In Regedit:
ImagePath: "java" -Djava.io.tmpdir="Z:\tmp" -jar "Z:\lib\symmetric-wrapper.jar" init "Z:\conf\sym_service.conf"
I also installed Java 32 bit.
Thanks a lot for your help!

A: I don't see how the service control manager running as SYSTEM is going to see Z:\ as a valid path.  It's just not possible what you are trying to do.  You would need to mount the file system at a much lower level (like what a SAN and Windows Clustering does) so that each windows machine see's it as a local disk.


text:
Q: Cannot get the codes right in php I have designed a chess board using loops in php. The board is all well, but I cannot get the chess pieces in right position, because of loops, same picture repeats in every squares of the chess boards. Can anyone suggest me what should I change. Please refer to my codes below.

<?php
   echo"
SAJID Chess Board
";

   echo"
";

   //Nested For loop starts
   for($i=1; $i<5; $i++)//this is the iteration construct starts from here
{
   echo"
";
   for ($j=7; $j>=0; $j--) // For loop for 1st row

   {
   if(($j%2)==0){
   echo"";
   echo""; //here is the problem, the image of king throughout the chess board
   }
  else{
  echo"";
  }

  echo"	";
  }//for loop ends
  echo "
";

  echo "
";

  for($j=0; $j<8; $j++){ // For loop for 2nd row

  if(($j%2)==0){
  echo"";
  }
  else{
  echo"";
  }

  echo"	";
  }//for loop ends

  echo "
";

  }//nested for loop ends

echo "
";

?>

A: You need to redesign your loops, for the correct coordinates,
Here is an example ive wrote for you

        <?php

          // Format $pictures[Row][Column];
          $pictures = array();

          //Row 1
          $pictures[1][1] = "Castle";
          $pictures[1][2] = "Horse";
          $pictures[1][3] = "Bishop";
          $pictures[1][4] = "King";

          //Row 2
           $pictures[2][1] = "Pawn";
           $pictures[2][2] = "Pawn";
           $pictures[2][3] = "Pawn";
           $pictures[2][4] = "Pawn";
           $pictures[2][5] = "Pawn";
           $pictures[2][6] = "Pawn";
           $pictures[2][7] = "Pawn";
           $pictures[2][8] = "Pawn";

            echo"
SAJID Chess Board
";
            echo"
";

            for($i = 1; $i <= 8; $i++)
            {
                echo "
";
                for($j = 1; $j <=8; $j++)
                {
                    if( ($i+$j)%2 )
                    {
                        echo"";

                    }
                    else
                    {
                        echo"";
                    }

                    if(isset($pictures[$i][$j]))
                        echo $pictures[$i][$j];

                    echo "	";
                }
                echo "
";
            }

            echo "
";

        ?>


text:
Q: SimpleRepository and booleans with SubSonic I am trying to add a boolean column in SubSonic 3.0.0.3 and without this column the code works fine but as soon as I had a bool variable into my model this fails with the following error:
The name "False" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
Anyonw know if this should be supported and if it is what I may be doing wrong:
Data Object Class:
public class Desk
{
    [SubSonicPrimaryKey]
    public int DeskId { get; set; }

    public string DeskName { get; set; }

    public string SAPCode { get; set; }

    public int LocationId { get; set; }

    public bool Active { get; set; }

}

Use of Class:
var d = new Desk();
            d.DeskName = "Test";
            d.SAPCode = "12345";
            d.LocationId = 2;
            d.Active = true;

            var repository = new SimpleRepository("SubSonicTesting", SimpleRepositoryOptions.RunMigrations);
            repository.Add(d);

A: I have faced the exact same issue (version 3.0.0.3) when I added a bool property named "IsAccountOwner". The problem seems to be with migrations because when I deleted the table, SubSonic re-created it correctly with the added column.
I'm using SQL Server 2008 Express, in case that matters. The error is related to a malformed query perhaps?


text:
Q: Why are extension methods used extensively in LINQ, despite the framework's guidelines? The Extension Methods documentation says:

For a class library that you implemented, you shouldn't use extension
  methods to avoid incrementing the version number of an assembly.

So why has the .NET team used them extensively in Enumerable and Queryable?
In search of a reason I checked out my copy of C# In Depth, where I came away with a feeling that extension methods are used because:

*

*You can chain them together in a readable way

*You can bring them in and out of scope

Is this correct or are the .NET team flying in the face of their own documentation? Are there other reasons that justify their use?

A: That's not the entire sentence.  What is actually written is this:

For a class library that you implemented, you shouldn't use extension methods to avoid incrementing the version number of an assembly. If you want to add significant functionality to a library for which you own the source code, you should follow the standard .NET Framework guidelines for assembly versioning.

(emphasis added)
What this means is that you should avoid just adding extension methods to a class when you're adding large amounts of functionality, just for the sake of not incrementing the assembly version.  If you're going to introduce large amounts of new functionality, you should really do it in a new version of that assembly.

A: It's because LINQ works on IEnumerable, not any specific implementation of a collection. If they were part of the definition of IEnumerable, you would have to implement your own methods, and it would needlessly bloat the interface. By putting LINQ into extension methods, you can implement IEnumerable on any class you create yourself, and the existing LINQ methods will work on it.


text:
Q: Object Oriented jQuery: bind a button for click event and call back the new obj as being clicked I would like to new obj
e.g. newForm = new MyForm(...);
Then I would like to bind the click event to a button.
How can I call back the "newForm" from the click event?

Sample code (Fail to bind):
var MyForm = function(data, targetUrl, targetObj, preload, callback){
    this.data = data;
    this.preload = preload;
    this.targetUrl = targetUrl;
    this.targetObj = targetObj;
    this.callback = callback;
    this.this = this;
    this.bind();
};

MyForm.prototype.submit = function(){
    this.preload;
    $.ajax({
      type: "POST",
      url: this.targetUrl,
      data: this.data
    }).done(function(responseData) {
        if(typeof this.callback === 'function'){
            return this.callback(responseData);
        }
    });
};

MyForm.prototype.bind = function(newTargetObj){
    if(typeof newTargetObj === 'object'){
        this.targetObj = newTargetObj;
    }

    this.targetObj.click(this.clickEvent());
}

MyForm.prototype.clickEvent = function(){
        console.log(this);
        console.log(this.targetForm);
//        this.targetForm.submit();
        alert('click!');
};

A: I'm not able to test this at the moment but I believe you should be able to pass an object into the event you have hooked up for the click event. This is shown below.
MyForm.prototype.bind = function(newTargetObj){
    if(typeof newTargetObj === 'object'){
        this.targetObj = newTargetObj;
    }

    this.targetObj.click(this.clickEvent(this.targetObj));
}

MyForm.prototype.clickEvent = function(sender){
        console.log(this);
        console.log(this.targetForm);
//        this.targetForm.submit();
        alert('click!');
};


text:
Q: Using Multiple Function to get an output in a single Line I am trying to create output from my Bash script which includes hostname, SSH protocol, and root login information.
I would like to do it using Bash functions. I have a .sh file but it does not work.  Where is the problem in this code?
Server Version: Red Hat 7
The expected output would be:
xyz|hostname|Protocol X|Root Access Denied

I would like to begin the output with "xyz" in order to later parse my output.
#!/bin/bash

host(){
         local tmpfile=$(mktemp)
         hostname > "$tmpfile"
         printf '%s' "$tmpfile"
}

protocol(){
        local infile="$1"

        cat /etc/ssh/sshd_config  | grep Protocol
}

rootlogin(){
        local infile="$1"

        if [[ $(sudo cat /etc/ssh/sshd_config | grep -i "PermitRootLogin yes" | grep -v "#PermitRootLogin yes") = "PermitRootLogin yes" ]];
                echo  $host
        else
                echo "Root Access Denied"
        fi
}
}

tmpfile=$( host )
{
        host "$tmpfile"
        protocol "$tmpfile"
        rootlogin "$tmpfile"
} > fonk.out

rm -f "$tmpfile"

A: The poor indentation and layout of your script muddles the question, but the basic answer is
printf '%s|%s|%s|%s\n' "$(field1)" "$(field2)" "$(field3") "$(field4)"

Refactored into this, and with indentation etc cleaned up, your script becomes
#!/bin/bash

host(){
    hostname
}

protocol(){
    # avoid useless use of cat; get rid of unused parameter
    # ... do you need sudo here too?
    grep Protocol /etc/ssh/sshd_config
}

rootlogin(){
    # straighten out massive spaghetti pretzel; remove unused parameter
    # ... can you avoid sudo cat here?
    if sudo cat /etc/ssh/sshd_config |
        grep -v "#PermitRootLogin yes" |
        grep -i -q "PermitRootLogin yes"
    then
        # Fix quoting
        echo "$host"
    else
        echo "Root Access Denied"
    fi
 }

printf '%s|%s|%s|%s\n' "$1" "$(host)" "$(protocol)" "$(rootlogin)" >fonk.out

The last line is somewhat speculative; your current script doesn't seem to print the first field at all, and it's not clear what it's supposed to contain.
This no longer uses a temporary file, but one antipattern in your attempt was to create the temp file in an unrelated function. When you really do need a temp file, it would probably be a good idea to create it separately, then use it as a parameter everywhere.  Like
tmp=$(mktemp) || exit
# arrange for temp file to be removed in case of errors or signals, too
trap 'rm -f "$tmp"' EXIT
trap 'exit' ERROR HUP QUIT TRAP TERM

function1 "$tmp"
function2 "$tmp"
: etc


text:
Q: Multicore processing in R on windows 7 x64 New to R, I need to use the spatstat package to run some point pattern analyses.
Since my data are quite large and spatstat only uses one core out of the four cores available, I was wondering if I could speed things up multithreading the process.
I found this paper, which presents a package that transformed spatstat's functions for use in a parallel environment. According to the paper, I first need to install Rmpi.
The first time, I had a problem with a missing msmpi.dll. After installing a windows package, I was able to load Rmpi into R.
At this point, I think there is something wrong somewhere, because it doesn't seem that Rmpi works correctly:
> library(Rmpi)
> mpi.spawn.Rslaves(nslaves=4)
Erreur dans mpi.comm.spawn(slave = system.file("Rslaves64.cmd", package = "Rmpi"),  :
Other MPI error, error stack:
MPI_Comm_spawn(106)..........: MPI_Comm_spawn(cmd="C:/Users/ddeltenre/Documents/R/win-
library/3.0/Rmpi/Rslaves64.cmd", argv=0x000000000EC70C90, maxprocs=4, MPI_INFO_NULL,
root=0, MPI_COMM_SELF, intercomm=0x000000000F44A878, errors=0x000000000E729AA8) failed
MPID_Comm_spawn_multiple(314): Function not implemented

My questions are thus the following:

*

*The most important, even if I manage to make Rmpi work, does it mean that parspatstat
will Work, or would it be easier to do all that stuff on a Linux
install?

*Is Rmpi really designed to allow multicore processing?

*Is it possible to use Rmpi on windows 7 x64?

*Before installing the windows package, I followed this tutorial
(www.stats.uwo.ca/faculty/yu/Rmpi/windows.htm), thinking that was
the way to go. Though I removed MPICH (I didn't solve the issue),
can it have an effect on Rmpi's behavior?
Many thanks for your help

A: It appears that MPICH2 is the MPI distribution recommended for Windows, so I would also recommend that you use it. It may not be easy to get everything installed and working, but it will be much easier to get help from others if you use the recommended distribution.
I expect that you could get "parspatstat" working on Windows using MPICH2/Rmpi and that it will allow you to use multiple cores, but it may be hard. If you have a choice, I would definitely recommend using Linux, especially a Debian-based distribution, which has excellent support for Rmpi.
Although MPI is primarily geared towards use on multiple machines, such as clusters, most implementations have support for running on multicore machines. Still, it may be worth testing "parspatstat" on a Linux machine before you spend a long time trying to get it working on Windows.


text:
Q: php process http authentication I have a server that prompts for http authentication before it gives personalized json results.
How can I write a php script that runs on another box to prompt for the auth, pass it along and pull the results?

A: Just create a HTML form with login and password inputs, and then retrieve data with cURL.
$curl = curl_init('http://example.com/api');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERPWD, $_POST['login'].':'.$_POST['password']);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);

$response = curl_exec($curl);

If you want to be more "interactive" try to add some AJAX stuff.

A: make sure this is going with SSL. otherwise, anyone could hijack your unencrypted credential.

A: Change USER:PASS to be the username and password, and change the URL to your URL. The return value is in $jsonStr.
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");

// Puts return in variable rather than the browser
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "USER:PASS");

// grab URL and pass it to the variable
$jsonStr = curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);


text:
Q: how to get non-overlapping distinct intervals in postgresql table? the table has user sessions, i need distinct non overlapping sessions printed.
CREATE TABLE SESSIONS(
            id serial NOT NULL PRIMARY KEY,
            ctn INT NOT NULL,
            day DATE NOT NULL,
            f_time TIME(0) NOT NULL,
            l_time TIME(0) NOT  NULL
        );
    INSERT INTO SESSIONS(id, ctn, day, f_time, l_time)
    VALUES
    (1, 707, '2019-06-18', '10:48:25', '10:56:17'),
    (2, 707, '2019-06-18', '10:48:33', '10:56:17'),
    (3, 707, '2019-06-18', '10:53:17', '11:00:49'),
    (4, 707, '2019-06-18', '10:54:31', '10:57:37'),
    (5, 707, '2019-06-18', '11:03:59', '11:10:39'),
    (6, 707, '2019-06-18', '11:04:41', '11:08:02'),
    (7, 707, '2019-06-18', '11:11:04', '11:19:39');

sql fiddle
My table looks like this:
id  ctn day         f_time      l_time
1   707 2019-06-18  10:48:25    10:56:17
2   707 2019-06-18  10:48:33    10:56:17
3   707 2019-06-18  10:53:17    11:00:49
4   707 2019-06-18  10:54:31    10:57:37
5   707 2019-06-18  11:03:59    11:10:39
6   707 2019-06-18  11:04:41    11:08:02
7   707 2019-06-18  11:11:04    11:19:39

Now i need distinct non-overlapping user sessions, so it should give me
1.  start_time: 10:48:25  end_time: 11:00:49  duration: 12min,24 sec
2.  start_time: 11:03:59  end_time: 11:10:39  duration: 6min,40 sec
3.  start_time: 11:11:04  end_time: 11:19:33  duration: 8min,29 sec

A: This is a gaps-and-islands problem. Here is an approach using window functions:
select
    ctn,
    min(f_ts) start_ts,
    max(l_ts) end_ts,
    max(l_ts) - min(f_ts) duration
from (
    select
        s.*,
        count(*) filter(where f_ts > lag_l_ts) over(partition by ctn order by f_ts) grp
    from (
        select
            s.*,
            lag(l_ts) over(partition by ctn order by f_ts) lag_l_ts
        from (
            select
                s.*,
                (day + l_time)::timestamp l_ts,
                (day + f_time)::timestamp f_ts
            from sessions s
        ) s
    ) s
) s
group by ctn, grp
order by ctn, start_ts

The query works as follows:

*

*first we rebuild proper timestamps from the date and time parts: storing data this way makes it uneasy to manipulate it (and it does not allow sessions to spread over different days)

*one data is normalized, we use lag() to get the end timestamp of the "previous" row

*we can then build groups of "adjacent" records: every time the start timestamp is greater than the previous end timestamp, a new group starts

*the final step is aggregation
Demo on DB Fiddle:

ctn | start_ts            | end_ts              | duration
--: | :------------------ | :------------------ | :-------
707 | 2019-06-18 10:48:25 | 2019-06-18 11:00:49 | 00:12:24
707 | 2019-06-18 11:03:59 | 2019-06-18 11:10:39 | 00:06:40
707 | 2019-06-18 11:11:04 | 2019-06-18 11:19:39 | 00:08:35


text:
Q: suppress keyboard in iphone UiWebViews I have an app that uses UiWebViews, and I need to not show the keyboard for a text field within such a view.  I provide my own buttons that insert the limited sorts of text the field allows, but I also need to allow pasting (I will filter what gets pasted) and adjusting the cursor position.  Any way to do this?

A: if you just want the textField do normal things except the showing keyboard action, you could subclass UITextField and overwrite the touchesBegan/Moved/Ended, just call super touchesBegan/Moved/Ended and add additional code which would hide the keyboard, if you have a reference to the keyboard ( you may figure it out urself how-to ), call the method : [keyboard resignFirstResponder], you may try to Category the UITextField class so you would have the reference to the keyboard ( if it's private ) - but not recommended because categorying may break our project design, but if you just need it for the only purpose, give it a try. Hope it helps.

A: It looks like this can't be done, I've researched it further and that's pretty clear.  I don't want to accept a wrong answer, so I figured I'd just answer this myself and say: can't be done.


text:
Q: Unable to use keytar in main.js of electron project I keep getting this error:
 error  in ./node_modules/keytar/build/Release/keytar.node

Module parse failed: Unexpected character '�' (1:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)

 @ ./node_modules/keytar/lib/keytar.js 1:13-52
 @ ./src/background.js
 @ multi ./src/background.js

I have background.js set as the main electron file in package.json because I'm using vue/vuetify with it which uses a main.js file as well.
{
  "name": "project",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "electron:build": "vue-cli-service electron:build",
    "electron:serve": "vue-cli-service electron:serve",
    "postinstall": "electron-builder install-app-deps",
    "postuninstall": "electron-builder install-app-deps"
  },
  "main": "background.js",    // <------------------ see right here
  "dependencies": {
    "axios": "^0.19.0",
    "core-js": "^3.4.3",
    "jwt-decode": "^2.2.0",
    "keytar": "^5.0.0",
    "request": "^2.88.0",
    "vue": "^2.6.10",
    "vue-router": "^3.1.3",
    "vuetify": "^2.1.0",
    "vuex": "^3.1.2"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^4.1.0",
    "@vue/cli-plugin-eslint": "^4.1.0",
    "@vue/cli-service": "^4.1.0",
    "babel-eslint": "^10.0.3",
    "electron": "^7.1.3",
    "eslint": "^5.16.0",
    "eslint-plugin-vue": "^5.0.0",
    "node-loader": "^0.6.0",
    "sass": "^1.19.0",
    "sass-loader": "^8.0.0",
    "vue-cli-plugin-electron-builder": "^1.4.3",
    "vue-cli-plugin-vuetify": "^2.0.2",
    "vue-template-compiler": "^2.6.10",
    "vuetify-loader": "^1.3.0"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "rules": {},
    "parserOptions": {
      "parser": "babel-eslint"
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ]
}

Searching, it seems this happens when keytar is used in a renderer process.  But background.js isn't a renderer process.  Or am I missing something?  I am completely new to electron.

A: I needed to mark keytar as external (as mentioned at https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/guide.html#native-modules)
// vue.config.js
module.exports = {
  pluginOptions: {
    electronBuilder: {
      // List native deps here if they don't work
      externals: ['keytar']
    }
  }
}

Once I did that it worked properly.

A: Run appropriate loader (source).
yarn add node-loader -D

// vue.config.js
configureWebpack: {
    devtool: 'source-map',
    module: {
      rules: [
        { test: /\.node$/, loader: 'node-loader' }
      ]
    }
  }


text:
Q: D2L / BrightSpace - Create user within a course and within a section and assign user a role So I am trying to Enroll a user in a section for a particular org unit (Course)
This all works fine and I can add them into the section etc using:
POST /d2l/api/lp/(version)/(orgUnitId)/sections/(sectionId)/enrollments/¶

But the issue is, I am only able to POST one attribute, user ID. I need to be able to post the RoleID as well so I can specify whether they are a student or staff, as it assigned them 'teacher'.
Is there a way to do this / a different approach?
Cheers,
Alex.

A: Enrollments in Sections and Groups are effectively treated as special sub-components of a Course Offering; the APIs that let you enroll a user into a Section or Group therefore assume that you want to take the user/role enrolled in the parent course offering and "assign" them to this Group or that Section (with the same enrollment role).
You are correct that if you want to have them enrolled with a different role, you should instead use the general enrollments API (assuming you have permissions; your calling user context may well have permissions to assign a user to a group or a section, but not to enroll them generally).


text:
Q: Visual Studio linker error if function's argument constness is different in definition and declaration This code is valid:
// .h
void foo(int);
// .cpp
void foo(int const){} // note `const` argument

Even more it's considered a good practice and clang sanitizer reports about const in definition.
But this function produces linker error error LNK2019: unresolved external symbol in vs2017:
// .h
bool check_required_device_extensions(VkPhysicalDevice physicalDevice, std::vector<char const *> const & requiredExtensions);
// .cpp
using namespace std;
bool check_required_device_extensions(VkPhysicalDevice const physicalDevice, vector<char const *> const & requiredExtensions){}

Here's another example:
// .h
VkInstanceCreateInfo get_instance_create_info(std::vector<char const *> const * extensions, std::vector<char const *> const * layers);
// .cpp
VkInstanceCreateInfo get_instance_create_info(std::vector<char const *> const * const extensions, std::vector<char const *> const * const layers)

gcc compiles it without a problem.
What's strange is that this function works:
// .h
MaybeSurfaceFormat get_device_surface_format(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface);
// .cpp
MaybeSurfaceFormat get_device_surface_format(VkPhysicalDevice const physicalDevice, VkSurfaceKHR const surface){}

Why? Is there a special linker flag or another workaround?
Update - minimal example.
// a.h
#pragma once
void foo(int);
void bar(int*); // #1 - add const to fix the error

// foobar.cpp
// #2 - or include a.h to fix the error
void foo(int const){}
void bar(int* const){}

// main.cpp
#include "a.h"
int main()
{
    foo(0); // ok
    bar(nullptr); // error LNK2019: unresolved external symbol

    return 0;
}

Win10, vs2017 Version 15.6.4 (and earlier)


text:
Q: Padding expands the size of a  So, i have a padding-top to define some space between the <textarea> and the borders of the table.

I need to add a small margin between the <textarea> and the table borders. When i don't add the padding-top the <textarea> goes slightly up, like this: http://i.imgur.com/Pq2NINo.png

As you can see, the <textarea> is slightly above the position of the content of the other rows.

When i add padding-top:10px; in my CSS file, the <textarea> expands, instead of doing what i pretend, like this: http://i.imgur.com/ittVeUl.png

I need the <textarea> to be centered like the textboxes in the other table rows.

Here is my html code:

echo "
<input type='checkbox' name='checkbox[]' id='checkbox[]' value='".$ppid_reg."' />
<input type='text' class='datepicker' name='ppdata[]' value='$ppdata' placeholder='dd-mm-aaaa'>	";
echo "<input type='text' name='ppemp[]' value='$ppemp'>	";
echo "<textarea rows='1' cols='20' name='ppdesc[]' form='form'>$ppdesc</textarea>";

(nevermind the variables and the echo's)

I removed and changed the number of rows and cols of the textarea, but the results were the same.

CSS:

th, td {padding:0px 10px 10px; text-align:center; }

Thanks in advance.

A: Try:
vertical-align: middle;

text-align is only concerned with horizontal alignment.

A: If you want to put space ABOVE the textarea you have to use margin
textarea {margin: 10px 0 0;}

If you are using a table and want to center the textarea vertically, you can you vertical-align
th, td{vertical-align: middle;}

Keep in mind that you need a table-cell for vertical-align to work

A: Just add the float left to the input and textarea. Then u can adjust the line-height to make their height same.
HTML

       <input type="text" />
       <input type="text" />
       <textarea rows='1' cols='20'></textarea>

CSS
table{border:1px solid;border-collapse:collapse;}
td{padding:5px;border:1px solid;}
textarea{resize:none;padding:0 5px;line-height:32px;float:left;border:1px #ddd    solid;height:30px;}
input{padding:0 5px;line-height:30px;float:left;border:1px #ddd solid;height:30px;}

Fiddle link is below
http://jsfiddle.net/murli2308/wye2s/2/


text:
Q: Functoriality for compactifications of locally symmetric spaces Let $X$ be a symmetric space associated to an algebraic group $G$ defined over $\mathbb{Q}$ and $G(\mathbb{R})$ acts on $X$ from the left. Let $\Gamma \subset G(\mathbb{Q})$ be an arithmetic subgroup which we assume to be torsion-free(even neat). Then the locally symmetric space $X_{\Gamma} \mathrel{:=} \Gamma \backslash X$ is known to have several Satake compactifications depending on the rank of the group $G$. It is my understanding that the Satake compactification come from a geometrically rational representation often denoted by $\tau$. Note that this representation may itself not be rational. I am mostly interested in the following two types of compactifications.

*

*When the representation $\tau$ is generic and $\operatorname{\mathbb{Q}-rank}(G) = \operatorname{\mathbb{R}-rank}(G)$, then the associated Satake compactification is same as the rBS (reductive Borel–Serre) compactification.

*When the symmetric space is Hermitian and the associated locally symmetric space admits a minimal Satake compactification or Satake–Baily–Borel compactification.
Let us mention for clarity what we mean by "functoriality of rBS or minimal compactification". Let $H$ be an algebraic group defined over $\mathbb{Q}$ and $\varphi : H \rightarrow G$ be a morphism of groups with finite kernel(may even assume $\varphi$ is injective). Associated to this morphism, we get a map of symmetric spaces $X_H \rightarrow X$, where $X_H$ is a symmetric space associated to the group $H$. Let $\Gamma_H \mathrel{:=} \varphi^{-1}(\Gamma)$ and $X_{\Gamma_H} \mathrel{:=} \Gamma_H \backslash X_H$. We get a map of locally symmetric spaces $\varphi : X_{\Gamma_H} \rightarrow X_{\Gamma}$ induced by $\varphi$. We say a compactification is functorial if such a  map $\varphi$ extends to a continuous map among the compactifications.
It is known that when $X_{\Gamma_H}$ and $X_{\Gamma}$ are Hermitian locally symmetric space then minimal compactification exists and it is functorial. It is also known that the rBS compactification is not functorial in general. I have the following questions.
Q1. Are there instances when rBS compactification is functorial? For example when $G$ and $H$ are of $\mathbb{Q}$-rank 1? or when $\operatorname{\mathbb{Q}-rank}(H) = \operatorname{\mathbb{Q}-rank}(G)$ and the root datum with respect to the maximal $\mathbb{Q}$-split tori are the same? or some other instance?
Q2. What is known about the functoriality of other Satake compactifications?
Q3. Let us denote by $\hat{X}$, a uniform way of compactifying locally symmetric spaces for example the ones described in 1 or 2. What can be said about the closure $\overline{\varphi{X_{\Gamma_H}}} \subset \hat{X}$? How is it related to $\hat{X_{\Gamma_H}}$? This is motivated by a remark in the book "Compactifications of symmetric and locally symmetric spaces" by A. Borel and L. Ji.
Q4. The rBS is not functorial but (perhaps surprisingly) the cohomology is in certain cases. This follows from one of the main results of A. Nair which describes a deRham model for the cohomology of rBS compactification of a Hermitian locally symmetric space. This appeared in "Weighted cohomology of arithmetic groups" by A. Nair. I wonder if there are ways to produce maps on the level of homotopy groups as well?
I apologize in advance for asking too many questions under the disguise of one. But they all seemed to belong together. I would appreciate any response towards a better understanding of any of these questions.


text:
Q: SQL Server Convert datetime to mm/dd/yyyy format but still be a datetime datatype I would like to keep my dates as datetime datatype by also be in MM/DD/YYYY format. I know how to do this by converting them to a varchar, but want to keep the datetime format. Can anyone help with this?
Currently I have tried
SELECT CONVERT(datetime, GETDATE(), 101)

which is not working...

A: There is a basic misunderstanding in your question. Repeat after me: Datetimes don't have a format.
It helps if you think of them as just an array of seven integers (year, month, day, hours, minutes, seconds, milliseconds) with certain constraints. That's not in any way accurate, but it helps to get the notion out of your head that something akin to 12/31/2015 is stored in your database.
Datetimes only get a format when (implicitly or explicitly) being converted to strings. You already know how to set the format when explicitly converting to string, now all that is left to do is to find the implicit conversion that is obviously bothering you and replace it with an explicit one.

A: Date and datetime Values stored in the database are NOT in any recognizable format. They are stored in binary (1s and 0s) in a proprietary format where one part represents the number of days since a defined reference date (1 jan 1900) in SQL server). and the other part represents the time portion of the value. (in sql server, its the number of 1/300ths of a second since midnight.)
ALL formatting of dates and date times, no matter what format you wish for, is done only after the values have been extracted from the database, before you see them on screen, in whatever application you are using.
You can find all the formats that the SQL Server convert function can use on this MSDN Convert Link


text:
Q: Is there a way to poll() and be awaken when a new bind + listen happens on a Linux system? I've seen so many things that can be poll()'ed on that I'm wondering whether that would include the detection of another process binding and then listening to a port.
poll() is most often used on a set of sockets to know when they gets new content (read) or have space in its output buffer (write).
Now we have:

*

*signalfd() to convert a Unix signal to a file descriptor and poll() on that.

*pipe() to listen to inter-process pipes (very similar to sockets)

*timerfd_create() to create a timer that will wake you up through your poll()

*eventfd() to create an event notification file descriptor (for example, to send events between threads)

*special socket to listen to the kernel creating new processes (fork()) and killing processes (exit())
struct sockaddr_nl sa_nl;
int s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);

sa_nl.nl_family = AF_NETLINK;
sa_nl.nl_groups = CN_IDX_PROC;
sa_nl.nl_pid = getpid();
bind(nl_sock, (struct sockaddr *) &sa_nl, sizeof(sa_nl));
...

Now... Is there a way to know when a process calls the listen() function?
In other words, know as soon as a new bound address and port appear in the output of netstat with the LISTEN keyword attached to it such as:
Proto   Local Address         Foreign Address       State
tcp     0.0.0.0:25            0.0.0.0:*             LISTEN

Obviously, I know that the connection will appear in /proc/net/tcp which I can scan (just like netstat does,) but that would require polling (opposed to sleeping with a call to poll()) with an interval timer. I know how to do that, but I would prefer to be able to know that the port is open without having to read a file over and over again...


text:
Q: Find a $2 \times 2$ matrix $A$ with each main diagonal entries $0$, and with $A^2 = -I.$ I'm not sure how to tackle this problem.
I'm not certain what is meant by "each main diagonal entries 0". Does this mean:
$$A=\begin{pmatrix} 1 & 0 \\ 0 & 1 \\ \end{pmatrix}$$
I'm also not sure what it means by $A^2 = -I$?
From Wikipedia, I gathered that the identity matrix is an $n \times n$ square matrix with one's on the main diagonal and zero's elsewhere. What would would be considered the main diagonal?

A: The main diagonal runs from the top left to the bottom right, so you're looking for a matrix like
$$A = \left[ \begin{array}{cc} 0 & a \\ b & 0 \end{array}\right]$$
such that $A^2 = -I$. This can be done by trial and error, or by writing a system of a few equations after finding what $A^2$ is.

A: Since $A^2=-I$ the only possibilities for the eigenvalues of $A$ are $\pm i$.
Now, if your matrix is real, the characteristic polynomial is a monic quadratic polynomial with $i$ or $-i$ as a root. The only possibility is $x^2+1$.
Therefore $\det(A)=1$.
Conversely, if $\det(A)=1$, since $tr(A)=0$ the characteristic polynomial of $A$ is $x^2+1$.  Then $A$ has two eigenvalues $\pm i$ with algebraic multiplicuty $1$. Hence $A$ is diagonalisable and then
$$A=P \left[ \begin{array}{cc} i & 0 \\ 0 & -i \end{array}\right] P^{-1} \Rightarrow A^2=P(-I)P^{-1}=-I$$
So the problem reduces to finding all such matrices of determinant 1. It is easy to find ALL matrices which satisfy the given condition of determinant 1, and these are all solutions to the question.

A: From the relation given that $A^2 =-I$
We get an annihilating polynomial $p(x)=x^2+1$
And clearly the minimal polynomial of A divides this and hence the roots are $i$ and $-i$.
Just choose any a,b such that their product is $-1$ and you'll get your matrix..the prod has to be  $-1$ since the product of the eigenvalues is the determinant and for your matrix this comes out to be $-ab$. So $$-ab=1$$


text:
Q: Op Amp LM324 Different Source + and -, + and Ground I have an issue with Op Amp LM324.
First, I supply with this, and everything is work like op amp. I have output twice than input.

simulate this circuit – Schematic created using CircuitLab
But, when I use different source, the output is equal with input.

simulate this circuit
Then I change the schematic. Output has twice than input.

simulate this circuit
Does Op Amp need supply + and -, and cannot be + and ground? Thanks for your answer.
EDIT QUESTION AFTER 4 HOURS
Sorry it was my mistake. I didnot draw correctly.
Oke, let me clear this. This wiring has output 6 Volt.

simulate this circuit
Why this one has output that same with input?

simulate this circuit

A:
Does an op-amp need a bipolar supply? And why can't it operate from a single supply?

This is entirely dependent on the op-amp in question and the circuit you are using it in. There are op-amps that require a bipolar supply, and op-amps that are happy with a single supply. The LM324 is designed to swing within ~5mV of ground and within ~1.5V of the positive supply rail (when powered by reasonable voltages, say, 5V-30V).
All of your circuits are rather strange. While it initially appears that you have connected feedback paths, this is not true. The first two circuits simply have a 100Ω output load resistor, and no feedback.  If yo draw the schematics in a more usual manner, this should become immediately apparent. Because of this, you are operating the op-amp as a comparator (the + input is 3V higher than the - input), and you should not trust the simulator. Intuitively, when the + input is significantly higher than the - input, the output will go to the rail. However, with a 100Ω load, the op-amp may not be able to source enough current. The point is, your output voltage is unpredictable, and the simulator may not accurately model this behaviour.
The third circuit is clearly marked incorrectly, you have marked a grounded node as "6V". Additionally, you are shorting the output of the op-amp to ground, which will make the op-amp sad.

Regarding your edited circuits: the first circuit is a non-inverting op-amp with an input of 3V and a gain of 2. Hence, the output is 6V.
The second circuit is still problematic; as I have already explained above, the op-amp is trying to drive the output to the + rail, but the load is large enough that the output is drawn down. Your label is misleading, it is very likely not 3V. It might be close to 3V, but the output is unpredictable and may depend on idiosyncrasies of the simulator model.


text:
Q: PySpark add a column to a DataFrame from a list of strings I'm looking for a way to add a new column in a Spark DataFrames from a list of strings, in just one simple line.
Given :
rdd = sc.parallelize([((u'2016-10-19', u'2016-293'), 40020),
                      ((u'2016-10-19', u'2016-293'), 143938),
                      ((u'2016-10-19', u'2016-293'), 135891225.0)
                     ])

This is my code to structure my rdd and get a Dataframe :
def structurate_CohortPeriod_metrics_by_OrderPeriod(line):

    ((OrderDate, OrderPeriod), metrics) = line
    metrics = str(metrics)

    return OrderDate, OrderPeriod, metrics

(rdd
 .map(structurate_CohortPeriod_metrics_by_OrderPeriod)
 .toDF(['OrderDate', 'OrderPeriod', 'MetricValue'])
 .show())

Result :
+----------+-----------+-----------+
| OrderDate|OrderPeriod|MetricValue|
+----------+-----------+-----------+
|2016-10-19|   2016-293|      40020|
|2016-10-19|   2016-293|     143938|
|2016-10-19|   2016-293|135891225.0|
+----------+-----------+-----------+

I want to add a new column to precise the metric's name. This is what I've done :
def structurate_CohortPeriod_metrics_by_OrderPeriod(line):

    (((OrderDate, OrderPeriod), metrics), index) = line
    metrics = str(metrics)

    return OrderDate, OrderPeriod, metrics, index

df1 = (rdd
 .zipWithIndex()
 .map(structurate_CohortPeriod_metrics_by_OrderPeriod)
 .toDF(['OrderDate', 'OrderPeriod', 'MetricValue', 'index']))

Then
from pyspark.sql.types import StructType, StructField, StringType

df2 = sqlContext.createDataFrame(sc.parallelize([('0', 'UsersNb'),
                                                 ('1', 'VideosNb'),
                                                 ('2', 'VideosDuration')]),
                                 StructType([StructField('index', StringType()),
                                             StructField('MetricName', StringType())]))

df2.show()

+-----+--------------+
|index|    MetricName|
+-----+--------------+
|    0|       UsersNb|
|    1|      VideosNb|
|    2|VideosDuration|
+-----+--------------+

And finally :
(df1
 .join(df2, df1.index == df2.index)
 .drop(df2.index)
 .select('index', 'OrderDate', 'OrderPeriod', 'MetricName', 'MetricValue')
 .show())

+-----+----------+-----------+--------------+-----------+
|index| OrderDate|OrderPeriod|    MetricName|MetricValue|
+-----+----------+-----------+--------------+-----------+
|    0|2016-10-19|   2016-293|      VideosNb|     143938|
|    1|2016-10-19|   2016-293|       UsersNb|      40020|
|    2|2016-10-19|   2016-293|VideosDuration|135891225.0|
+-----+----------+-----------+--------------+-----------+

This is my expected output, but this method takes considerably longer. I want to do this in just one or two lines.. Something like for exemple the lit method :
from pyspark.sql.functions import lit

df1.withColumn('MetricName', lit('my_string'))

But I need of course to put 3 different strings : 'VideosNb', 'UsersNb' and 'VideosDuration'.
Ideas ? Thank you very much !


text:
Q: Spinner in fragments pop up delayed I created some fragments in an Activity class as tabs where you can switch through and inside these I have various Spinner. The data I'm getting from a SQL-database with JSONParser and the Spinner gets created in the fragment classes as follow:

spinnerMaterial = (Spinner) view.findViewById(R.id.Spinner_material);

        List<String> lables_material = new ArrayList<String>();

        for (int i = 0; i < materialList.size(); i++) {
            lables_material.add(materialList.get(i).getMaterial());
        }

        // Creating adapter for spinner
        ArrayAdapter<String> spinnerAdapter_material = new ArrayAdapter<String>(getActivity(),
                android.R.layout.simple_spinner_item, lables_material);

        // Drop down layout style - list view with radio button
        spinnerAdapter_material
                .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        // attaching data adapter to spinner
        spinnerMaterial.setAdapter(spinnerAdapter_material);

        // spinner item select listener
        spinnerMaterial.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> adapterView, View view,
                                       int position, long id) {
                Object item = adapterView.getItemAtPosition(position);
            }

            @Override
            public void onNothingSelected(AdapterView<?> adapterView) {
                // TODO Auto-generated method stub

            }
        });

Actually everything is working. I'm getting all the data and the Spinner are poping up. BUT not in a direct way. So I need to switch between the tabs (fragments) and then go back that the Spinner is showing the data. Strange fact is that when I try to debug and go over some breakpoints the Spinner pops up immediately (without switching tabs).
Do you have an idea what the problem could be?


text:
Q: Display picklist values in AuraComponents depending on user's Language? I'd like to display values from a picklist in the users language,
What is the best way to do it, working on a LtngComponent ?
I can get the language by userInfo.getLanguage() but I'm lost when it comes to the displaying part : do I have to code in the controller a method to ask for the userInfo.getLanguage(), and display the traduction ?
Is there an easyer way ?
For the moment, the query is :
SELECT TypeLibelle__c, Status FROM Task

An exemple :

The Apex controller's method begin like this :

The activity class could have Events or Tasks attributes (two constructors), public Activity(Task t) { ...} and public Activity(Event ev) {...}

The picklist values have translations already.
Any help would be appreciate,
Thanks !!

A: You can use toLabel for this purpose:
SELECT toLabel(TypeLibelle__c), toLabel(Status) FROM Task

Alternatively, if you were to call describe calls, you could get the api value and label. This would be the preferred method.


text:
Q: How to Exit a For Loop in MoveIt I am setting up my first real task using Moveit as we just purchased it to replace a home-grown file mover.
I am running a for loop that will pick up 24 files but if one fails, it currently continues on and picks up the rest. If the final file succeeds (even if previous files failed), the error code = 0 and it sends the success email message to the client. What I want is for the for each loop to end if one file fails and then the error code != 0 and the error email will be sent instead. I can put the error email in the for loop and send that but I don't want the success message to send until all 24 files have been copied and the client only wants one success message rather than one for each file.
But I can't figure out how to make the for loop end or, alternatively, to accumulate the error codes so that I can check to see if the value of the sum is greater than 0 to determine which email to send.
I've tried the manual and can't figure it out, I think I need to use a script  (MOVE it uses vbscript) but again I can't figure out how to write one that does what I need. I have tried Google but can't find any good examples of scripting for tasks we want to do in Moveit and I don't know vbscript at all.

A: This is an advanced task that you are talking about.
First, all of the files are downloaded prior to entering the loop.  You cannot stop downloading...
The logic will kick in after the files are downloaded.
You cannot exit the loop, but you can stop further actions.  It sounds like you have an if block checking "File Error Code" which will just tell you the result of the last file process/upload.  You can embed a second if statement to also check "Task Error Code" to action based on overall success/failure.
From my experience however I would recommend to use a couple of traditional tasks with conditional (success/failure) next actions...download one file at a time (via advanced options - download limits) and repetitively call the same task.  You can also pass a parameter between the tasks containing the current number of files transferred.

A: Use Exit For (surprise!) to exit a For loop. Use Boolean Operators to accumulate True/False|Success/Failure values.


text:
Q: Winapi - How to achieve equivalent of LWA_COLORKEY for MS Edge browser My goal is to pick a color that will be transparent on the Microsoft Edge browser (i.e. so we can see the windows behind where that color occurs in Edge). I was able to achieve what I want on Mathematica windows in the past with the following lines of Python code:
win32gui.SetWindowLong(hwnd,win32con.GWL_EXSTYLE,
                       win32gui.GetWindowLong(hwnd,win32con.GWL_EXSTYLE) | win32con.WS_EX_LAYERED)
winxpgui.SetLayeredWindowAttributes(hwnd,win32api.RGB(*transparentColor),50,win32con.LWA_COLORKEY)

where hwnd is the window's handle and transparentColor is the RGB values for the desired color. Now I'm experimenting with Jupyter and wanted to do the same to Edge since Jupyter runs from a browser, but the above is pretty much ignored on Edge (depending on the color, some parts of the menu may become transparent, but not the body of the window). My research so far leads me to believe that this is because Edge (or any other modern browser) does not use GDI and ignores the LWA_COLORKEY request. I tried using LWA_ALPHA instead of LWA_COLORKEY and that does work (makes the whole window semi-transparent), but this is not the effect I'm looking for. I get the same results if I use win32gui.SetLayeredWindowAttributes.
Is it possible in any way for an external application to achieve the intent of the code above for the Edge browser application? From Rita Han's research, in her answer and comments, it is clearly possible, since it works for her. The question is why doesn't it work on my systems (I've tried on two computers).
Updated following a request for more information:
My version of Edge was 44.18362.449.0 but I have now updated it to 81.0.416.72 with the same results. The screen capture below shows two windows, the one on the left is MS Paint where I created an image called "almostBlack_010000.png" and the one on the right is Edge displaying the same image. I have set WS_EX_LAYERED and LWA_COLORKEY on both of these windows using the code above, using color (1,0,0) as the key (i.e. very dark red). As you can see, the Paint window shows my desktop through the "black" rectangle, whereas Edge does not.

A few additional notes:

*

*I have also tried the with Internet Explorer and Chrome with the same negative results.

*The transparent area on MS Paint is click through, i.e. clicking in that area is like clicking on the desktop or any window that happens to be behind.

*When I use the RGB color (0,0,0) as the key, the whole window becomes click through. This happens with Edge as well, but black pixels still do not become transparent.

*The code above would throw a Python traceback if there was an error. For example, if I provide a non-existing window handle in the call to SetLayeredWindowAttributes, I get a traceback with the following last line:
error: (1400, 'SetLayeredWindowAttributes', 'Invalid window handle.')
I have tried with the c++ code below and I am getting the same results, i.e. I can get the selected color to be transparent in Paint and other applications, but not in Edge.
#include <iostream>
#include <Windows.h>

int main(int argc, char *argv[])
{
    HWND hwnd;
    COLORREF color;

    if (argc != 3)
    {
        printf("Usage: %s <HWND> <color>",argv[0]);
    }
    else
    {
        hwnd = (HWND)strtoul(argv[1],NULL,16);
        color = (COLORREF)strtoul(argv[2],NULL,16); // Note: order is reverse than usual. Use 0xBBGGRR
        printf("Setting window %x to %x", (unsigned int)hwnd, (unsigned int)color);

        if (!SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED))
            printf("SetWindowLong error: %d\n", GetLastError());
        if (!SetLayeredWindowAttributes(hwnd,color,50,LWA_COLORKEY))
            printf("SetLayeredWindowsAttributes error: %d\n", GetLastError());
    }

}

I found out that LWA_COLORKEY and LWA_ALPHA can be ORed, in which case both the alpha and colorkey arguments of SetLayeredWindowAttributes can be used simultaneously. I can, therefore, see on the same Edge window that the overall alpha effect is visible, but that the transparency for the key color is not visible.

A: I follow your steps, create a black image using MS Paint and run the following code for MS Paint and Edge, both work for me. Make sure you use the right target window handle and add error check for ensuring functions execute successfully.
HWND hwnd = (HWND)0x00070948; // The window handle I found via Spy++ for testing purpose.

if (!SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED))
    printf("SetWindowLong error: %d\n", GetLastError());
if (!SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), 50, LWA_COLORKEY))
    printf("SetLayeredWindowAttributes error: %d\n", GetLastError());

The black image open with MS Paint:

The black image open with Edge and turns to transparent after executing SetLayeredWindowAttributes. From transparent area you can see my desktop (blue).

A: I finally found a solution, which may or may not have undesirable performance side effects, but I suspect that it is the only way to make it work with the code in my question.
The problem was that Edge was using hardware acceleration by default, and the use of a GPU for rendering either makes it impossible to use my code to cause transparency, or at least makes it too difficult for me to figure out at this time.
Posts such as SetLayeredWindowAttributes to make a window transparent is only working part of the time clued me in to look at hardware acceleration.
Thanks to Rita for at least proving that it could be done, which kept me looking for why it wasn't working on my systems.
I found the way to turn off hardware acceleration in Edge at TenForums.
I would still be interested to know if there are other ways of achieving the same effect, while possibly keeping the hardware acceleration. Comment away!


text:
Q: Factoring algebraic expressions of three variables I want to factor $$bc^2+ab^2+a^2c-b^2c-ac^2-a^2b$$
Using Wolfram, I know it's factored into $$-(a-b)(a-c)(b-c) = (b-a)(a-c)(b-c)$$
However, I don't think I ever got taught how to simplify such expression by hand.

*

*What's the general methodology for this?

*Is there any mental-tool that could be used to do this without the experience to spot factors by sight?

A: This is an expression deduced from a pattern by a circular permutation on the variables; it is more apparent if you rewrite it as:
$$ab^2+bc^2+ca^2- a^2b-b^2c-c^2a$$
To (try to) factor it, a strategy consists in breaking the symmetry between variables, e.g. by replacing $b-a$ with $(b-c)+(c-a)$:
\begin{align*}
ab^2+bc^2+ca^2- a^2b-b^2c-c^2a&= ab(b-a)+bc(c-b)+ca(a-c)\\
&=ab(b-c)+ab(c-a)+bc(c-b)+ca(a-c)\\
&=(ab-bc)(b-c)+(ab-ca)(c-a)\\
&=b(a-c)(b-c)+a(b-c)(c-a)\\
&=(a-b)(b-c)(c-a).
\end{align*}


text:
Q: How to do proper and responsive Image Grid view with display:flex I am pretty confused with display:flex that how to get responsive image grid like this..
Thanks in advance. I have tried many StackOverflow answer but it didn't worked
Right now I have Layout like this...

But i want my layout like this ...

Html code:

CSS code
.makeExploreCenter{
    width: 90%;
    margin: 0 auto;
    display: flex;
    flex-wrap:wrap ;
    justify-content: center; /* align horizontal */
    align-items: center; /* align vertical */
}
.explorePost{
    text-align: center;
    margin: 5px;
    max-width: 300px;
    min-width: 300px;
    align-self: flex-start;
    background: #545454;
}
.explorePost img{
    max-height: 60vh;
    max-width: 100%;
    max-height: 70vh;
}
.likesdetails{
    width: 100%;
    height: 44px;
    background: #FAFAFA;
    margin-top: -3px;
    overflow: auto;
    overflow: hidden;
    display: flex;
}

A: Using a framework like bootstrap will make life easier.
Bootstrap grid system can achieve that easily.

A: You can use the flex-diretion: column property to achieve that effect. See the following example:

.grid{
  display:flex;
  flex-direction: column;
  flex-wrap: wrap;
  width:400px;
  height:400px;
  list-style:none;
}

img{
  width:100px;
  height:auto;
  display:block;
}

codepen

A: You may do it with float
Example:
---- first div ---- ---- second div --- -------AND-----
4G3Y5B6GBY3G7W10P-- ----5G5W5E6B10P10W- ----SO---------
Picture------------ ----Picture-------- -------ON------
------------------- ------------------- --MORE PICTURES
The text related to Content related to- --MORE TEXT----
this--------------- this--------------- ----MORE SPACE-
----Another picture ----Another picture ---Another-----
3B6G6B7GYB3G7W10P-- ----6B7B8B7WBG10YP- ---content-----
Picture------------ ---Picture--------- Modern content-
------------------- ------------------- ---------------
The text related to Related to picture- ---------------
the another picture above-------------- Whatever-------
-- end first div -- -- end second div-- ---------------

Real example:
CSS:
    .grid0, .grid1{float:left;margin-right:30px;}

HTML:

    The text to the picture number 1.0

    The text to the picture number 1.1

    The text to the picture number 2.0

    The text to the picture number 2.1

    The text to the picture number 3.1

    The text to the picture number 3.1


text:
Q: find the last two digits of this number find the last 2 digits of this number
$$19^{{17}^{{{{15}^{{\ddots}}}^{{3}^{1}}}}}$$
PS: the three dots in opposite direction .
NOW I know that I should work on  $mod 100$ but I couldn't work with this very big number !

A: It's quick to compute the order of $19$ mod $100$, since $19^5 \equiv -1 \pmod{100}$.  That is, the order is $10.$  So you really just need to know the last digit of the exponent.
The order of $17$ mod $10$ is $4$.  So we just need to know the residue of the exponent on $17$ modulo $4$.
Well, $15 \equiv -1 \pmod{4}$ and it's raised to an odd power, so the part of the exponent starting with $15$ reduces to $-1 \equiv 3 \pmod{4}$.  So we need $17^3 \equiv (-3)^3 \equiv 3 \pmod{10}$.
That is, the exponent on $19$ is $10k+3$ for some $k$, and $19^{10} \equiv 1 \pmod{100}$, so the answer is $19^3 \equiv 6859 \equiv 59 \pmod{100}$.


text:
Q: Implications of cloning MS Win7 OS SSD What are the implications esp. with resp. to OS / application software licensing, bootability when cloning the MSFT OS (win7pro64) carrying msata SSD onto a larger msata SSD?
Plan is to unbolt the msata SSD from the Win7 PC plug into msata-USB adapter plug that into an auxiliary computer (pref. running linux) using dd command to copy ssd to a file and then the file to the new ssd. Concern is if OS /software licensing is tied to OS boot disk hardware IDs that will not be preserved in the coning process.


text:
Q: AndroidX Camera Core ImageAnalysis.Analyser results in distorted image I am using ImageAnalysis library to extract live previews to then barcode scanning and OCR on.
I'm not having any issues with barcode scanning at all, but OCR is resulting in some weak results. I'm sure this could be from a few reasons. My current attempt at working on the solution is to send the frames to GCP - Storage before I run OCR (or barcode) on the frames in order to look at them in bulk. All of them look very similar:

My best guess is the way i'm processing the frames could be causing the pixels to be organized in the buffer incorrectly (i'm inexperienced to Android - sorry). Meaning rather than organizing 0,0 then 0,1.....it's randomly taking pixels and putting them in random areas. I can't figure out where this is happening though. Once I can look at the image quality, then i'll be able to analyze what the issue is with OCR but this is my current blocker unfortunately.
Extra note: I am uploading the image to GCP - Storage prior to even running OCR, so for the sake of looking at this, we can ignore the OCR statement I made - I just wanted to give some background.
Below is the code where I initiate the camera and analyzer then observe the frames
private void startCamera() {
    //make sure there isn't another camera instance running before starting
    CameraX.unbindAll();

    /* start preview */
    int aspRatioW = txView.getWidth(); //get width of screen
    int aspRatioH = txView.getHeight(); //get height
    Rational asp = new Rational (aspRatioW, aspRatioH); //aspect ratio
    Size screen = new Size(aspRatioW, aspRatioH); //size of the screen

    //config obj for preview/viewfinder thingy.
    PreviewConfig pConfig = new PreviewConfig.Builder().setTargetResolution(screen).build();
    Preview preview = new Preview(pConfig); //lets build it

    preview.setOnPreviewOutputUpdateListener(
            new Preview.OnPreviewOutputUpdateListener() {
                //to update the surface texture we have to destroy it first, then re-add it
                @Override
                public void onUpdated(Preview.PreviewOutput output){
                    ViewGroup parent = (ViewGroup) txView.getParent();
                    parent.removeView(txView);
                    parent.addView(txView, 0);

                    txView.setSurfaceTexture(output.getSurfaceTexture());
                    updateTransform();
                }
            });

    /* image capture */

    //config obj, selected capture mode
    ImageCaptureConfig imgCapConfig = new ImageCaptureConfig.Builder().setCaptureMode(ImageCapture.CaptureMode.MAX_QUALITY)
            .setTargetRotation(getWindowManager().getDefaultDisplay().getRotation()).build();
    final ImageCapture imgCap = new ImageCapture(imgCapConfig);

    findViewById(R.id.imgCapture).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d("image taken", "image taken");
        }
    });

    /* image analyser */

    ImageAnalysisConfig imgAConfig = new ImageAnalysisConfig.Builder().setImageReaderMode(ImageAnalysis.ImageReaderMode.ACQUIRE_LATEST_IMAGE).build();
    ImageAnalysis analysis = new ImageAnalysis(imgAConfig);

    analysis.setAnalyzer(
            Executors.newSingleThreadExecutor(), new ImageAnalysis.Analyzer(){
                @Override
                public void analyze(ImageProxy imageProxy, int degrees){
                    Log.d("analyze", "just analyzing");
                    if (imageProxy == null || imageProxy.getImage() == null) {
                        return;
                    }
                    Image mediaImage = imageProxy.getImage();
                    int rotation = degreesToFirebaseRotation(degrees);
                    FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(toBitmap(mediaImage));

                    if (!isMachineLearning){
                        Log.d("analyze", "isMachineLearning is about to be true");
                        isMachineLearning = true;
                        String haha = MediaStore.Images.Media.insertImage(getContentResolver(), toBitmap(mediaImage), "image" , "theImageDescription");
                        Log.d("uploadingimage: ", haha);
                        extractBarcode(image, toBitmap(mediaImage));
                    }
                }
            });

    //bind to lifecycle:
    CameraX.bindToLifecycle(this, analysis, imgCap, preview);
}

Below is how I structure my detection (pretty straightforward and simple):
FirebaseVisionBarcodeDetectorOptions options = new FirebaseVisionBarcodeDetectorOptions.Builder()
            .setBarcodeFormats(FirebaseVisionBarcode.FORMAT_ALL_FORMATS)
            .build();

FirebaseVisionBarcodeDetector detector = FirebaseVision.getInstance().getVisionBarcodeDetector(options);
detector.detectInImage(firebaseVisionImage)

Finally, when I'm uploading the image to GCP - Storage, this is what it looks like:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos); //bmp being the image that I ran barcode scanning on - as well as OCR
byte[] data = baos.toByteArray();

UploadTask uploadTask = storageRef.putBytes(data);

Thank you all for your kind help (:

A: My problem was that I was trying to convert to a bitmap AFTER barcode scanning. The conversion wasn't properly written but I found a way around without having to write my own bitmap conversion function (though I plan on going back to it as I see myself needing it, and genuine curiosity wants me to figure it out)


text:
Q: Grafana Prometheus "Info" Metric Im wondering if I can use "Info" (https://github.com/prometheus/client_python#info) metric from prometheus data to display info/data in grafana.  I haven't found any meaningful examples online with regards to using that metric.  I've checked the sample dashboards but I don't see any use of that metric.  I've tried sending data to prometheus with the example in the link above:
from prometheus_client import Info, push_to_gateway, CollectorRegistry
regis = CollectorRegistry()
i = Info('my_build_version', 'Description of info')
i.info({'version': '1.2.3', 'buildhost': 'foo@bar'})
push_to_gateway('http://localhost:9091', job="Try_Info_metric", registry=regis)

Anyone have meaningful queries/visual in grafana that I can use?  Im trying to see if I can display this as a table some how.

A: I have a build_info metric exported by all services that looks like this:
build_info{commit_id="42806c2f7f1e17a63d94db9d561d220f53d38ee0",commit_time="2019-11-16 13:53:46Z",build_time="2019-11-16 13:57:20Z",branch="v19.57.x",version="19.57.3",} 1.0

And an availability graph on the service dashboard that shows how many instances are running as a filled area (plus lines for how many are supposed to be running, count(up{job="$job",env="$env"}), and the alerting thresholds; the dashboard defines $job and $env template variables) that looks like this:

So I'm using the version label (and when that's not available, e.g. for test deployments, the Git commit_id) as a label for the running instances count.
label_replace(
label_replace(
label_join(
  sum without(instance) (
    build_info{job="$job",env="$env"}      # Take labels of `build_info`
      * on(job, env, instance) group_left  # Multiplied by `up`, for the actual value
    up{job="$job",env="$env"}),
  "build", "_", "version", "commit_id"),   # Join `version` and `commit_id` label values into label `build`
"build", "$1", "build", "MASTER_(.{7}).+"),# Retain the `commit_id` if `version == "MASTER"
"build", "$1", "build", "(.+)_.+")         # Else, retain `version`

To end up with a metric that looks like:
{branch="v19.57.x",build="19.57.3",build_time="2019-11-16 14:02:38Z",commit_id="42806c2f7f1e17a63d94db9d561d220f53d38ee0",commit_time="2019-11-16 13:53:46Z",env="prod",job="foo-service",version="19.57.3"} 10

And finally, in the query legend format in Grafana I put Version {{ build }}, to end up with Version 19.57.3 in the legend.
On the graph you will notice for example that we went from 19.57.2 to 19.58.3, but then had to roll back to 19.57.3 last evening due to a regression.
Edit Here's the JSON for a table panel that shows pretty much what you want. (It is based on editing in place the https://play.grafana.org/d/000000065/prometheus-console-tables?orgId=1 dashboard you provided.)
{
"datasource": "demo.robustperception.io",
"columns": [
  {
    "text": "Current",
    "value": "current"
  }
],
"editable": true,
"error": false,
"fontSize": "100%",
"gridPos": {
  "h": 7,
  "w": 24,
  "x": 0,
  "y": 7
},
"id": 2,
"isNew": true,
"links": [],
"pageSize": null,
"scroll": true,
"showHeader": true,
"sort": {
  "col": 0,
  "desc": true
},
"styles": [
  {
    "dateFormat": "YYYY-MM-DD HH:mm:ss",
    "pattern": "Time",
    "type": "date"
  },
  {
    "alias": "up",
    "colorMode": null,
    "colors": [
      "rgba(245, 54, 54, 0.9)",
      "rgba(237, 129, 40, 0.89)",
      "rgba(50, 172, 45, 0.97)"
    ],
    "dateFormat": "YYYY-MM-DD HH:mm:ss",
    "decimals": 2,
    "pattern": "Value",
    "thresholds": [],
    "type": "number",
    "unit": "short"
  }
],
"targets": [
  {
    "expr": "sum by (job, instance, version, revision) ({__name__=~\".*_build_info\"})",
    "format": "table",
    "instant": true,
    "intervalFactor": 1,
    "refId": "A",
    "step": 30,
    "target": "",
    "hide": false,
    "legendFormat": ""
  }
],
"title": "Multiple queries merge",
"transform": "table",
"type": "table",
"options": {}
}

A: I realized that looking into pushgateway the info metric is a gauge that has value of 1.
I suppose I can use gauge as a way to build the table with the metrics.