text:
Q: How do you get cycling emojis in the same Embed in a Discord bot? I'm trying to replicate some games from a few discord bots on my server, one of these is slots.
Using node.js for reference.
I've created a clone of it however am missing one element -> Emoji cycling.
Basically in the same Embed message the bot gets each icon to cycle through; like an actual slot machine and then stop on one, then it moves to the next icon and does the same. My bot processes all of this at once so if you type the +slots 1000 it sends a messsage back with the slots already chosen.
How would I get my bot to cycle through emojis then move to the next and do the same before showing all of the information?
Is there some kind of "Wait for seconds" function I'm missing?
I'm assuming the animated icon is just a custom emoji that goes through each of the options, however I'm still unsure how to actually go:
Animated emoji -> 0.5s later pick one -> 0.5s later animate seconds -> 0.5s later pick one etc.
Cheers!

A: So I actually had this same question about this same bot. I was disappointed that there weren't any answers here, but I ended up figuring it out. I initially tried just updating the emoji fields a couple of times a second to make it look like it was cycling. This approach doesn't work, however, because of the 5 "thing" rate limit (you can only do 5 message edits (or things) in 1 second).
What they are actually doing (like you hinted at) is using a custom animated emoji. If you want to use their emoji for the cycle, you'll find it here. You then would need to download this gif and import it into your bot's discord server. You can change the tag for the emoji, which is the :name:, that you use to call it in your server. I called mine :cycle_test:. If then enter the following text into a chat with the bot or on server channel it will give you the unique identifier for the custom emoji: \:cycle_test:. Just right click on your message and click "quote" and it will give you this unique identifier, which looked like this for me: <a:cycle_test:732311116742393856>.
Now that you have this identifier for your animated emoji you can then use it in a discord embed. I was using Python, but the syntax should be quite similar:
embed.add_field(name="Slot results", value="<a:cycle_test:732311116742393856>")

. Then you will want to add code to wait for a second or two and as you go through all of your slot results you will stop them one column at a time. You only do an edit when you want to display a result from a column, which if you give it about a second between each result, it won't hit the limit.
Here's the code I used (again, it is in Python but the logic should help you figure it out)
slot_embed = discord.Embed(title="**Slot Machine**")
slot_embed.add_field(name="Results",value=f"<a:cycle_test:732311116742393856> <a:cycle_test:732311116742393856> <a:cycle_test:732311116742393856>")
sent_embed = await ctx.send(embed=slot_embed)
current_slot_pics = ["<a:cycle_test:732311116742393856>","<a:cycle_test:732311116742393856>","<a:cycle_test:732311116742393856>"]
for i in range(0,len(slot_results_pic)):
    await asyncio.sleep(1.5)
    current_slot_pics[i] = slot_results_pic[i]
    new_slot_embed = None
    new_slot_embed = discord.Embed(title="**Slot Machine**")
    slot_results_str = ""
    for thisSlot in current_slot_pics:
        slot_results_str += f"{thisSlot} "
    new_slot_embed.add_field(name="Results",value=f"{slot_results_str}")
    await sent_embed.edit(embed=new_slot_embed)

Walking through the code, what I'm doing is first setting up a embed to send out that has the animated emoji "cycle_test." I send the embed out and start a for loop for the size of my slot_results_pic variable which is a variable that I setup earlier to determine what slots they picked. (Note, the results of the slots are already known long before it is displayed for the user, all of this code is just gimicky to make it look cooler). I have an array called "current_slot_pics"  which contains the data that is currently being displayed to the user. Notice how they are all set to to the animated emoji at the beginning.
Next, I run a sleep command so that it cycles for 1.5 seconds before showing a result. Now I set the first element of the "current_slot_pics" array to be the first result that the program calculated earlier to be the first slot. After this I make a new embed field and send it as an edit to the original message "slot_embed." The variable i helps keep track of how far we are along in the results and helps me set the proper value of current_slot_pics.
Here is what my finished results looked like:

Final note: if you want to have an animation with the emojis that you have chosen for the slot machine, you would have to make a gif like the one that gambling bot uses and upload it as a custom emoji.


text:
Q: Image data type to byte array According to this tutorial , he have 'image' data type to store file bytes. Then, on download action, he just get that image data type value as byte[], but I have problem in my solution.
I'm using SQL 2008, LinqToSQL.
Row screenshot

C# screenshot

Error message

P.S This is my first time to work with 'save files to db'.

A: As the error clearly states, AttchDB is a Binary, not a byte.
You can call .ToArray() to get the raw byte[] data.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to cut up my dataframe in chunks, but keeping groups together I currently have a massive set of datasets. I have a set for each year in the 2000's. I take a combination of three years and run a code on that to clean.
The problem is that due to the size I can't run my cleaning code on it as my Memory runs out.
I was thinking about splitting the data using something like:
 df.ix[1,N/x]

Where N is the total amount of rows in my dataframe. I think I should replace the dataframe to clear up the memory being used. This does mean I have to load in the dataframe first for each chunk I create.
There are several problems:
How do I get N when N can be different for each year ?
The operation requires that groups of data stay together.
Is there a way to make x vary with the size of N?
Is all of this highly inefficient/is there an efficient inbuild function for this?
Dataframe looks like:
 ID     Location    year  other variables
 1         a        2006
 1         a        2007
 1         b        2006
 1         a        2005
 2         c        2005
 2         c        2007
 3         d        2005

What I need is for all the same ID's to stay together.
The data to be cut in managable chunks, dependent on a yearly changing total amount of data.
In this case it would be:
 ID     Location    year  other variables
 1         a        2006
 1         a        2007
 1         b        2006
 1         a        2005

 ID     Location    year  other variables
 2         c        2005
 2         c        2007
 3         d        2005

The data originates from a csv by year. So all 2005 data comes from 2005csv, 2006 data from 2006csv  etc.
The csv's are loaded into memory and concatenated to form one set of three years.
The individual csv files have the same setup as indicated above. So each observation is stated with an ID, location and year, followed by a lot of other variables.
Running it just on a group by group bases would be a bad idea, as there are thousands, if not millions of these ID's. They can have dozens of locations and a maximum of three years. All of this needs to stay together.
Loops on this many rows take ages in my experience
I was thinking maybe something along the lines of:
create a variable that counts the number of groups
use the maximum of this count variable and divide it by 4 or 5.
cut the data up in chunks this way
Not sure if this would be efficient, even less sure how to execute it.

A: One way to achieve this would be like as follows:
import pandas as pd

# generating random DF
num_rows = 100

locs = list('abcdefghijklmno')

df = pd.DataFrame(
        {'id': np.random.randint(1, 100, num_rows),
         'location': np.random.choice(locs, num_rows),
         'year': np.random.randint(2005, 2007, num_rows)})

df.sort_values('id', inplace=True)

print('**** sorted DF (first 10 rows) ****')
print(df.head(10))

# chopping DF into chunks ...
chunk_size = 5

chunks = [i for i in df.id.unique()[::chunk_size]]

chunk_margins = [(chunks[i-1],chunks[i]) for i in range(1, len(chunks))]

df_chunks = [df.ix[(df.id >= x[0]) & (df.id < x[1])] for x in chunk_margins]

print('**** first chunk ****')
print(df_chunks[0])

Output:
**** sorted DF (first 10 rows) ****
    id location  year
31   2        c  2005
85   2        e  2006
89   2        l  2006
70   2        i  2005
60   4        n  2005
68   7        g  2005
22   7        e  2006
73  10        i  2005
23  10        j  2006
47  16        n  2005

**** first chunk ****
    id location  year
31   2        c  2005
85   2        e  2006
89   2        l  2006
70   2        i  2005
60   4        n  2005
68   7        g  2005
22   7        e  2006
73  10        i  2005
23  10        j  2006
47  16        n  2005
6   16        k  2006
82  16        g  2005

A: Use chunked pandas by importing Blaze.
Instructions from http://blaze.readthedocs.org/en/latest/ooc.html

Naive use of Blaze triggers out-of-core systems automatically when called on large files.
d = Data('my-small-file.csv')
d.my_column.count()  # Uses Pandas

d = Data('my-large-file.csv')
d.my_column.count()  # Uses Chunked Pandas

How does it work?
Blaze breaks up the data resource into a sequence of chunks. It pulls one chunk into memory, operates on it, pulls in the next, etc.. After all chunks are processed it often has to finalize the computation with another operation on the intermediate results.


text:
Q: How to add border with no mask to masked image at Objective-C I have UIImageView with added mask to it's layer. And after that I want to add border to the image. But, looks like mask applying to the border also, because it's changing color (should be strong white, w\o mask).
My code for doing this looking as
// Mask
CALayer *layer = [CALayer layer];
layer.frame = _photo.bounds;
layer.backgroundColor = [UIColor colorWithWhite:0.f alpha:.5f].CGColor;
[_photo.layer setMask:layer];

_photo.layer.cornerRadius = _photo.frame.size.width / 2;
_photo.layer.masksToBounds = YES;
_photo.clipsToBounds = YES;

// Border
_photo.layer.borderColor = [[UIColor whiteColor] CGColor];
_photo.layer.borderWidth = 2.0;

Image w\o mask applied:

Result is next:

How I can add border without changing it's color during mask apply?

A: I suspect you can't (easily) stop the layer's mask from also masking the layer's border. That being the case, I'd suggest creating a second view or layer just for the border, in front of _photo but outside its view hierarchy. You can then give that second layer the same bounds, corner radius and border as _photo's layer without the mask applying to it.


text:
Q: firebase + facebook Open Graph (I am creating a new question cause it will be easy for others to find it)
have got the login to work with firebase. trying to get access to the open graph data on the client side itself.
I have the user access Token thanks to the firebase sdk. Now I have permission to get access to the user likes.
(I have never used FB open graph before and all the examples are done using the FBphp sdk)
            var myDataRef = new Firebase('my firebase');
            var temp;
            var authClient = new FirebaseAuthClient(myDataRef, function(error, user) {
                if (error) {
                    // an error occurred while attempting login
                    console.log('an error occurred:');
                    console.log(error);
                } else if (user) {
                    // user authenticated with Firebase
                    console.log('logged in:');
                    console.log(user.accessToken);
                    temp=user.accessToken;

    /*look here*/   $.getJSON('https://graph.facebook.com/'+ user.id +'/likes?access_token='+temp+'', function(data) {
                    console.log("Data Loaded: " + data);

                 } else {
                       // user is logged out
                       console.log('logged out');
                 }
            });

The request is successful but the data returned is not being displayed, all I am getting is [Object object] in console. Any help will be appreciated

A: It looks like you actually are getting some useful data back, but console.log("Data Loaded: " + data); is converting that data to the string [Object object]
To see the contents of your data, try logging with this instead: console.log(data) or use a breakpoint in your developer tools to inspect it during runtime.

A: you are using json, just use console.log("Data Loaded: " + JSON.stringify(data));


text:
Q: Make container X to wait n seconds untill localstack queues are created I'm trying to create a docker-compose file to run localstack (for sqs), 1 mysql databases and 2 services together.
The problem I'm trying to deal with is that the services starts to build and run before the queues are created (which I don't want).
Is there a way to make the services sleep ? I've tried to use health check but it didn't make a difference.
Here's how the file looks:
version: "3.8"
services:

localstack:
        container_name: "DGT-localstack_main"
        image: localstack/localstack
        ports:
          - "4566:4566"            # LocalStack Gateway
          - "4510-4559:4510-4559"  # external services port range
          - "53:53"                # DNS config (only required for Pro)
          - "53:53/udp"            # DNS config (only required for Pro)
          - "443:443"              # LocalStack HTTPS Gateway (only required for Pro)
        environment:
          - DEBUG=${DEBUG-}
          - PERSISTENCE=${PERSISTENCE-}
          - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR-}
          - LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY-}  # only required for Pro
          - DOCKER_HOST=unix:///var/run/docker.sock
        volumes:
          - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
          - "/var/run/docker.sock:/var/run/docker.sock"
        networks:
          - localstack_network

awslocal_cli:
        image: amazon/aws-cli
        depends_on:
          - localstack
        entrypoint: /bin/sh -c
        networks:
          - localstack_network
        command: >
          '
            echo "########### Creating profile ###########"

            aws configure set aws_access_key_id ignore
            aws configure set aws_secret_access_key ignore
            aws configure set region eu-north-1

            echo "########### Creating SQS ###########"
            aws sqs create-queue --endpoint-url=http://localstack:4566 --queue-name=FIRST_QUEUE
            aws sqs create-queue --endpoint-url=http://localstack:4566 --queue-name=SECOND_QUEUE

            echo "########### Listing SQS ###########"
            aws sqs list-queues --endpoint-url=http://localstack:4566
           '

db:
        container_name: db
        image: mysql:8.0.28
        command: --lower_case_table_names=1
        ports:
          - "3308:3306"
        environment:
          - MYSQL_ROOT_PASSWORD=root
          - MYSQL_DATABASE=maindb
        volumes:
        - ./db_config/core/data:/var/lib/mysql
        networks:
          - localhost_network

api:
    container_name: Api
    image: api:1.0
    build:
      context: blabla
      dockerfile: blabla
    ports:
      - blabla
    env_file: ./Server/common.env
    environment:
      - blabla
    restart: on-failure
    depends_on:
      - core
    networks:
      - localhost_network

core:
        container_name: Core
        image: core:1.0
        build:
          context: blabla
          dockerfile: blabla
        ports:
          - "5115:80"
        env_file: .blabla
        environment:
          - blabla
        restart: on-failure
        depends_on:
          - localstack
          - awslocal_cli
          - db
        networks:
          - localstack_network
          - localhost_network

networks:
      localstack_network:
      localhost_network:

I'm sorry for the bad indentation (they are right indented in my file)

A: Use the depends_on function.
If you want container B to start after container A you would need to create you docker-compose like this
A:
    image: ...
    other_settings: ...

B:
    image: ...
    other_settings: ...
    depends_on: A

This would ensure that container B is only started if container A is already up and running.
If there is a URL to check if the queue is already created you could also try this:
https://docs.docker.com/compose/startup-order/

A: You can try to wrap starting command in script wait-for-it.sh. Complete example is hire: https://docs.docker.com/compose/startup-order/


text:
Q: Make slider full width, but center contents I'm playing about with http://www.slidesjs.com/ slider. Trying to make it full width, but make the current slide (slidescontent) full width, but have a div inside the container (slidescenter) have it's contents stay centered with a width set, this is the code im using:
<!doctype html>

        <title>Title</title>

                    Text 1

                    Text 2

A: I recommend using Cycle. Slidesjs was adding unwanted html... causing some problems
I did a centered slideshow on this site: http://celebrationsnetwork.co.nz
Did it by making the main container set width and centered (using margin)
#slides {
    width: 570px;
    height: 270px;
    margin: 0 auto;
    overflow: hidden;
}

And making the slides set width also:
#slides .slide {
    width: 570px;
    height: 270px;
}

I played around with your problem on Jsfiddle: http://jsfiddle.net/3q8cX/4
Any questions?

A: Without being able to actually use slides.js (as it's referring to a copy on your local machine/server), it's a little hard to tell what's going on.  Have you tried to center .slidescenter the standard way?
.slidescenter {
  width: 990px;
  margin: 0 auto;
}


text:
Q: Javascript - variable visibility Hi I have following code
var idx = 0;
var size = 0;
do {
    response.push({
        key: "data" + idx,
        ajaxOptions: function () {
            var data = this.getPref("groupsCN");
            var items = data.split(';');
            size = items.length;
            idx++;
            alert('inside index: ' + idx + ' < inside length ' + size);
            return {
                url: '/rest/adrestresource/1.0/activedirectory/findgroups&test@lab.local&Bezhesla1&localhost&',
                type: "GET",
                dataType: "xml"
            }
        }
    });
    alert('outside index: ' + idx + ' < outside length ' + size);
} while (idx < size);

The function getPref loads string with some values divided by ;. Main point is to iterate through all this values and do something with them. But following code outputs

outside index: 0 < outside length: 0

so it means that variables idx and size are not modified inside the function. But I don't know why?
I must call this.getPref() inside ajaxOptions -> function, because it doesn't work outside of it (I don't know why, this function is part of Atlassian gadget JavaScript framework)

A: You are not executing a function, you are just assigning anonymous function to an object literal's property ajaxOptions. To execute a function use something like this:
var idx = 0;
var size = 0;
do {
    response.push({
        key: "data" + idx,
        ajaxOptions: (function () {
            var data = this.getPref("groupsCN");
            var items = data.split(';');
            size = items.length;
            idx++;
            alert('inside index: ' + idx + ' < inside length ' + size);
            return {
                url: '/rest/adrestresource/1.0/activedirectory/findgroups&test@lab.local&Bezhesla1&localhost&',
                type: "GET",
                dataType: "xml"
            }
        })()
    });
    alert('outside index: ' + idx + ' < outside length ' + size);
} while (idx < size);

A: Try like this :
var idx = 0; var size = 0; var self = this;

and
var data = function () { return self.getPref("groupsCN"); };


text:
Q: Get x-path of radio button need to find the regular expression for the below label
<div class="field radio-container valid" data-editable="true" data-type="RadioGroup" data-mandatory="true" name="gender">
  <label>
    <input type="radio" value="1" name="gender">
      gender
    </input>
  </label>
</div>

Not working when tried the following using xpath checker: name(//label/input[text() = \"" + label + "\"]/@name)

A: This should work for you:
//input[text()=\"gender\"]

A: click > xpath=(//input[@type='checkbox'])[position()=1]

to select the first radio button in your page
click > xpath=(//input[@type='checkbox'])[position()=2]

to select another one and so on
it will help you a lot to select random and any radio button


text:
Q: Point slope form in C# Im trying to find the ortho-centre of a triangle using the tutorial found here. All is fine up to the point where I have to calculate the equation of the line. For the equation of the line I should end up with 2 equations that should look something like x + 9y = 45 and 2x - y = 12 as per the example.
This is where I get stuck. How can I express this programatically as 2 of the variables for each equation are unknown?
And then I am to use the 2 equations above to solve for x and y. Again, how can I do this programatically? I know how to do it on paper but I cant seem to get my head around how to do this in C# (XNA)
Does anyone have any solutions?


text:
Q: Assigning base data from derived class with move produces an error I am new to the new feature of C++ such as moving semantic (moving constructor and moving assignment operator). The code below produces an error in IDE as follows.

How to fix it?
#include <iostream>
using namespace std;

class HeavyData {};

class Base
{
protected:
    HeavyData data;

public:
    Base(HeavyData data) :data{ data } {}
    Base(Base const&& src) :data{ move(src.data) } {}

    Base& operator = (Base const&& rhs)
    {
        this->data = move(rhs.data);
        return *this;
    }
};

class  Derived : public Base
{
private:
    HeavyData extra;
public:
    Derived(HeavyData data, HeavyData extra) :
        extra{ extra }, Base(data) {}
    Derived(Derived const&& src) :
        extra{ move(src.extra) }, data{ move(src.data) }  {}

    Derived& operator = (Derived const&& rhs)
    {
        this->data = move(rhs.data);
        this->extra = move(rhs.extra);
        return *this;
    }
};
void main()
{
    HeavyData data, extra;
    Derived d1(data, extra);
    Derived d2 = move(d1);
}

A: Don't initialize base-class data in the derived class's constructor. Invoke the base class constructor first, then your derived class's data.
Derived(Derived const &&src) :
  Base(std::move(src)), extra{std::move(src.extra)} ()

A: tl;dr;You need to call base class constructor.
Since base class should be initialized before derived class, base class members should be initialized during base class constuction. You cannot affect base class members creation from the derived class, but you can call base class constructor like this:
 Derived(Derived const&& src) :
        Base(move(src.data)),
        extra{ move(src.extra) }{}

Edit: delegating -> base class

A: You need:
Derived(Derived const&& src) :
    Base(std::move(src.data)),
    extra{ move(src.extra) }
{}


text:
Q: Plotly Polar Plot with Color as Hover Info I am trying to visulalize a heat distribution across a radial object using plotly.
import numpy as np
import plotly.graph_objects as go
import plotly.express as px

r, theta = np.mgrid[0.1:1:20j, 0:360:2j]
# %%
T = np.linspace(130,100,20)
color = np.ones(r.shape) * T[:,np.newaxis]
fig = go.Figure(go.Barpolar(
    r=r.ravel(),
    theta=theta.ravel(),
    marker_color=color.ravel(),
    marker={"showscale": True,
            "colorscale": px.colors.sequential.RdBu_r,},
    opacity=1))
margin = 10
fig.update_layout(
    showlegend=True,
    polar=dict(
        radialaxis_layer="above traces",
        angularaxis_direction="clockwise",
        angularaxis_color="white",
        angularaxis_showgrid=False,
        radialaxis_showgrid=False,
        radialaxis_showline=False,
        radialaxis_tickvals=[],  # Radii ticks
        bargap=0,  # Ensure cells will touch
        hole=0.0,  # Center gap
    ),
)
fig.show()

But now the hover_info shows only the info on radius and theta (spatial), but I would like to actually let it show the color-value (temperature, T).
As a goodie on top, if I could get rid of the white concentric lines between the segments would be amazing. I tried *_showgrid=False but it does not work, maybe it's part of the bar shape?


text:
Q: State Plane Coordinate system is off in longitude by almost exactly 5 miles? I am doing a simple well location map that involves me taking the coordinates from a table (coordinates that are in New York Long Island State Plane 3104), plugging them into Excel and then using the "Find XY" tool on ArcGIS in order to show them visually. The data frame properties have also been set to New York Long Island State Plane. I've downloaded aerial images from a New York State GIS site (https://orthos.dhses.ny.gov/# for those interested). I confirmed both through my boss and Google Earth that according to the coordinates in both decimal degrees and NY Stateplane these images are where my wells are located. However, when I add my aerial images to my map document, the images are shifted in longitude by about 5 miles or so. Latitude wise (Y value) they are correct, but the longitude value (X value) is wrong.
How can I fix this?
I can post pictures and my files as needed.

A: Try re-projecting the Aerial Images to Coordinate system "New York Long Island State Plane 3104". Make sure all the data added to Data Frame should be in same Datum.


text:
Q: vectors perpendicular to a vector-geometrically I will ask my question using $\mathbb R^3$ as a reference.
Vectors of the form $[x,y,z]$ perpendicular to $[a,b,c]$ are those where $[a,b,c]\cdot [x,y,z]=0$, that is where $ax+by+cz=0$.The $x,y,z$ components of these vectors must satisfy the equation of the above plane.
At first, I was like that makes sense asthe vector $[a,b,c]$ is perpendicular to the plane $ax+by+cz=0$. But, it kind of doesn't because all those other parallel planes $ax+by+cz=d$ where d is non-zero contain the very same vectors (whose components satisfy $ax+by+cz=0$.) So, what is the meaning geometrically of the plane $ax+by+cz=0$ and the fact that the vector [a,b,c] is perpendicular to it? How would you represent the collection of vectors perpendicular to a given vector or explain it?

A: One interpretation is that one of the vectors can not help in constructing the other vector by linear combinations. The closest fit will always be for length 0 of that vector in any linear combination. So if we geometrically view a vector ${\bf v} = [x,y,z]$ as constructed by summing a set of other vectors ${\bf e}_k$:
$${\bf v} = \sum_{\forall i} s_i {\bf e}_i$$
For any ${\bf e}_k = [a,b,c]$ perpendicular to $\bf v$ there would be no point in having $s_k \neq 0$.


text:
Q: When setting the size of a picture in html/css mobile, is the percentage width/height based on screen size? I am in the middle of Oracle Apex jmobile query project where I have an HTML page. This page contains the following image code :

And the css to follow:
.img {
width:"50%",
height:"50%"
}

This code sets my image to the correct size when I am in portrait view, but when I switch to landscape orientation on my phone, the image doesn't re-size. So is the percentage method the correct choice or is there a different way? I also tried getting the screen width and height and dividing those values with no luck.

A: use img
not .img
img{
   width:"50%",
   height:"50%"
}

you have not set a class of class="img" on your img tag

A: If you want to make the sizes relative to the viewport, you can also use view height and view widths (vh)+(vw), although it is not as supported as %

A: as 1l13v said:

in css percentages are relative to parent container, in your case to
  the center element dimensions

a good solution for responsive images ist to let them autoresize relatively to their size:
center img{
  width:100%;
  height:auto;
}

the computed width depends on the width of the parent container.
example:
center{
  width:50%;
  margin:0 auto;
  display:block;
}


text:
Q: Probability of two darts getting a score of 10 on regular hexagon dart board The question I'm working on is shown below:

I've reasoned that the probability of throwing a dart for each section are: $Pr(1)=\frac{1}{6}$, $Pr(2)=\frac{1}{12}$, $Pr(3)=\frac{1}{3}$, $Pr(4)=\frac{1}{4}$, $Pr(5)=\frac{1}{8}$ and $Pr(6)=\frac{1}{24}$. I'm stuck how to proceed from here.

A: $P(3)=\dfrac{1}{3}$
$\rightarrow P(1)=\dfrac{1}{6} \rightarrow P(2)=\dfrac{1}{12}\rightarrow P(4)=\dfrac{1}{6}+P(2)=\dfrac{1}{4}$
$P(5)+P(6)=\dfrac{1}{6}$
but $P(6)=\dfrac{1}{3}P(5)\rightarrow \dfrac{1}{3}P(5)+P(5)=\dfrac{1}{6}\rightarrow P(5)=\dfrac{1}{8}\,and\, P(6)=\dfrac{1}{24}$
$P(1)+P(2)+P(3)+P(4)+P(5)+P(6)=\dfrac{1}{6}+\dfrac{1}{12}+\dfrac{1}{3}+\dfrac{1}{4}+\dfrac{1}{8}+\dfrac{1}{24}=1$
$\begin{align}P(X_1+X_2=10)&=P(X_1=4,X_2=6)+P(X_1=5,X_2=5)+P(X_1=6,X_2=4)\\
&=P(X_1=4)P(X_2=6)+P(X_1=5)P(X_2=5)+P(X_1=6)P(X_2=4)\\
&=\dfrac{1}{4}\cdot\dfrac{1}{24}+\dfrac{1}{8}\cdot\dfrac{1}{8}+\dfrac{1}{24}\cdot\dfrac{1}{4}\\
&=\dfrac{7}{192}\end{align}$

A: You found the probabilities of hitting the sections correctly.
Hint:
$\hspace{5cm}$


text:
Q: How to structure c# poco so that it works with time series json data in Highcharts? I am working on creating a time series chart using Highcharts.js like the one in this example:
http://www.highcharts.com/demo/spline-irregular-time
This chart has date and data in a series that I am accessing via an ajax call to a c# api that then returns json. I have been successful in doing this with bar charts and basic numeric data. However, I can't seem to generate the Date/Time data like in this example.
My question is - how do I structure my c# poco so that I can in turn, send back valid json to the chart in the correct date format (like this sample)? My poco is filled with data from a SQL Server database.
The json data in the sample is in this format (see below). When I attempt to create a poco of this data using http://json2csharp.com/ I get an error that the json is not valid. I realize I could probably manually create a string to generate this date data, but I wanted to avoid that if possible.
Thank you for your help or suggestions.
json sample data:
series: [{
            name: 'Winter 2007-2008',
            // Define the data points. All series have a dummy year
            // of 1970/71 in order to be compared on the same x axis. Note
            // that in JavaScript, months start at 0 for January, 1 for February etc.
            data: [
                [Date.UTC(1970,  9, 27), 0   ],
                [Date.UTC(1970, 10, 10), 0.6 ],
                [Date.UTC(1970, 10, 18), 0.7 ],
                [Date.UTC(1970, 11,  2), 0.8 ],
                [Date.UTC(1970, 11,  9), 0.6 ]
                ....
            ]
        }...

A: Because this is not proper JSON, use jsonlint or something similar before. For example proper JSON:
[{ "name": "Winter 2007-2008", "data": [ [25833600000, 0 ], [27043200000, 0.6 ], [27734400000, 0.7 ], [28944000000, 0.8 ], [29548800000, 0.6 ]  ] }]

As you can see, changed are:

*

*name -> "name"

*'Winter 2007-2008' -> "Winter 2007-2008"

*all Date.UTC() functions to proper numbers

These numbers are values returned by Date.UTC(), so are number of milliseconds since 1970.01.01 00:00:00:000 in UTC time.

A: I determined the best object to create looked like this:
public class SeriesOfData
{
    public string name { get; set; }
    public List<double[]> data { get; set; }
}

This enabled me to convert to json and achieve an array of points in a series, and each series would be a set of 2 double values (datetime in javascript milliseconds since 1970, and then the associated value/reading). As these are in an array they are not 'named' when rendered as json, so the resulting json text is in the propoer form. It was also much easier to read the code when assigning these values to the array, and I can add additional series of data as needed just by instantiating a new SeriesOfData object. Not sure if this is the best way, but it works for me. Appreciate any suggestions on improvements.


text:
Q: MySQL SUM of REAL type can return inconsistent results For a column of large real values, MySQL will return 0 for their sum but if wrapped in a subselect a non-zero result will be returned. I know that usually overflow cases are undefined but it seems pretty strange to me that MySQL will return different results depending on if the query is simple or contains a subselect.
create table z (f_real real);
insert into z values (1.80309068027e307),(1.44090607633e308),(1.59586958712e308);
select sum(f_real) from z;
+-------------+
| sum(f_real) |
+-------------+
|           0 |
+-------------+
select * from (select sum(f_real) from z) t;
+------------------------+
| sum(f_real)            |
+------------------------+
| 1.7976931348623157e308 |
+------------------------+

A: Okay, I think this has to do with hitting a ceiling in the number that SUM can deal with.
For instance:
insert into z values (1.80309068027e307),(1.44090607633e307),(1.59586958712e307);
works fine.
insert into z values (1.80309068027e308),(1.44090607633e307),(1.59586958712e307);
doesn't work, because 1.80309068027e308 is an illegal double. I'm guessing because it's just too big.
So,it seems that if you sum up numbers that are all below the double ceiling, but the result is a double above that ceiling, it reports a 0, rather than returning an error?


text:
Q: How to place text on same height as image I am trying to move the h3s and paragraphs on this page to where the h3 is level with the top of the image rather than slightly below the top line of the image if that makes sense. I just managed to be able to get the text next to the pictures the way I wanted them, but now I just need to get this fixed.
Code:

h1 {
  position: absolute;
  font-family: aquilinetworegular;
  color: #000066;
  font-size: 50px;
  top: -50px;
  left: 20px;
}

h2 {
  text-align: center;
  font-family: Arial;
  font-size: 200%
}

h3 {
  font-size: 200%
}

p.tagline {
  position: absolute;
  color: #800000;
  top: 80px;
  left: 12px;
  font-size: 19px;
  padding-top: 15px;
}

p {
  font-size: 19px;
}

.washington {
  float: right;
}

.washington img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.greene {
  float: right;
}

.greene img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.knox {
  float: right;
}

.knox img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.wayne {
  float: right;
}

.wayne img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.arnold {
  float: right;
}

.arnold img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.steuben {
  float: right;
}

.steuben img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.marion {
  float: right;
}

.marion img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.kosciuszko {
  float: right;
}

.kosciuszko img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.morgan {
  float: right;
}

.morgan img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.tallmadge {
  float: right;
}

.tallmadge img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.hamilton {
  float: right;
}

.hamilton img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.moultrie {
  float: right;
}

.moultrie img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.laurens {
  float: right;
}

.laurens img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.lafayette {
  float: right;
}

.lafayette img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.rochambeau {
  float: right;
}

.rochambeau img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.chastellux {
  float: right;
}

.chastellux img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.knyphausen {
  float: right;
}

.knyphausen img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.rall {
  float: right;
}

.rall img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.clinton {
  float: right;
}

.clinton img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.cornwallis {
  float: right;
}

.cornwallis img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.howe {
  float: right;
}

.howe img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.gage {
  float: right;
}

.gage img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.burgoyne {
  float: right;
}

.burgoyne img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.andre {
  float: right;
}

.andre img {
  float: left;
  padding-right: 15px;
  padding-bottom: 40px;
}

.northerncampaign {
  margin: 0 0 15px 20px;
  padding: 15px;
  overflow: hidden;
}

.northerncampaign img {
  margin-right: 15px;
  float: left;
}

.southerncampaign {
  margin: 0 0 15px 20px;
  padding: 15px;
  overflow: hidden;
  height: 300px;
}

.southerncampaign img {
  margin-right: 15px;
  float: left;
}

.image-center {
  display: flex;
  justify-content: space-evenly;
  width: 100%;
  margin-top: 40px;
}

.image-center2 {
  display: flex;
  justify-content: space-evenly;
  width: 100%;
  margin-top: 40px;
}

.imagecenter3 {
  display: flex;
  justify-content: space-evenly;
  width: 100%;
  margin-top: 40px;
}

.imagecenter4 {
  display: flex;
  justify-content: space-evenly;
  width: 100%;
  margin-top: 40px;
}

.imagecenter6 {
  display: flex;
  justify-content: space-evenly;
  width: 100%;
  margin-top: 40px;
}

form {
  float: right;
}

/* Navbar container */

.navbar {
  overflow: hidden;
  background-color: #333;
  font-family: Arial;
  display: flex;
  justify-content: center;
  width: 100%;
}

/* Links inside the navbar */

.navbar a {
  float: left;
  font-size: 16px;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

/* The dropdown container */

.dropdown {
  float: left;
  overflow: hidden;
}

/* Dropdown button */

.dropdown .dropbtn {
  font-size: 16px;
  border: none;
  outline: none;
  color: white;
  padding: 14px 16px;
  background-color: inherit;
  font-family: inherit;
  /* Important for vertical align on mobile phones */
  margin: 0;
  /* Important for vertical align on mobile phones */
}

/* Add a red background color to navbar links on hover */

.navbar a:hover,
.dropdown:hover .dropbtn {
  background-color: blue;
}

/* Dropdown content (hidden by default) */

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

/* Links inside the dropdown */

.dropdown-content a {
  float: none;
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

/* Add a grey background color to dropdown links on hover */

.dropdown-content a:hover {
  background-color: #ddd;
}

/* Show the dropdown menu on hover */

.dropdown:hover .dropdown-content {
  display: block;
}

Soldiers of Columbia

A research site about the American Revolutionary War

<form>
  <input type="text" placeholder="Search..." required>
  <input type="button" value="Search">
</form>

    Home
    Causes
    Battles

      <button class="dropbtn">Armies
     </button>

        Continental
        British
        French
        Hessian

      <button class="dropbtn">Commanders
    </button>

        American
        British
        French
        Hessian

Battles of the American Revolutionary War

Northern theater

Read about the battles of the war's northern theater

Southern theater

Read about the battles of the war's southern theater

A: This is because the h3 line-height and margin getting pushed down so if you add h3 {margin: 0; line-height: 1;} the text will align with the top of the image. and you change the values.
Check this code:

.northerncampaign {
  margin: 0 0 15px 20px;
  padding: 15px;
  overflow: hidden;
  vertical-align: text-bottom;
}

.northerncampaign img {
  margin-right: 15px;
  float: left;
}

.southerncampaign {
  margin: 0 0 15px 20px;
  padding: 15px;
  overflow: hidden;
  height: 300px;
}

.southerncampaign img {
  margin-right: 15px;
  float: left;
}

h3 {
  line-height: 1;
  margin: 0;
}

Northern theater

Read about the battles of the war's northern theater

Southern theater

Read about the battles of the war's southern theater


text:
Q: Is there a way to disable cross-origin resource sharing restrictions in mobile safari As far as I know, currently it is not possible to disable cross-origin resource sharing restrictions in mobile safari. It would be great if this could be implemented or if someone knows how to do this. This would be an incredibly useful feature for automated testing of web applications on mobile Safari.
Yes I know that we can do it with Chrome:
Disable same origin policy in Chrome
And there are options to do it with desktop Safari:
https://stackoverflow.com/questions/4556429/disabling-same-origin-policy-in-safari#:~:text=Just%20enable%20the%20developer%20menu,restrictions%22%20from%20the%20develop%20menu.
And to do it manually on Mac for mobile Safari:
https://stackoverflow.com/a/72309627/16804973
But I need to do it within Appium/Selenium code and I do not find any equivalent to Chrome option "-diasble-web-security", because there is no such one for Safari: https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/safari/SafariOptions.html
The last info I have found, was a request on Mac Developers page about this: https://developer.apple.com/forums/thread/80927
Does anyone has a solution for this nowadays?


text:
Q: Deploying django on app engine 500 server error I am trying to deploy completed web-app (runs locally) on the app engine. The app has no databases and the web page is static. My primary problem is that I try to deploy the app and I get a server error. I suspect that the issue lies with my app.yaml file but I cannot seem to fix it. Here is my yml file:
runtime: python27
api_version: 1
threadsafe: yes

handlers:

- url: /static
  static_dir: personal/static/

- url: /.*
  script: mysite.wsgi.application

The directory is organized so that the 'personal' is an installed app and static, templates etc. are inside the personal folder.

A: In settings file, make DEBUG=False for short time to just check what is error, then return it back to True


text:
Q: C# abstract record with abstract Equals method Why are we not allowed to do the following for a record
abstract record AA
{
  public abstract bool Equals(AA other);
}

record BB:AA
{
  public override bool Equals(AA other)// error as it is already implemented
  {
    //do some thing
  }
}

while it is totally acceptable for classes?
abstract class AA
{
   public abstract bool Equals(AA other);
}

class BB:AA
{
  public override bool Equals(AA other)
  {
    //do some thing
  }
}

By the way, I am doing this implementation to enforce the Equals check to cascade to its derived classes.
Edit: just to give context on why am I interested on this is because I am currently creating an library/autogenerator for IEquatable.
Edit/Info 2: Based on the comments, I have done some tests. since the abstract Equals method of record can't be overridden, I tried leaving it as is.
public abstract record AA
{
    public int Prop1 { get; set; }
    public string? Prop2 { get; set; }
    public string? Prop5 { get; set; }
    public abstract bool Equals(AA? other);
}

public record BB : AA
{
    public string? Prop3 { get; set; }
}

The result I get an error of System.BadImageFormatException: Bad IL format.
All in all, abstract Equals method on records is not just an unnecessary implementation but is also a bad one.

A: This is because compiler already implements equality methods for records. Check Value equality of records:

To implement value equality, the compiler synthesizes the following methods:

*

*An override of Object.Equals(Object).

*This method is used as the basis for the Object.Equals(Object, Object) static method when both parameters are non-null.

*A virtual Equals method whose parameter is the record type. This method implements IEquatable.

*An override of Object.GetHashCode().

*Overrides of operators == and !=.

It means that there's not need to enforce the implementation of Equals method in the base abstract record.
If you still want to have custom Equals method implementation and derive from some base record you could do so by declaring virtual Equals method with the derived type as an argument:
abstract record AA
{
    // Redundant in case of records and can be omitted.
    public abstract bool Equals(AA other);
}

record BB : AA
{
    public virtual bool Equals(BB other)
    {
        throw new NotImplementedException();
    }
}


text:
Q: SQL Query for Separated Group By please consider below table
ProductCode     Flag    Date-----------------------------------------
A                        N      01/10/2015
A                        N      02/10/2015
A                        Y      04/10/2015
A                        Y      05/10/2015
A                        Y      12/10/2015
A                        N      13/10/2015
A                        N      15/10/2015
A                        Y      16/10/2015
A                        Y      16/10/2015
A                        Y      17/10/2015
B                        N      01/12/2015
B                        N      02/12/2015
B                        Y      08/12/2015
B                        N      08/12/2015
B                        N      09/12/2015
what could be the SQL query to give me below resultLProductCode    Flag     StartDate     End Date-------------------------------------------------------------------
A                         N       01/10/2015    02/10/2015
A                         Y       04/10/2015    12/10/2015
A                         N      13/10/2015    15/10/2015
A                         Y       16/10/2015    17/10/2015B                        N       01/12/2015    02/12/2015
B                        Y       08/12/2015    08/12/2015B                        N       08/12/2015    09/12/2015Thanks.

A: The key here is to assign groups to continuous N and Y flags for each product. Thereafter, it is just a grouping operation on the classified groups.
with grps as (
 select t.*,
-row_number() over(partition by productcode,flag order by dt)
+ row_number() over(partition by productcode order by dt) grp
from t
)
select productcode,flag,min(dt) startdate,max(dt) enddate
from grps
group by productcode,flag,grp
order by 1,3

Sample Demo


text:
Q: How to get sql data from two tables and print to one? I'm new to PHP and SQL. I'm still learning.
So, I have in my DB 3 tables called ps_plr, ps_plr_ids_name and ps_plr_victms.

*

*ps_plr, I need column: rank

*ps_plr_ids_name, I need column: name

*ps_plr_victms, I need 2 columns: kills and deaths
in all of these tables, I have the plrid column that will serve as a base.
I need to output an html table having:
Rank, Name, Kills and Deaths.
I tried the following code that can print the rank and the plrid, but I don't really need the plrid on the table, as I said, just as a base to find what I need on the other tables.
<?php
$servername = "localhost";
$username = "root";
$password = "********";
$dbname = "psychostats3_1";

$mysqli = new mysqli($servername,$username,$password,$dbname);

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$query  = "SELECT ps_plr.rank, ps_plr.plrid FROM ps_plr;";
$query .= "SELECT ps_plr_ids_name.name FROM ps_plr_ids_name plrnk, ps_plr plrst;";
$query .= "WHERE plrid=name";

//select task.id, task.name, proj.id, proj.name
//from tasks task, projects proj
//where proj.id=task.project_id;

/* execute multi query */
if ($mysqli->multi_query($query)) {
    do {
        /* store first result set */
        if ($result = $mysqli->store_result()) {
            while ($row = $result->fetch_row()) {
                printf("
" . $row[0] . "	");
                printf("" . $row['2'] . "
");
            }
            $result->free();
        }
        /* print divider */
    } while ($mysqli->next_result());
}

/* close connection */
$mysqli->close();
?>

A: +-----------------+----------------+
| tutorial_author | tutorial_count |
+-----------------+----------------+
| mahran          |             20 |
| mahnaz          |           NULL |
| Jen             |           NULL |
| Gill            |             20 |
| John Poul       |              1 |
| Sanjay          |              1 |
+-----------------+----------------+

Let say this is a table tcount_tbl
And My another table tutorials_tbl
+-------------+----------------+-----------------+-----------------+
| tutorial_id | tutorial_title | tutorial_author | submission_date |
+-------------+----------------+-----------------+-----------------+
|           1 | Learn PHP      | John Poul       | 2007-05-24      |
|           2 | Learn MySQL    | Abdul S         | 2007-05-24      |
|           3 | JAVA Tutorial  | Sanjay          | 2007-05-06      |
+-------------+----------------+-----------------+-----------------+

Now executing the query.
SELECT a.tutorial_id, a.tutorial_author, b.tutorial_count
    -> FROM tutorials_tbl a, tcount_tbl b
    -> WHERE a.tutorial_author = b.tutorial_author;

This is how I can Join two tables as in your case you haven't mentioned the whole column names So I am just supposing and giving you a brief example for joins. You can do further joins like left join etc to fetch from 3 tables
Source fetching from 3 tables

A:

Rank
Name
Kills
Deaths

   $res=mysql_query("SELECT c.* , p.*,d.* FROM ps_plr c,ps_plr_ids_name p,ps_plr_victms d WHERE c.plrid=p.plrid and c.plrid = d.plrid ");
    while($row=mysql_fetch_array($res))
    {
     ?>

<?php echo $row[' Rank']; ?>

<?php echo $row['Name']; ?>

<?php echo $row['Kills']; ?>

<?php echo $row['deaths']; ?>

        <?php
    }
    ?>

Try it Hope this works..


text:
Q: multiple Drilldown in Highcharts using values from database in ruby on rails I have the following tables in my database

table1 animals-->
columns [name,count]
[cat,4]
[dog,2]
[cow,1]

table2 cars--->
columns [name,count]
 [toyota,4]
 [opel,2]

table3 toyota-->
columns [name,count]

[liva,2]
[etios,2]

I want to fetch the data from data base and dynamically create multiple drill down charts using high-charts. eg:cars-->toyota-->etios .....etc
the following code with static data works fine.how to pass dynamic values using Ruby?
series: [{
            name: 'Things',
            colorByPoint: true,
            data: [{
                name: 'Animals',
                y: 3,
                drilldown: 'animals'
            },  {
                name: 'Cars',
                y: 2,
                drilldown: 'cars'
            }]
        }],
        drilldown: {
            series: [{
                id: 'animals',
                data: [
                    ['Cats', 4],
                    ['Dogs', 2],
                    ['Cows', 1]

                ]
            },  {
                id: 'cars',
                data: [
                    {
                name: 'Toyota',
                y: 4,
                drilldown: 'Toyota'
            },
                ]
            }, {
                id: 'Toyota',
                data: [
                    ['Etios', 2],
                    ['Liva', 2]
                ]
            }]
        }

A: You have to do many things for that
1) First use group_by method like
group =@animals.group_by(&:name)

hash = group.values

after that
2)  value = hash.collect(&:first)
3) then use value.map for getting
4) Use Hash.new {|h,k| [k, variable.count(k)] }

after that ,  as you want just change or add some more steps like count , uniq, or collect
at last my highcharts script is ,this is my code , you can customized as you need ...
series: [{
type: 'pie',
name: 'Country Visits',
data: [
<% for index in 0 ... @country_name.size%>
<% if index == 0 %>
 ['<%= @country_name[index ] %>', <%= @country_name_visits[index]%>]
 <% else %>
 ,['<%= @country_name[index ] %>', <%= @country_name_visits[index]%>]
<% end %>
<% end %>
]
}]

A:  series: [{
        name: 'Things',
        colorByPoint: true,
        data: [<%@comp.each do |com|%>
                  { name:'<%=com.name%>',
                    y: <%=com.count%>,
                    drilldown: '<%= com.name%>'
                  },
                      <%end%>
                      ]
    }],
    drilldown: {
        series: [ <%@car.each do |qq|%>
                  {
                  id: '<%=qq.name%>',

                  data: [
                  <%@cars.each do |q|%>
                     <% if q.name == qq.name  %>
                     {
                        name:'<%=q.carvendor%>',
                      y: <%=q.count%>,
                      drilldown: '<%= q.carvendor%>'
                    },
                    <%end%>
                     <%end%>
                       ]
                  },
                  <%end%>

                ]
                 }


text:
Q: Should I use "to", or not?

*

*All I can say is give them rest.

*All I can say is to give them rest.

*Give to me.

*Give me.

*We just asked him to join our dance trope.

*We just asked him  join our dance trope.

Should I use "to", or not?

A: The first phrase could go either way, but if you choose the first form you should probably use quotation marks, or at least a comma, since that construction actually puts those words in your mouth, making the rest of the sentence a paraphrase or quotation.

All I can say is, "give them rest."
  All I can say is, give them rest.

The second phrase is wrong in both forms, I think. You need an object, e.g.

Give it to me.

You definitely need the "to" there. Children and very causal speakers may use "Give me", or, more commonly, the shortened slang form "Gimme", to imply the longer phrase "Give that to me", but you shouldn't use this in most situations.
In the third phrase, "to" is absolutely necessary. You asked him to join your dance group.


text:
Q: Lwjgl / Opengl font rendering I am trying to display text with a custom font onto the lwjgl display using opengl. currently i am using my custom bitmap font class to load the font from a png file, and display them in the same fashion as a tileset. It works alright but when i draw the text to the screen the spacing between the characters is all different because the letter M is way wider than the letter I and all of the characters have different widths. is there any way to detect the width of each character? or is there any library's that are specific to fonts in lwjgl? There is a way to do it using slick2d but its pointless to load the whole library just to display text!

A: I once had the same problem, so here is what I did to solve the problem.
I usually make a lot of small example programs so I can actually still find the program which have the exact problem, so here is a screenshot.

As you already described the problem lies in that we're using the same width for each character which gives those awful spacing.
Basically what I ended up doing was writing each character and symbol's x, y, width, height, xoffset, yoffset, xadvance to a file.

*

*x/y = The x/y coordinate of the character on the image.

*width/height = The width/height of the character.

*xoffset/yoffset = This is extra spacing only given to the rendered character.

*xadvance = This is the extra spacing that will be added after the character is rendered.

*All of the values are given in pixels.

Here is an example:
file data/materials/font/font1.png

char default width=5 height=7 xoffset=0 yoffset=0 xadvance=1

char id= x=0 y=16

char id=a x=8 y=48
char id=b x=16 y=48
char id=c x=24 y=48
... etc ...
char id=i x=72 y=48 width=1
... etc ...

char id=A x=8 y=32
char id=B x=16 y=32
char id=C x=24 y=32
... etc ...
char id=I x=72 y=32 width=3
... etc ...

Understanding The File
Let me just explain shortly what each line does.
file data/materials/font/font1.png
Tells the parser that we want to load and and use the following given path as the font texture. You can of course do that manually, this is simply how I've done it.
char default width=5 height=7 xoffset=0 yoffset=0 xadvance=1
This sets the default values for a new char, so if we define a char and it doesn't contain any of the above it will be given the default value.
char id=a x=8 y=48
This defines the character 'a' because of course the ìd=a tells that it's 'a' and x=8 y=48 is the top-left coordinate of where the character is located on the texture.
Again, because we defined char default width=5 height=5 ..... above it will by default be assigned to the character as well. So basically the parser reads char id=a x=8 y=48 as char id=a x=8 y=48 width=5 height=7 xoffset=0 yoffset=0 xadvance=1
That is also why I added the char id=i x=72 y=48 width=1 to the example, there you can actually see that we define the width as only being 1 instead of the default 5
char id= x=0 y=16
This actually defines the whitespace, so if you would like it so render a letter or symbol instead of a whitespace, that could also be done.
Loading The File
First, I mainly have 2 classes BitmapFont and BitmapGlyph. I won't give you all the code of both my classes, because the point of Stack Overflow isn't that we should do all your work.
The BitmapGlyph class stores infomation about a characters/symbol, since it's just a class for storing information it's pretty simple.
public class BitmapGlyph {
    public int id;
    public int x, y, width, height;
    public int xoffset, yoffset, xadvance;
    public float u, v, u2, v2;
}

The BitmapFont class mainly contains 2 mehods static load(final File file) and render(String text, float x, float y, float size)
It contains more methods, like dispose(), getTexture(), etc. though for your problem they are irrelevant.
Parsing The File
public final static BitmapFont load(final File file) {
    BitmapFont font = new BitmapFont();

    final ArrayList<BitmapGlyph> glyphs = new ArrayList<BitmapGlyph>();

    try (final BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)))) {
        String line;

        while ((line = br.readLine()) != null) {
            if (line.isEmpty()) { continue; }

            // Now parse the file, example:

            if (line.startsWith("file ")) {
                // I don't know if you have a Texture class, and if you
                // can load an image from a path to a texture,
                // though since this is just an example and it's easy
                // to understand. Then you will just have to adapt it
                // to your own program.
                font.texture = new Texture(new File(line.substring(5)));
            }

            // PARSE THE REST OF THE FILE
        }

        br.close();
    }
    catch (Exception ex) {}

    return font;
}

After I've parsed the file I also convert the characters x, y, width, height, to actual u, v, u2, v2, coordinates on the texture. I do that by looping through each BitmapGlyph like this.
int width = texture.getWidth(); // The width should of course be the actual pixel width of the image.
int height = texture.getHeight(); // The height should of course be the actual pixel height of the image.

for (BitmapGlyph glyph : glyphs) {
    glyph.u = glyph.x / (float) width;
    glyph.v = glyph.y / (float) height;
    glyph.u2 = (glyph.x + glyph.width) / (float) width;
    glyph.v2 = (glyph.y + glyph.height) / (float) height;
}

Rendering
You probably already know this, though to be on safe side I will guide you.
public final void render(String text, float x, float y, float size) {
    // BIND FONT TEXTURE

    glBegin(GL_QUADS);

    for (int i = 0, istop = text.length(); i < istop; i++) {
        char ascii = text.charAt(i);

        BitmapGlyph g = ...; // Get the stored glyph according to the char, check against the BitmapGlyph id

        float ww = g.width * size;
        float hh = g.height * size;

        float xx = x + g.xoffset * size;
        float yy = y + g.yoffset * size;

        glTexCoord2f(g.u, g.v);
        glVertex2f(xx, yy);

        glTexCoord2f(g.u, g.v2);
        glVertex2f(xx, yy + hh);

        glTexCoord2f(g.u2, g.v2);
        glVertex2f(xx + ww, yy + hh);

        glTexCoord2f(g.u2, g.v);
        glVertex2f(xx + ww, yy);

        x += (g.width + g.xadvance) * size;
    }

    glEnd();
}

Important: I'm only using the deprecated methods because it makes it easier to explain.
When using the way I just described you will end up with this result. (Again this is a screenshot of the actual program I made for fixing this problem)

Comparison
Before

After

Extra
Here are some points on why you should choose to do it this way.

*

*This way you don't have to arrange all the characters the same way.

*You can always add new characters and/or symbols.

*The characters can be any size you want them to be.

This was probably the longest answer I've ever made, though I hope you can use it!


text:
Q: Android: How to make scrollable table with frozen table headers? I wonder how I could make a scrollable table with static table header ? (with different elements in cells like buttons, images, etc.)
I have already made some of this, but i dont know how to make columns in different tables match each other by width.
<TableLayout>
    <TableRow>
        Table headers...
    </TableRow>
    <ScrollView>
        <TableLayout > <!-- Table content--></TableLayout >
    </ScrollView>
</TableLayout>

Thanks !

A: You should ditch the TableLayout for a ListView or GridView
Then use a RelativeLayout
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="wrap_parent"
    android:laout_height="wrap_content"
    android:alignParentTop="true"
    android:id="@+id/buttons">
 <!-- Your Buttons Here -->
 </LinearLayout>
 <GridView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@id/buttons"/>
 </RelativeLayout>


text:
Q: Ubuntu 20.04.4 freezes with no error I am at my wit's end. Lets start with my computer's hardware.

*

*CPU: Ryzen 3500X

*GPU: Nvidia GTX1660 Super

*Motherboard: Asus b550m tuf plus gaming wifi

*RAM: 2x 8GB Corsair Vengence

*1 SSD and 1 HDD for Windows

I am trying to install Ubuntu onto my desktop in a brand new SSD. However, after installation, it seems that Ubuntu would unexpectedly freeze. Everytime it freezes, I end up in a state where no emergency command works and I would need to force shutdown my desktop.
I have managed to update all ubuntu drivers and used Nvidia graphics drivers (before the freeze happens). I have also tried to remove my storage drivers for windows. But the results are still the same and the PC inevitably freezes, even when I am using the "try out Ubuntu" from my boot media. Somehow, my old laptop bought 6 years ago runs the same installation media perfectly fine.
I noticed that the freeze happens when I try to run something. Like opening Firefox to browse youtube or even sometimes during a system update. There is no error log generated each time this happens. So I have no idea what is happening internally. Would appreciate any help before I can get!
Edit: Things I have tried to do are

*

*Installed and switched to Linux kernel 5.15.29

*Change kernel boot parameters using "rcu_noobs=0-11 processor.max_cstate=5"

*Change bios PSU Idle control to "typical current idle"

*Update all packages and drivers, including GPU drivers

*Installed Ubuntu 21.10 with and without 3rd party drivers
Still, none of these have worked so far...

A: I FOUND THE ANSWER!!! And I am using Ubuntu 20.04 with no problems for the last hour so far.
The solution was to update the BIOS. I removed all other changes too, so that I can confirm that the BIOS version was the only change needed to reach the solution.
Great thanks for everyone who pitched in to help me. It has been 1 week worth of nights of testing but I am glad I am finally here. =)

A: Try a fresh install with version 21.10 downloaded freshly from Official Ubuntu site. I think there might be some issues with 20.04 ISO you have or flashing tool. Use Etcher tool and don't see any reason else you might encounter this issue.

A: Web site https://easylinuxtipsproject.blogspot.com/p/bugs.html#ID27 solves most freezing of boxes with amd processors.On mine, I was not able to do the PSU Idle Control mod as my BIOS does not have that parameter.


text:
Q: $soc^n(M)=\{m\in M | mJ_A^n=\{0\}\}$? Consider a right $A$-module $M$ over an Artinian ring $A$ (unital, not necessarily commutative). Define $soc(M)$ to be sum of all simple $A$-submodules of $M$. Inductively define $soc^0(M):=0$, $soc^n(M)/soc^{n-1}(M) := soc(M/soc^{n-1}(M))$. My question:

Is $soc^n(M)=\{m\in M | mJ_A^n=0\}$?

Here $J_A$ is the Jacobson radical of $A$.
I am struggling to prove the inclusion for $n=1$, namely $soc(M)\supseteq\{m\in M | mJ_A=\{0\}\}$. The reverse inclusion is easy and I am confident that the rest will follow by induction


text:
Q: In PostgreSQL, calculate the average duration (interval of time) that an ID appears in a single Date column Background
I'm pretty new to SQL and to Postgres. I'm trying to get some basic descriptions of some data in a large table about car and motorcycle insurance claims -- call the table claims. The data have ~15 columns, but only 2 are relevant here:
     id        | claim_date   |
---------------+--------------|
 001           |  2011-01-30  |
 001           |  2012-04-12  |
 001           |  2014-06-27  |
 002           |  2017-09-03  |
 002           |  2018-12-25  |

The Problem
I'd like to know the average interval of time that IDs appear in this dataset. Were I to do this by hand, I'd subtract the earliest from the latest claim_date for each ID, sum them, and divide by the number of distinct IDs (2, in this case). This'd give me a result of 861 days here.
The main issue is that I'm not really sure how to write this out in query form in Postgres.
What I've Tried
In similar posts, other users have asked about subtracting the date in one date column from another to get a date interval, but that's not exactly what I'm after.
I've tried a query like this:
select max(claims.claim_date) - min(claims.claim_date) date_diff
from claims
group by ID

But only gets me part way, just a list of max-min intervals for each ID. I've also tried using AVG like so:
select AVG(max(claims.claim_date) - min(claims.claim_date))
from claims
group by ID

But here I get the error ERROR: aggregate function calls cannot be nested.
Any ideas?

A: Just use two levels of aggregation.
SELECT avg(d) AS ad
       FROM (SELECT max(claim_date)
                    - min(claim_date) AS d
                    FROM claims
                    GROUP BY id) AS x;


text:
Q: Bibtex cite an (online)article or url from a online version of a magazine I am new to using to Latex and Bibtex.There is a (online)article in the following link, which I want to use in Bibtex:
http://www.raspberry-pi-geek.de/Magazin/2013/05/Distributionen-fuer-den-Raspberry-Pi-im-Ueberblick
Its possible to Use it in a style sheet with the following parameters:

*

*url

*title

*the journals name

*the authors

*the edition (in this case 05/2013 )

(maybe with aditional informations)


text:
Q: in_array devuelve valores incorrectos Tengo este simple código, para determinar si un elemento ya existe o no en un array previamente definido
$rutasUnicas = array();

$rutas = array(
    $xml->CODED_DATA_SECTION->NOTICE_DATA->IA_URL_GENERAL,
    $xml->CODED_DATA_SECTION->NOTICE_DATA->IA_URL_ETENDERING,
    $xml->FORM_SECTION->$sectionName->CONTRACTING_BODY->ADDRESS_CONTRACTING_BODY->URL_GENERAL,
    $xml->FORM_SECTION->$sectionName->CONTRACTING_BODY->ADDRESS_CONTRACTING_BODY->URL_BUYER,
    $xml->FORM_SECTION->$sectionName->CONTRACTING_BODY->URL_DOCUMENT,
    $xml->FORM_SECTION->$sectionName->CONTRACTING_BODY->URL_TOOL
);

foreach ($rutas as $ruta) {
    if ($ruta != '') {
        echo "revisando [$ruta]... >>>>> ";
        if (in_array($ruta, $rutasUnicas)){
            echo "YA EXISTE, la ignoramos
";
        } else {
            echo "no existe en el array, la insertamos
";
            array_push($rutasUnicas, $ruta);
        }
    }
}

empty($rutasUnicas);

Este código devuelve esto por pantalla:
revisando [http://www.esm.europa.eu]... >>>>> no existe en el array, la insertamos
revisando [https://www.esm.europa.eu/procurement]... >>>>> YA EXISTE, la ignoramos
revisando [http://www.esm.europa.eu]... >>>>> no existe en el array, la insertamos
revisando [https://www.esm.europa.eu/procurement]... >>>>> no existe en el array, la insertamos

Y esto es el contenido del array $arrayUnicos una vez terminan los foreach.
Array (
    [0] => SimpleXMLElement Object (
        [0] => http://www.esm.europa.eu
    )

    [1] => SimpleXMLElement Object (
        [0] => http://www.esm.europa.eu
    )

    [2] => SimpleXMLElement Object (
        [0] => https://www.esm.europa.eu/procurement
    )
)

Como véis, el array final tiene una dirección repetida, que no debería, además de haber agregado la segunda aparición de la segunda url, en vez de la primera aparición de la misma.
Qué estoy haciendo mal?

A: Pienso que el error se debe a que no es lo mismo comparar un par de objetos SimpleXMLElement a comparar un par de cadenas. Puedes intentar comparando el contenido de $arreglo y no solamente los objetos. De la siguiente manera:
if (in_array($ruta[0], $rutasUnicas)){
    echo "YA EXISTE, la ignoramos
";
} else  {
    echo "no existe en el array, la insertamos
";
    array_push($rutasUnicas, $ruta[0]);
}

A: Finalmente encontré la solución.
Las rutas que aparecen dentro del array $rutas son objetos XML. Pese a que intenté comparar ambos objetos siempre resolvía mal, seguía sin detectar las repetidas correctamente, de forma que se me ocurrió forzar esas variables a ser de tipo string en el momento de ser capturadas para formar el array, con lo que a partir de ahí y siendo ya strings puros, la comparación resulta positiva cuando toca y negativa lo mismo.
    $rutasUnicas = array();

    $rutas = array(
            (string) $xml->CODED_DATA_SECTION->NOTICE_DATA->IA_URL_GENERAL,
            (string) $xml->CODED_DATA_SECTION->NOTICE_DATA->IA_URL_ETENDERING,
            (string) $xml->FORM_SECTION->$sectionName->CONTRACTING_BODY->ADDRESS_CONTRACTING_BODY->URL_GENERAL,
            (string) $xml->FORM_SECTION->$sectionName->CONTRACTING_BODY->ADDRESS_CONTRACTING_BODY->URL_BUYER,
            (string) $xml->FORM_SECTION->$sectionName->CONTRACTING_BODY->URL_DOCUMENT,
            (string) $xml->FORM_SECTION->$sectionName->CONTRACTING_BODY->URL_TOOL
        );

        foreach ($rutas as $ruta) {
            if ($ruta != '') {
                echo "revisando [$ruta]... >>>>> ";
                if (in_array($ruta,$rutasUnicas, TRUE)) {
                    echo "YA EXISTE, la ignoramos
";
                }
                else  {
                    echo "no existe en el array, la insertamos
";
                    array_push($rutasUnicas, $ruta);
                }
            }
        }

        empty($rutasUnicas);

Y aquí el resultado final:
revisando [https://tendering.consilium.europa.eu]... >>>>> no existe en el array, la insertamos
revisando [https://etendering.ted.europa.eu/cft/cft-display.html?cftId=4335]... >>>>> no existe en el array, la insertamos
revisando [https://tendering.consilium.europa.eu]... >>>>> YA EXISTE, la ignoramos
revisando [http://www.consilium.europa.eu/contacts/procurement]... >>>>> no existe en el array, la insertamos
revisando [https://etendering.ted.europa.eu/cft/cft-display.html?cftId=4335]... >>>>> YA EXISTE, la ignoramos
Array
(
    [0] => https://tendering.consilium.europa.eu
    [1] => https://etendering.ted.europa.eu/cft/cft-display.html?cftId=4335
    [2] => http://www.consilium.europa.eu/contacts/procurement
)


text:
Q: Trying to merge wav with video file using ffmpeg This batch file isn't working and I know the ffmpeg commands work when the command is on its own.
I am using a WAV file that's exactly the length of the video (it was extracted from the video I am trying to add it back to).
The NOAUDIO and NOVIDEO labels work properly if I delete the wav and/or video file from the folder where ffmpeg.exe and the batch file are.
When the batch file is run with a wav audio and mp4 video file there, it just flashes up a command window. I tried putting pause after every single command but, still no joy.
Is there a mistake here somewhere?
Cheers folks...
:: --------------------
::
:: This will put any included WAV file with any included
:: video file, assuming the video file type exists:
::
:: - AVI
:: - MKV
:: - MP4
:: - WEBM
::
:: --------------------

@echo off
title Replace Video Audio with WAV
color 0f

:: --------------------

if not exist *.wav goto NOAUDIO
if not exist *.avi if not exist *.mkv if not exist *.mp4 if not exist *.webm goto NOVIDEO

:: --------------------

if exist *.avi goto AVIFILE
if exist *.mkv goto MKVFILE
if exist *.mp4 goto MP4FILE
if exist *.webm goto WEBMFILE

:: --------------------

For %%a IN ("*.wav") DO Set "FILEWAV=%%~na"

:: --------------------

:AVIFILE
For %%a IN ("*.avi") DO Set "FILEAVI=%%~na"
start /wait ffmpeg.exe -i "%FILEAVI%.avi" -i "%FILEWAV%.wav" -c:v copy -map 0:v:0 -map 1:a:0 "%FILEAVI%-NEW.mp4"
goto FINISHED

:MP4FILE
For %%a IN ("*.mp4") DO Set "FILEMP4=%%~na"
start /wait ffmpeg.exe -i "%FILEMP4%.mp4" -i "%FILEWAV%.wav" -c:v copy -map 0:v:0 -map 1:a:0 "%FILEMP4%-NEW.mp4"
goto FINISHED

:WEBMFILE
For %%a IN ("*.webm") DO Set "FILEWEBM=%%~na"
start /wait ffmpeg.exe -i "%FILEWEBM%.webm" -i "%FILEWAV%.wav" -c:v copy -map 0:v:0 -map 1:a:0 "%FILEWEBM%-NEW.mp4"
goto FINISHED

:MKVFILE
For %%a IN ("*.mkv") DO Set "FILEMKV=%%~na"
start /wait ffmpeg.exe -i "%FILEMKV%.mkv" -i "%FILEWAV%.wav" -c:v copy -map 0:v:0 -map 1:a:0 "%FILEMKV%-NEW.mp4"
goto FINISHED

:: --------------------

:NOAUDIO
cls
echo.
echo.
echo    There is no audio to put with the video!
echo.
echo    Exiting...
timeout 6 >nul
goto FINISHED

:: --------------------

:NOVIDEO
cls
echo.
echo.
echo    There is no video to put audio with!
echo.
echo    Exiting...
timeout 6 >nul
goto FINISHED

:: --------------------

:FINISHED
exit

:: --------------------

I just tested this and it does work, using the exact same commands as in the above batch file just with all the labels removed...
For %%a IN ("*.wav") DO Set FILEWAV=%%~na

:MP4FILE
For %%a IN ("*.mp4") DO Set FILEMP4=%%~na
start /wait ffmpeg.exe -i "%FILEMP4%.mp4" -i "%FILEWAV%.wav" -c:v copy -map 0:v:0 -map 1:a:0 "%FILEMP4%-NEW.mp4"
goto FINISHED

:FINISHED
exit

So I know the reason it's not working is something to do with the order the batch file runs. It's odd because I have another batch file just like it for extracting the WAV in the first place and that does work, with labels set out just like the first batch file above. Perplexing.
If I reduce it to just this, it works...
For %%a IN ("*.wav") DO Set FILEWAV=%%~na

For %%a IN ("*.avi") DO Set FILEAVI=%%~na
start /wait ffmpeg.exe -i "%FILEAVI%.avi" -i "%FILEWAV%.wav" -c:v copy -map 0:v:0 -map 1:a:0 "%FILEAVI%-NEW.mp4"

For %%a IN ("*.mp4") DO Set FILEMP4=%%~na
start /wait ffmpeg.exe -i "%FILEMP4%.mp4" -i "%FILEWAV%.wav" -c:v copy -map 0:v:0 -map 1:a:0 "%FILEMP4%-NEW.mp4"

For %%a IN ("*.webm") DO Set FILEWEBM=%%~na
start /wait ffmpeg.exe -i "%FILEWEBM%.webm" -i "%FILEWAV%.wav" -c:v copy -map 0:v:0 -map 1:a:0 "%FILEWEBM%-NEW.mp4"

For %%a IN ("*.mkv") DO Set FILEMKV=%%~na
start /wait ffmpeg.exe -i "%FILEMKV%.mkv" -i "%FILEWAV%.wav" -c:v copy -map 0:v:0 -map 1:a:0 "%FILEMKV%-NEW.mp4"

exit

A: The main problem is that the command line
For %%a IN ("*.wav") DO Set "FILEWAV=%%~na"

is not executed ever on any video file found because of command goto on the four if conditions above. So one of the ffmpeg.exe command lines is executed with environment variable FILEWAV most likely not defined at all, at least not by the batch file.
The batch file can be improved to:
@echo off
:: --------------------
::
:: This will put any included WAV file with any included
:: video file, assuming the video file type exists:
::
:: - AVI
:: - MKV
:: - MP4
:: - WEBM
::
:: --------------------

setlocal EnableExtensions DisableDelayedExpansion
title Replace Video Audio with WAV
color 0f

if not exist %SystemRoot%\System32\where.exe goto CheckAudio
%SystemRoot%\System32\where.exe ffmpeg.exe >nul 2>nul
if not errorlevel 1 goto CheckAudio
echo/
echo/
echo    There is ffmpeg.exe not found in current directory or
echo    any directory defined in environment variable PATH!
echo/
if exist %SystemRoot%\System32\timeout.exe (echo    Exiting...& %SystemRoot%\System32\timeout.exe 6 >nul) else pause
goto FINISHED

if exist *.wav goto ProcessVideo
cls
echo/
echo/
echo    There is no audio to put with the video!
echo/
if exist %SystemRoot%\System32\timeout.exe (echo    Exiting...& %SystemRoot%\System32\timeout.exe 6 >nul) else pause
goto FINISHED

:ProcessVideo
rem Get file name of (last) WAV file in current directory.
for %%I in (*.wav) do set "AudioFile=%%I"

rem Process all AVI, MKV, MP4 and WBEM video files in current directory.
set "NoVideo=1"
for /F "eol=| delims=" %%# in ('dir *.avi *.mkv *.mp4 *.webm /A-D /B /ON 2^>nul ^| %SystemRoot%\System32\findstr.exe /I /E /L /V /C:"-new.mp4"') do ffmpeg.exe -i "%%#" -i "%AudioFile%" -c:v copy -map 0:v:0 -map 1:a:0 "%%~n#-NEW.mp4" & set "NoVideo="
if not defined NoVideo goto FINISHED

cls
echo/
echo/
echo    There is no video to put audio with!
echo/
if exist %SystemRoot%\System32\timeout.exe (echo    Exiting...& %SystemRoot%\System32\timeout.exe 6 >nul) else pause

:FINISHED
color
endlocal

The command FOR supports searching for file names using multiple wildcards like also command DIR. Therefore it is not necessary to use nearly the same code for each type of video file format to support by the batch file. The modification results in processing all video files in current directory and not just the last one, except the video file name ends already case-insensitive with -NEW.
The character a is a modifier for the loop variable. It can be used nevertheless as loop variable, but it is better to use as loop variable a character which is never interpreted as modifier. The batch file above uses once I and once # as loop variable to demonstrate that.
start /wait is not necessary at all. Windows command processor cmd.exe waits by default for self-termination of any executable started from within a batch file as otherwise the execution of timeout.exe would not work as expected. Therefore ffmpeg.exe can be run without usage of command start and its option /wait.
The command exit at end of a batch file is always useless. It makes it just more difficult to debug the batch file for the developer of the batch file and its existence at end of the batch file without any parameter is counter-productive for batch file users executing the batch file from within a command prompt window or for users which want to call the batch file from another batch file multiple times, for example in a loop.
It is good practice to specify a Windows Command with full qualified file name in a batch file to make the batch file independent on PATH and PATHEXT as much as possible. Then Windows command processor does not need to search for the executables and the batch file works even if a user has somehow corrupted the value of environment variable PATH.
The executable timeout.exe does not exist by default on Windows XP and older versions of Windows. Therefore an IF condition is used to use either timeout.exe on Windows Vista and newer versions of Windows or pause on older versions of Windows.
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.

*

*cls /?

*color /?

*dir /?

*echo /?

*endlocal /?

*findstr /?

*for /?

*goto /?

*if /?

*pause /?

*rem /?

*set /?

*setlocal /?

*timeout /?

*title /?

*where /?
See also:

*

*Single line with multiple commands using Windows batch file

*DosTips forum topic: ECHO. FAILS to give text or blank line - Instead use ECHO/
Read the Microsoft documentation about Using command redirection operators for an explanation of >nul, 2>nul and |. The redirection operators > and | must be escaped with caret character ^ on FOR command line to be interpreted as literal character when Windows command interpreter processes this command line before executing command FOR which executes the embedded dir command line with using a separate command process started in background with %ComSpec% /c and the command line within ' appended as additional arguments.


text:
Q: Why QQmlAppicationEngine crashes on exit if QApplication is not specifically referenced as parent? I have a simple qml app, following the QmlBook tutorial. The Qml code is as such:
Window {
    id: root
    visible: true
    width: Screen.width / 2
    height: Screen.height / 2
    title: "Happy Windmill"

    onHeightChanged: console.log('new window height: ', height)
    property int spins: 0
    property int fpresses: 0

    Image {
        id: background
        anchors.fill: parent
        source: "assets/background.png"
        MouseArea {
            anchors.fill: parent
            onClicked: {
                wheel.rotation += 90
                incrementSpinCounter()
            }

        }

        Image {
            id: pole
            source: "assets/pole.png"
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.bottom: parent.bottom
            anchors.top: wheel.verticalCenter
        }

        Image {
            id: wheel
            source: "assets/pinwheel.png"
            anchors.centerIn: parent
            Behavior on rotation {
                NumberAnimation {
                    duration: 250
                }
            }
        }
    }
    function incrementSpinCounter(){
        spins += 1
    }

    function incrementFCounter(){
        fpresses += 1
    }
}

I'm running it with the QQmlApplicationEngine using PyQt5. The python code to execute the application is as such:
def run_qml():
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine(parent=app)
    engine.load('main.qml')
    sys.exit(app.exec_())

if __name__ == '__main__':
    run_qml()

Every reference I have seen, the QmlApplicationEngine has always been declared as
engine = QmlApplicationEngine(), however, when I run the code like this, it works, but then crashes when the application is exited with error QPixmap: Must construct a QGuiApplication before a QPixmap. This is fixed when I use engine = QmlApplicationEngine(parent=app) instead.
My question here is why this happens, as I would like to avoid making code decisions without properly understanding what I am doing.


text:
Q: How to open new screens in new JavaFx stages in Angela Caicedo's framework on Managing Multiple Screens in JavaFX I'm using Angela Caicedo's framework to Managing Multiple Screens in my JavaFX application. The problem is that I'd like to have some screens open up in new stages, or pop-ups to open up as pop-ups and not new screens. Could anyone please have a hint on how to go about this using Angela Caicedo's framework.
Here are her tutorials:
Managing Multiple Screens in JavaFX. Part I
Managing Multiple Screens in JavaFX. Part II
Video -> Managing Multiple Screens in JavaFX: here
Thank you all in advance.
EDIT:
If anyone could help with a possible way on how the individual separate screens could be resized, that would be a huge bonus.

A: I use my own MDI-framework. For dialogs I use internal windows from jfxtras library (Now, I start work on highly customizable InternalWindow). You can see sample on my  javafx-MultipleScreens-framework github.


text:
Q: Python - last hour of postfix log I am looking for an effective way of getting the past hour of the maillog log file created by postfix. I want to do that in python or in bash.
So far I have extracted the month and the day that is saved in the postfix log:
now_m = today.ctime().split()[1]
now_d = int(today.ctime().split()[2])

but am stuck over here and need some fresh ideas.
Any help would be greatly appreciated.
Code example:
Apr  2 11:53:15 server01 postfix/bounce[9177]: 62A347FB99: sender non-delivery notification: 6F4B67FB97
Apr  2 11:53:15 server01 postfix/qmgr[8140]: 5E9B07FB95: removed
Apr  2 11:53:15 server01 postfix/qmgr[8140]: 62A347FB99: removed
Apr  2 11:53:15 server01 postfix/qmgr[8140]: 6F5837FB98: from=<>, size=4054, nrcpt=1 (queue active)
Apr  2 11:53:15 server01 postfix/bounce[9182]: 652D67FB9D: sender non-delivery notification: 6F5837FB98
Apr  2 11:53:15 server01 postfix/qmgr[8140]: 652D67FB9D: removed
Apr  2 11:53:15 server01 postfix/qmgr[8140]: 6EE717FB92: from=<>, size=4926, nrcpt=1 (queue active)
Apr  2 11:53:15 server01 postfix/qmgr[8140]: 6F4B67FB97: from=<>, size=3448, nrcpt=1 (queue active)
Apr  2 11:53:15 server01 postfix/smtpd[9163]: disconnect from unknown[10.0.0.4]

and another example:
Aug 30 09:00:56 server01 postfix/qmgr[2321]: 1654A7FB86: removed
Aug 30 09:01:57 server01 postfix/smtpd[4320]: connect from unknown[10.0.0.0]
Aug 30 09:01:57 server01 postfix/smtpd[4320]: disconnect from unknown[10.0.0.0]
Aug 30 09:02:16 server01 postfix/smtpd[4320]: connect from unknown[10.0.0.0]
Aug 30 09:02:16 server01 postfix/smtpd[4320]: 21F077FB86: client=unknown[10.0.0.0]

A: It's simple:
NOW=`date +%s`; THEN=`expr $NOW - 3600`; until (("$THEN" > "$NOW")); do DATE=`date -d @\$THEN +'%b %e %k:%M:%S'`; grep -e "^$DATE" /var/log/maillog && sed -n -e "/^$DATE/,\$p" /var/log/maillog && break; THEN=`expr $THEN + 1`; done

In other words:
1) get current time $NOW
2) get time one hour ago $THEN
3) if there is a line beginning with $THEN, print the line and everything after it (and break the cycle)
4) increment $THEN by one second and repeat until $NOW (or until you find something)
It's not very efficient and not very fast but will probably serve you well.

A: The basic track is to read each line, and parse it's timestamp into a datetime.datetime object. There are several options to do so, e.g using its .fromtimestamp (static) method. Or the more general parsers (see utile)
Then use datetime.datetime.now() and subtract datetime.timedelta(mins=60); the result can be compared to the parsed timestamp.
It as simple as that!
No need to do any manual, work.
PS add an example of the log file/line next time. The we can give the concrete example code


text:
Q: Unable to start a Linux VM in VirtualBox with a "Kernel driver not installed (rc=-1908)" error on macOS even if VirtualBox is reinstalled I am trying to start a Ubuntu (64-bit) Linux VM from VirtualBox (5.2.18 r124319 (Qt5.6.3)) on macOS High Sierra (10.13.6 (17G65)) running on a 2016 MacBook Pro 15"
The MacBook Pro in question is recently restored using my Time Machine Backup. I have enabled FileVault on the original MacBook Pro.
Here is the image of the error dialog box:

The text is:

Kernel driver not installed (rc=-1908)
Make sure the kernel module has been loaded successfully.
where: suplibOsInit what: 3 VERR_VM_DRIVER_NOT_INSTALLED (-1908) - The
  support driver is not installed. On linux, open returned ENOENT.

I have enabled disk level encryption when I set up the Linux VM.
Here is some more details of the VM

It is what I picked up from the system.log
Sep 26 10:15:44 konga-mbp-loaner com.apple.xpc.launchd[1] (org.virtualbox.startup[95]): Service exited with abnormal code: 1

What I tried after the Linux VM failed to start:

*

*I tried to reinstall VirtualBox but the installation failed.

*Restart the machine and try reinstall again, also failed.

A: FWIW, on the latest version of MacOS (Big Sur) I simply had to update VirtualBox to the latest version (and allow the security control mentioned above). Without upgrading I never saw a security control block.

A: I've had VirtualBox installed before but after an Upgrade to Mac OS 11.6 VirutalBox stopped working. Reinstalling VirtualBox didn't help. I also didn't see any option in the Security & Privacy pane.
Finally, this was the only solution that worked for me:
https://ilgthegeek.wordpress.com/2018/01/27/macos-install-oracle-virtualbox-on-10-13/
Reboot your Mac into Recovery Mode, then type:
spctl kext-consent add VB5E2TV963

VB5E2TV963 is Oracle's Developer ID

A: MACOS Catalina 2020
Run following command and to clear vmBox
sudo kextcache --clear-staging

after that reinstall virtualBox and go to your Preferences --> security & privacy -->select General

you will see a allow option there you have to allow that .

NOTE:- that allow option will be there only for 30 min after you installed VMBox,
otherwise you have to do install again.

A: Basically it is because Apple has blocked some extensions from loading. After unblocking them I can reinstall VB as expected.

A: COMMENTING INCASE ANYONE SEES THIS THREAD AND NEEDS HELP IN THE PRESENT.
I would get the same install error. I decided to open the application anyways to see if I could figure more things out. I could open the application and make new systems, but when trying to open and install those systems I would get a Kernel Driver Not Installed rc =- 1908 error.
I did every step I could find on these threads, updated computer (MAC High Sierra 10.13.6), temporarily disabled security preferences through terminal, deleted installer and application and tried other previous downloads for VirtualBox. The fix was so easy in the end!
It was a "kernel" error, so when installing VirtualBox I clicked "customize" instead of the regular install. You will see multiple things checked off that is included in the standard install. Just click on the one that has "kernel" in the name so it is highlighted, and then the install button on the bottom right. For some reason it was not installing the Kernel Driver with the package, despite it being selected to install. I just had to single it out!
Hope this helps another struggling Mac user. I really need to get a new computer lol

A: Make sure that you move the old .app to trash before re-installing virtualbox.
Check Security & Privacy as mentioned by others in case it was locked out by the system.


text:
Q: How can I show that every eigenvectors can be chosen to be orthogonal? If $A$ is symmetric (real) matrix,
CASE 1: $\lambda$ distinct $\rightarrow$ eigenvectors are orthonormal
CASE 2: $\lambda$ not distinct $\rightarrow$ eigenvectors are orthogonal (and then they can be normalized)
I'm focusing on CASE 2.
It is trivial becuase every symmetric matrix can be diagonalized by orthogonal matrix.
But I want to show that mathematically. (eg. inner product, etc...)
Also, in CASE 2, the number of eigenvectors are equal to multiplicity of eigenvalues. Why they can not exceed that? (It's trivial too, but I want to show it precisely!)
We can conclude this by constructing an orthonormal basis of $R^n$ using eigenvectors of $A$.
I think I know principal theorems related to them but have problems with applying them.
Please help me and don't just throw a hint, I need detailed explanation!
Thanks.

A: In your CASE 1, actually the eigenvectors are orthogonal, and you can normalize them so they are orthonormal.  In your CASE 2, eigenvectors corresponding to different eigenvalues are orthogonal, as it seems you know.  But eigenvectors corresponding to the same eigenvalue are not necessarily orthogonal unless you construct them or modify them so that they are.  For any eigenvalue $\lambda$ whose eigenspace $\{\mathbf{x} \mid A\mathbf{x}=\lambda \mathbf{x}\}$ has dimension greater than $1$ (which occurs if you have "repeated eigenvalues"), use the Gram-Schmidt procedure to find an orthonormal basis for that eigenspace.  The Gram-Schmidt procedure is in any linear algebra book and probably on Wikipedia so I won't retype it here.  The Gram-Schmidt procedure can be used on any finite-dimensional inner product space and your eigenspace here is such an inner product space.
You also asked why, roughly speaking, the number of eigenvalues is the same as the number of eigenvectors for a real symmetric matrix.  This question has been asked and answered here: geometric multiplicity= algebraic multiplicity for a symmetric matrix
The "geometric multiplicity" of an eigenvalue is the dimension of its eigenspace, and the "algebraic multiplicity" is the multiplicity of the eigenvalue as a root of the characteristic polynomial.
Of course, I am only talking about real matrices, and when I use the word "dimension" I am using the field of real numbers.

A: We can suppose that $A$ is diagonal, with real entries, which are the eigenvalues of $A$. That is, $A$ has the form $A = \begin{bmatrix} \lambda_1 & & \\ & \ddots & \\ & & \lambda_n\end{bmatrix}$, with eigenvalues $\lambda_1,...,\lambda_n$.
Let $I_\lambda = \{ k \in \{ 1,...,n\}  | \lambda_k = \lambda \}$ be the indices for eigenvalues equal to $\lambda$. The algebraic multiplicity of eigenvalue $\lambda_k$ is then given by $| I_{\lambda_k} |$.
Then it is straighforward to see that $A v = \lambda v$ (equivalently $v \in \ker (A-\lambda I)$) iff $[v]_k = 0 $ for all $k \notin I_\lambda$.
So, suppose $\lambda$ is an eigenvalue, and let $E = \ker (A- \lambda I)$. Then we want to show that $\dim E = | I_\lambda |$.
We see that $v \in E$ iff $v \in \operatorname{sp} \{e_k\}_{k \in I_\lambda}$, that is $E = \operatorname{sp} \{e_k\}_{k \in I_\lambda}$. It follows from this that $\dim E = | I_\lambda |$.
We note that the $\{e_k\}_{k \in I_\lambda}$ are orthogonal, so
obviously we can choose an orthogonal basis for the eigenspace $E$.


text:
Q: Can jacksons ObjectMapper serialize Java-null as empty String, in Version 2.11.2 I'm using the com.fasterxml.jackson.databind.ObjectMapper in jackson-databind 2.11.2 and trying to serialize Java properties with null-value to something like this:
{ %Key% : "" }

I've tried:
ObjectMapper MAPPER = new JodaMapper();

DefaultSerializerProvider defaultSerializerProvider = new DefaultSerializerProvider.Impl();

defaultSerializerProvider.setNullValueSerializer(new JsonSerializer<Object>() {
   @Override
   public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
      gen.writeString("bla");
   }
});

MAPPER.setSerializerProvider(defaultSerializerProvider);

But the NullValueSerializers serialize-method does not get triggered for any fields.
Has anybody some ideas?

A: I found the solution.... I had
@JsonInclude(JsonInclude.Include.NON_NULL)

at class level in the class that I wanted to serialize. When I remove the annotation I the code above works.

A: There are a couple of ways to achieve custom null value serialising:

*

*If you want to serialise a null as an empty String, try using this annotation on a property, or setter:
 @JsonSetter(nulls=Nulls.AS_EMPTY)

or the same for specific mapper:
MAPPER.configOverride(String.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY));

*You can initialise properties with default values on the declaration or in the getter.

*As you've already mentioned, by providing a custom serialiser.

I did try your code, and that serialised null value as expected when using an ObjectMapper instead of JodaMapper. Is there any particular reason for using a JodaMapper?


text:
Q: How to use blobs > 1GB in zodb relstorage with sqlite backend? I am trying to save a blob > 1GB via relstorage in a sqlite backend. The following minimum working example

*

*removes any previously created databases along with the blob directory,

*create a new database and

*saves a blob with 1GB to the database.

Minimum Working Example:
import os
import shutil
from ZODB import blob, config

connectionString = """
%import relstorage
<zodb main>
<relstorage>
    blob-dir blob
    keep-history false
    cache-local-mb 0
    <sqlite3>
        data-dir .
    </sqlite3>
</relstorage>
</zodb>
"""

# cleaning up
for x in os.listdir():
    if "sqlite" in x:
        os.remove(x)

shutil.rmtree("blob", True)

# creating database
db = config.databaseFromString(connectionString)

with db.transaction() as conn:
    conn.root.blob = blob.Blob()
    with conn.root.blob.open("w") as f:
        f.write(b"\0" * 1024 ** 3)

During the commit (at the __exit__ method of the db.transaction with-block) of the newly created object an error occurs with the following final exception:

sqlite3.InterfaceError: Error binding parameter 2 - probably unsupported type.

Saving a blob with size 1024 ** 2 does not raise the exception.
How is it possible to save a blob in a sqlite backend using relstorage without the usage of a shared blob directory?

A: According to my research, you can't store arbitrary sized blobs in this setup.  You are hitting the sqlite blob size limit (https://www.sqlite.org/limits.html).
Your only options at this stage appear to be:

*

*Don't store the blob in sqlite, e.g. by using a shared blob directory.

*Increase the blob limit, using a custom build of sqlite (as covered in the above link).

*Decrease the size of what you store - e.g. by compressing your blobs, or chunking your data into smaller blobs.

*Move to a different storage backend.

Personally, I would be inclined to use the shared blob directory if I was using sqlite, but you have discounted that option, so I think your choices are limited.

A:
I am trying to save a blob > 1GB via relstorage in a sqlite backend.

A related answer is this one.
My suggestion would be to handle differently large blobs (e.g. bigger than 8 to 32MBytes in 2020) and small ones.
Large content would be saved as files, and your sqlite database would know (and store) the file path (e.g. some generated file path such as /var/tmp/bigblob1234 on Linux. See hier(7) and inode(7)...).
Small content would be saved as SQLITE blobs.
Of course both your database schema and the Python code using it should be improved. Be aware of database normalization.