text:
Q: System.Text.Json won't deserialize to my type even though my constructor implements every property I can't figure out why System.Text.Json won't deserialize this simple JSON string to my specified .NET type. I'm getting the Each parameter in the deserialization constructor on type 'MenuItem' must bind to an object property or field on deserialization. Each parameter name must match with a property or field on the object. The match can be case-insensitive error message, even though I have mapped every property — name, url, and permissions — in my MenuItem constructor.
Dotnet fiddle demo
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;

public class Program
{
    public static void Main()
    {
        try
        {
            var json = @"
                [
                    {
                        ""name"": ""General Info"",
                        ""url"": ""/Info"",
                        ""permissions"": []
                    },
                    {
                        ""name"": ""Settings"",
                        ""url"": ""/Settings"",
                        ""permissions"": [
                            ""Admin""
                        ]
                    }
                ]";

            Console.WriteLine(json);
            var menu = new Menu(json);
            Console.WriteLine("Deserialization success");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error: {ex.Message}");
        }
    }
}

public class Menu
{
    public Menu(string json)
    {
        var items = JsonSerializer.Deserialize<List<MenuItem>>(json);
        MenuItems = items.AsReadOnly();
    }

    public IReadOnlyList<MenuItem> MenuItems { get; }
}

public class MenuItem
{
    [JsonConstructor]
    public MenuItem
        (
            string name,
            string url,
            List<Permission> permissions
        )
    {
        this.Name = name;
        this.Url = url;
        this.Permissions = (permissions ?? new List<Permission>()).AsReadOnly();
    }

    public string Name { get; }
    public string Url { get; }
    public IReadOnlyList<Permission> Permissions { get; }
}

public enum Permission
{
    Admin,
    FinancialReporting
}

Can anyone tell me what I'm doing wrong?

A: I've had a look at your fiddle and spotted a couple of problems. Working fiddle here

*

*System.Text.Json is case-sensitive by default (except for web apps). You can resolve this by using either PropertyNamingPolicy = JsonNamingPolicy.CamelCase or PropertyNameCaseInsensitive = true in the serializer options.

*The second issue is outlined in Enums as strings

By default, enums are serialized as numbers. To serialize enum names
as strings, use the JsonStringEnumConverter.

You should add JsonSerializerOptions to resolve (1) and (2):
var options = new JsonSerializerOptions
{
    Converters =
    {
        new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)
    },
    PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var items = JsonSerializer.Deserialize<List<MenuItem>>(json, options);

*The third issue appears to be with the binding in the constructor
for the list of Permissions.  In the constructor you define a
List<Permission> for the permissions parameter.  I receive the
error in your question unless the constructor argument type matches
the model property type exactly.  So, I updated the constructor to
take a IReadOnlyList<Permission> and it deserializes successfully:
[JsonConstructor]
public MenuItem
    (
        string name,
        string url,
        IReadOnlyList<Permission> permissions
    )
{
    this.Name = name;
    this.Url = url;
    this.Permissions = permissions ?? new List<Permission>().AsReadOnly();
}

Alternatively, you could change the Permissions property to List<Permission>.
This answer to a question with a similar problem explains that this is actually a limitation of System.Text.Json and there is currently an open github issue.
A working fork of your fiddle is demoed here.

A: I had the same issue. The solution is to use

JsonSerializable

attribute of

System.Text.Json.Serialization

It looks like:
[JsonSerializable(typeof(YourClassName))]
public class YourClassName
{
    public byte YourPropertyName { get; set; }
}

Always class and always public and always properties and always use the attribute on the class.


text:
Q: Issues with Selecting Date Ranges in SQL Server I need to return results between 01/01/2019 and 08/13/2019. I am having trouble with the date ranges.
First I tried the SQL below using the commented out piece and I received all dates.  Then I tried using the # method that I have below and I am receiving the following error:

Msg 102, Level 15, State 1, Line 25
  Incorrect syntax near '#'

I think there might be an issue with how the dates are formatted in the db (which I have no control over) but I tried using
Format(b.QualifyingEventDate, "yyyymmdd")

but that didn't work.
I've been working on this all afternoon ad it seems like it should be a simple query. Any help would be much appreciated. Thank you.
SELECT
    a.GroupID,
    c.employername,
    b.QualifyingEventDate, b.QualifyingEventType
FROM
    MST_MEMBER_DEMOGRAPHICS AS a
JOIN
    DET_ENROLLMENT_DETAILS AS b ON a.BFUNIQUEID = b.BFUNIQUEID
JOIN
    MST_EMPLOYER_GROUP_MASTER AS c ON a.groupid = c.groupid
WHERE
    a.GroupID = TestClient
    AND QualifyingEventType <> 'NULL'
    --and QualifyingEventDate between '01/01/2019' and '08/13/2019'
    AND QualifyingEventDate > #01/01/2019#
    AND QualifyingEventDate < #08/13/2019#
ORDER BY
    b.QualifyingEventDate, a.groupid, b.QualifyingEventType

A: The WHERE clause, assuming you want inclusive, should be this:
WHERE a.GroupID = TestClient
  and QualifyingEventType IS NOT NULL -- notice 'IS NOT' instead of '<>'
  and QualifyingEventDate between '2019-01-01 00:00:00' and '2019-08-13 23:59:59'

This is assuming that QualifyingEventDate is a datetime data type.  Not including the time component could potentially cause some casting issues with date.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Finding the maximum value from a derivative function I am having problems understanding how to find the maximum value from a rate of change (derivative) function. The rate of change of Volume with respect to time is $\frac{dv}{dt}=1000- 30t^2 +2t^3$,  $0 \le t \le 15$
How do I find the maximum rate of change? the answers is where $t=0$ and $t=15$, but I can't see how this is done?

A: Relative extrema occur at endpoints or critical points. Critical points occur where a function's derivative is $0$ or undefined.
The maximum of $\frac{dv}{dt}$ is where $\frac{d^2v}{dt^2}=0$ or is undefined.
\begin{align*}
\frac{d^2v}{dt^2} &= -60t + 6t^2 =0 \\
0 &= 6t(t - 10) \\
t&=0, \ t=10
\end{align*}
So $\frac{dv}{dt}$ has critical points at $t=0,10$. Now you have to find $\frac{dv}{dt}(0)$, $\frac{dv}{dt}(10)$, and $\frac{dv}{dt}(15)$ and see which one has the highest value to find the max.
\begin{align*}
\frac{dv}{dt}(0)\ \ &= 1000 \\
\frac{dv}{dt}(10) &= 0 \\
\frac{dv}{dt}(15) &= 1000
\end{align*}
On the domain $[0,15]$, $\frac{dv}{dt}$ has a maximum value of $1000$ at $t=0,15$.


text:
Q: Not able to automatically login Hey I'd like to login automatically, but havnt gotten the option to do so.
I have tried some hints and stuff
But nothing has worked so far.
Im running 12.10 and have xbmc installed(dont know if it matters, the xbmc).
Here is 2 screenshots of how my settings look.

the last 2 lines i have put in myself. (har restarted after, didnt work and below you see user accounts settings, from after reboot)

A: I believe it won't work if you home directory is encrypted.
Unencrypt Home Directory
Autologin disabled


text:
Q: How to use ajax request to send friend request in views.py without reloading page With my limited Knowledge of ajax requests,I wrote this function which uses a get request to send friend requests when the add button is pressed,but when I run local host,the code seems not to be working and I can't figure out why.
Html template:
{% extends "posts/base.html" %}
{% load crispy_forms_tags %}

        {% block content %}

<form method="POST" class="form-signin">
            {% csrf_token %}

            {{ form|crispy }}

            <button class="btn btn-lg btn-primary btn-block text-uppercase" type="submit">Search</button>
            </form>

            {{ results.username }}

            <button class="btn btn-sm btn-circle mt-1 mb-1" onclick="add-friend" value="{{ results.username }}">+</button>

{% endblock content %}

Views.py:
from django.shortcuts import render
from .models import AddFriend
from django.contrib.auth.models import User
from users.models import Profile

def SearchDetail(request):
    Ruser= None
    if request.method == 'GET':
        username= request.GET['username']
        Ruser= User.objects.get(username=username)
        NewFriendRequest=None
        NewFriendRequest=AddFriend.objects.create(sender=request.user,receiver=Ruser)
        NewFriendRequest.save()
        messages.success(request, f'Your friend request has been sent successfully!')

Urls.py:
urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('users.urls')),
    path('posts/home.html', p_views.PostsListView.as_view(), name='posts-home'),
    path('friends/search.html', f_views.search, name='friends-search'),
    path('friends/add-friend/', f_views.SearchDetail, name='friends-search-detail'),
]

A: Give this a try

Remove onclick="add-friend" from
<button class="btn btn-sm btn-circle mt-1 mb-1"  value="{{ results.username }}">+</button>

Ref


text:
Q: Nuxt store mutation recieving TypeError I set up a simple store in store/index.js that looks like this:
export const state = () => ({
    isDark: false,
});

export const mutations = {
    setIsDark(state, payload) {
        state.isDark = payload;
    },
};

export const getters = {
    getIsDark(state) {
        return state.isDark;
    },
};

I'm able to get isDark in my component but when I try to call setIsDark I get a error:
TypeError: Cannot read property 'setIsDark' of undefined

My component:
computed: {
    isDark() {
        return this.$store.getters.getIsDark;
    },
},

methods: {
    toggleIsDark() {
        this.$store.mutations.setIsDark(!this.isDark);
    },
},

What am I doing wrong?

A: The syntax for calling a mutation is:
this.$store.commit('setIsDark', !this.isDark);

For an action, it's:
this.$store.dispatch('setIsDark', !this.isDark);


text:
Q: Summing columns contents in a multi index dataframe in Pandas Dataframe sample
I have this multi- index data frame with multi level columns and indices. For the columns, the highest level is the floors (ground floor- first floor..etc) and then the next level is apartments and finally the rooms. In the rooms level I have for each room 7 columns [1_B4_QHEAT-, 1_B4_QCOOL+, 1_B4_QINF+, 1_B4_QVENT+,    1_B4_QTRANS+,   1_B4_QGINT+,    1_B4_QSOL+].
The number in the beginning of the title is the room number and it goes from 1 to 67. Is there a way to sum the contents of each similar columns for each apartment without having to do it manually?
Example: I want to automate:
df['Qcool_apt1'] = df['1_B4_QCOOL+'] + df['2_B4_QCOOL+'] + df['3_B4_QCOOL+']
df['Qcool_apt2'] = df['4_B4_QCOOL+'] + df['5_B4_QCOOL+'] + df['6_B4_QCOOL+']

Thanks
Part of the source code of the dataframe: df.head().to_dict()
{('G.F', 'G.F_apt1', '1_B4_QHEAT-'): {(1.0, 1.0, 1.0): 0.0,
  (1.0, 1.0, 2.0): 0.0,
  (1.0, 1.0, 3.0): 0.0,
  (1.0, 1.0, 4.0): 0.0,
  (1.0, 1.0, 5.0): 0.0,
  (1.0, 1.0, 6.0): 0.0,
  (1.0, 1.0, 7.0): 0.0,
  (1.0, 1.0, 8.0): 0.0,
  (1.0, 1.0, 9.0): 0.0,
  (1.0, 1.0, 10.0): 0.0},
 ('G.F', 'G.F_apt1', '1_B4_QCOOL+'): {(1.0, 1.0, 1.0): 0.0,
  (1.0, 1.0, 2.0): 0.0,
  (1.0, 1.0, 3.0): 0.0,
  (1.0, 1.0, 4.0): 0.0,
  (1.0, 1.0, 5.0): 0.0,
  (1.0, 1.0, 6.0): 0.0,
  (1.0, 1.0, 7.0): 0.0,
  (1.0, 1.0, 8.0): 0.0,
  (1.0, 1.0, 9.0): 0.0,
  (1.0, 1.0, 10.0): 0.0},
 ('G.F', 'G.F_apt1', '1_B4_QINF+'): {(1.0, 1.0, 1.0): -0.010019444444444444,
  (1.0, 1.0, 2.0): -0.012180555555555556,
  (1.0, 1.0, 3.0): -0.01233611111111111,
  (1.0, 1.0, 4.0): -0.012338888888888889,
  (1.0, 1.0, 5.0): -0.013033333333333334,
  (1.0, 1.0, 6.0): -0.013419444444444446,
  (1.0, 1.0, 7.0): -0.013686111111111112,
  (1.0, 1.0, 8.0): -0.014041666666666666,
  (1.0, 1.0, 9.0): -0.013361111111111112,
  (1.0, 1.0, 10.0): -0.011313888888888887},
 ('G.F', 'G.F_apt1', '1_B4_QVENT+'): {(1.0, 1.0, 1.0): -0.05011111111111111,
  (1.0, 1.0, 2.0): -0.06088888888888889,
  (1.0, 1.0, 3.0): -0.06169444444444444,
  (1.0, 1.0, 4.0): -0.06169444444444444,
  (1.0, 1.0, 5.0): -0.06516666666666666,
  (1.0, 1.0, 6.0): -0.06708333333333333,
  (1.0, 1.0, 7.0): -0.06841666666666667,
  (1.0, 1.0, 8.0): -0.07022222222222223,
  (1.0, 1.0, 9.0): -0.06680555555555556,
  (1.0, 1.0, 10.0): -0.05655555555555555},
 ('G.F', 'G.F_apt1', '1_B4_QTRANS+'): {(1.0, 1.0, 1.0): -0.26725,
  (1.0, 1.0, 2.0): -0.2573333333333333,
  (1.0, 1.0, 3.0): -0.25233333333333335,
  (1.0, 1.0, 4.0): -0.2554166666666667,
  (1.0, 1.0, 5.0): -0.2500277777777778,
  (1.0, 1.0, 6.0): -0.24869444444444444,
  (1.0, 1.0, 7.0): -0.15308333333333335,
  (1.0, 1.0, 8.0): -0.18811111111111112,
  (1.0, 1.0, 9.0): -0.10619444444444445,
  (1.0, 1.0, 10.0): -0.11352777777777777},
 ('G.F', 'G.F_apt1', '1_B4_QGINT+'): {(1.0, 1.0, 1.0): 0.32861111111111113,
  (1.0, 1.0, 2.0): 0.32861111111111113,
  (1.0, 1.0, 3.0): 0.32861111111111113,
  (1.0, 1.0, 4.0): 0.32861111111111113,
  (1.0, 1.0, 5.0): 0.32861111111111113,
  (1.0, 1.0, 6.0): 0.32861111111111113,
  (1.0, 1.0, 7.0): 0.23591666666666666,
  (1.0, 1.0, 8.0): 0.23591666666666666,
  (1.0, 1.0, 9.0): 0.058583333333333334,
  (1.0, 1.0, 10.0): 0.058583333333333334},
 ('G.F', 'G.F_apt1', '1_B4_QSOL+'): {(1.0, 1.0, 1.0): 1.1119444444444444e-15,
  (1.0, 1.0, 2.0): 3.0916666666666665e-15,
  (1.0, 1.0, 3.0): 7.061111111111111e-16,
  (1.0, 1.0, 4.0): 8.877777777777779e-17,
  (1.0, 1.0, 5.0): 1.1541666666666667e-15,
  (1.0, 1.0, 6.0): -1.7122222222222222e-15,
  (1.0, 1.0, 7.0): 4.913888888888889e-17,
  (1.0, 1.0, 8.0): 0.035083333333333334,
  (1.0, 1.0, 9.0): 0.11869444444444445,
  (1.0, 1.0, 10.0): 0.13019444444444445},
 ('G.F', 'G.F_apt1', '2_B4_QHEAT-'): {(1.0, 1.0, 1.0): 0.0,
  (1.0, 1.0, 2.0): 0.0,
  (1.0, 1.0, 3.0): 0.0,
  (1.0, 1.0, 4.0): 0.0,
  (1.0, 1.0, 5.0): 0.0,
  (1.0, 1.0, 6.0): 0.0,
  (1.0, 1.0, 7.0): 0.0,
  (1.0, 1.0, 8.0): 0.0,
  (1.0, 1.0, 9.0): 0.0,
  (1.0, 1.0, 10.0): 0.0},
 ('G.F', 'G.F_apt1', '2_B4_QCOOL+'): {(1.0, 1.0, 1.0): 0.0,
  (1.0, 1.0, 2.0): 0.0,
  (1.0, 1.0, 3.0): 0.0,
  (1.0, 1.0, 4.0): 0.0,
  (1.0, 1.0, 5.0): 0.0,
  (1.0, 1.0, 6.0): 0.0,
  (1.0, 1.0, 7.0): 0.0,
  (1.0, 1.0, 8.0): 0.0,
  (1.0, 1.0, 9.0): 0.0,
  (1.0, 1.0, 10.0): 0.0},
 ('G.F', 'G.F_apt1', '2_B4_QINF+'): {(1.0, 1.0, 1.0): -0.014025000000000001,
  (1.0, 1.0, 2.0): -0.01704722222222222,
  (1.0, 1.0, 3.0): -0.017252777777777777,
  (1.0, 1.0, 4.0): -0.017258333333333334,
  (1.0, 1.0, 5.0): -0.01822222222222222,
  (1.0, 1.0, 6.0): -0.018758333333333335,
  (1.0, 1.0, 7.0): -0.019163888888888887,
  (1.0, 1.0, 8.0): -0.019674999999999998,
  (1.0, 1.0, 9.0): -0.01864722222222222,
  (1.0, 1.0, 10.0): -0.01573888888888889},
 ('G.F', 'G.F_apt1', '2_B4_QVENT+'): {(1.0, 1.0, 1.0): -0.07011111111111111,
  (1.0, 1.0, 2.0): -0.08522222222222223,
  (1.0, 1.0, 3.0): -0.08627777777777779,
  (1.0, 1.0, 4.0): -0.08630555555555555,
  (1.0, 1.0, 5.0): -0.09111111111111111,
  (1.0, 1.0, 6.0): -0.09380555555555556,
  (1.0, 1.0, 7.0): -0.09580555555555555,
  (1.0, 1.0, 8.0): -0.09838888888888889,
  (1.0, 1.0, 9.0): -0.09322222222222223,
  (1.0, 1.0, 10.0): -0.07869444444444444},
 ('G.F', 'G.F_apt1', '2_B4_QTRANS+'): {(1.0, 1.0, 1.0): -0.3169444444444444,
  (1.0, 1.0, 2.0): -0.30416666666666664,
  (1.0, 1.0, 3.0): -0.29638888888888887,
  (1.0, 1.0, 4.0): -0.3013888888888889,
  (1.0, 1.0, 5.0): -0.29333333333333333,
  (1.0, 1.0, 6.0): -0.29194444444444445,
  (1.0, 1.0, 7.0): -0.21258333333333332,
  (1.0, 1.0, 8.0): -0.2489722222222222,
  (1.0, 1.0, 9.0): -0.0888611111111111,
  (1.0, 1.0, 10.0): -0.0931111111111111},


text:
Q: JQuery Taconite C# helper I'm writing a helper class to wrap the functionality of JQuery Taconite plugin. The plugin enables you to process multiple DOM updates in a single Ajax call.
The class simply enables you to construct the appropriate xml structure that is sent back to the client. I'm trying to wrap this functionality in a fluent interface. The basic example looks like this:
FluentTaconite ft = new FluentTaconite(writer);
ft
   .Select("#id1").ReplaceContentWith("Hello World!").FadeIn("100")
   .Select("#id2").AppendWith("
Another div
")
return ft.Output();

What I'm worried about is this, what structure would you expect be created after a call to this:
ft.Select("#A").AppendWith("
").AppendWith("div id=C/>")

Is your expectation to build:

Or:

The question is - are you expecting context to shift to a newly added content or remain at the selector?
Update
The project in question is uploaded to code.google. Hope you find it useful.
Thanks for the input!

A: I expect it to remain at selector. Look at the following sample:
ft.Select("#A").Append("
").Select("#B").Append("div id=C/>").End().Append("
");

I expect the following output:

AppendWith imo is too noisy, it's enough of simple Append. 'End' method has similar functionality to JQuery's one.
And I have one more question, are you sure that this will be more usable in comparison with javascript code?


text:
Q: How to fit a normal cumulative distribution function to data I have generated some data which is effectively a cumulative distribution, the code below gives an example of X and Y from my data:
X<- c(0.09787761, 0.10745590, 0.11815422, 0.15503521, 0.16887488, 0.18361325, 0.22166727,
0.23526786, 0.24198808, 0.25432602, 0.26387961, 0.27364063, 0.34864672, 0.37734113,
0.39230736, 0.40699061, 0.41063824, 0.42497043, 0.44176913, 0.46076456, 0.47229330,
0.53134509, 0.56903577, 0.58308938, 0.58417653, 0.60061901, 0.60483849, 0.61847521,
0.62735245, 0.64337353, 0.65783302, 0.67232004, 0.68884473, 0.78846000, 0.82793293,
0.82963446, 0.84392010, 0.87090024, 0.88384044, 0.89543314, 0.93899033, 0.94781219,
1.12390279, 1.18756693, 1.25057774)

Y<- c(0.0090, 0.0210, 0.0300, 0.0420, 0.0580, 0.0700, 0.0925, 0.1015, 0.1315, 0.1435,
0.1660, 0.1750, 0.2050, 0.2450, 0.2630, 0.2930, 0.3110, 0.3350, 0.3590, 0.3770, 0.3950,
0.4175, 0.4475, 0.4715, 0.4955, 0.5180, 0.5405, 0.5725, 0.6045, 0.6345, 0.6585, 0.6825,
0.7050, 0.7230, 0.7470, 0.7650, 0.7950, 0.8130, 0.8370, 0.8770, 0.8950, 0.9250, 0.9475,
0.9775, 1.0000)

plot(X,Y)

I would like to obtain the median, mean and some quantile information (say for example 5%, 95%) from this data. The way I was thinking of doing this was to fit a defined distribution to it and then integrate to get my quantiles, mean and median values.
The question is how to fit the most appropriate cumulative distribution function to this data (I expect this may well be the Normal Cumulative Distribution Function).
I have seen lots of ways to fit a PDF but I can't find anything on fitting a CDF.
(I realise this may seem a basic question to many of you but it has me struggling!!)
Thanks in advance

A: Perhaps you could use nlm to find parameters that minimize the squared differences from your observed Y values and the expected for a normal distribution. Here an example using your data
fn <- function(x) {
   mu <- x[1];
   sigma <- exp(x[2])
   sum((Y-pnorm(X,mu,sigma))^2)
}
est <- nlm(fn, c(1,1))$estimate

plot(X,Y)
curve(pnorm(x, est[1], exp(est[2])), add=T)

Unfortunately I don't know an easy with with this method to constrain sigma>0 without doing the exp transformation on the variable. But the fit seems reasonable


text:
Q: Area of the intersection of four circles of equal radius
This picture basically shows a rearrangement of four quarters of a circle of radius 1. It asks for the shaded area.
I got the answer to be $\frac{2\pi + 6}{13}$. But then it is incorrect.
The way I did it is by rearranging the four pieces into respectively a circle a square and a larger square with a inscribed circle. And naming each different pieces in the picture as x y and z.

A:
To figure out the area of the shape you described, we can split it into two parts: the area in the square, and the part just outside it. For both, we need to find out the angle between which each circle intersects. We can find this easily by using the equations of circle. To find the top intersection, consider $x^2+y^2=1$ and $(x-1)^2+y^2=1$. These circles intersect at $(\frac12,\frac{\pm\sqrt3}{2})$, which is at an angle of $\frac\pi3$ with the x-axis. Similarily, the coordinates of the right point make an angle of $\frac\pi6$ with the x-axis. Hence, each circle intersects in an angle of $\frac\pi6$.
Now to find the areas. To find the areas of the four smaller sections between the square and circles, it is the area of the sector minus the triangle in the sector. Hence the area of each is
$$\frac12\cdot\frac\pi6-\frac12\sin\left(\frac\pi6\right)=\frac\pi{12}-\frac14$$.
Now for the square. If the side length of the the square is $s$, then by connecting the top and right points with the bottom left point of the big square, we create a triangle with sides $1,1$ and $s$, and the angle between the 1s is $\frac\pi6$. By the cosine rule, the area of the square is
$$s^2=1^2+1^2-2\cos\left(\frac\pi6\right)=2-\sqrt3$$
Hence, the area of the shape between the four circles is
$$4\left(\frac\pi{12}-\frac14\right)+(2-\sqrt3)=\frac\pi3+1-\sqrt3$$
No calculus required.
Alternatively:

Consider the set of parametric equations $x(t)=\cos(t)-\frac12,y(t)=\sin(t)-\frac12$. This is the equation of the circle centred at the bottom left point. Point $D$ is a $t=0$, E at $t=\frac\pi6$, and $F$ at $t=\frac\pi3$. Hence, the centre area is 4 times the area between $F$ and $E$, so its area is
$$4\int_{t=\frac\pi3}^{t=\frac\pi6} y \,dx=-4\int_{\frac\pi6}^{\frac\pi3}y(t)x'(t)\,dt=4\int_{\frac\pi6}^{\frac\pi3}\left(\sin(t)-\frac12\right)\sin(t)\,dt=\frac\pi3+1-\sqrt3$$

A: Consider; What about trying to fit a rectangle in a quarter area?
As a rectangle is 2 x triangles, using the Pythagorean Theorem is handy. $1^2 = x^2 + {\frac{1}{2}}^2$
Thus we can figure out that $x = \sqrt{\frac{3}{2}}$, then integrate to get the area under the curve where there would be no rectangle.
Let $A$ denote the area,
$$A = \int^{\frac{\pi}{3}}_{\frac{\pi}{6}} \frac{1}{2}(1-\sin(2u))\,du = \frac{\pi}{12}$$
and let $R$ denote the area of the rectangle, and $S$ denote the shaded region,
$$R=\frac{1}{2}(\sqrt{\frac{3}{2}} - \frac{1}{2}) = \frac{\sqrt{3} -1}{4}$$
Which leaves us with $$\frac{S}{4} = A-R \implies\\ S = \frac{\pi}{3} - \sqrt{3} + 1$$

Also, googling "quarter circles" gives a pretty few good results...

A: Note that we could use the first quadrant and then get the final answer by symmetry. We have three quarter-circles in this region with the equations$$\begin{array}{l}{C_1}:{\left( {x - \frac{1}{2}} \right)^2} + {\left( {y + \frac{1}{2}} \right)^2} = 1\\{C_2}:{\left( {x + \frac{1}{2}} \right)^2} + {\left( {y - \frac{1}{2}} \right)^2} = 1\\{C_3}:{\left( {x + \frac{1}{2}} \right)^2} + {\left( {y + \frac{1}{2}} \right)^2} = 1\end{array}$$we want to obtain the area beneath ${C_3}$ (to the $x$-axis) but to obtain the endpoint, we have to find the cross point of ${C_2}$ and ${C_3}$, which is $$\begin{array}{l}x = \frac{{\sqrt 3  - 1}}{2}\\y = 0\end{array}$$now, the final answer is $$I = 4\int\limits_0^{\frac{{\sqrt 3  - 1}}{2}} {\left( { - \frac{1}{2} + \sqrt {1 - {{\left( {x + \frac{1}{2}} \right)}^2}} } \right)dx}  = 1 - \sqrt 3  + \frac{\pi }{3}$$

A: To solve this problem, the only tool that you need is:-
(P ∩ Q) = (P) + (Q) – (P ∪ Q)
The following is an example.


text:
Q: Facebook Gameroom assetbundle We are using Unity 5.6.
In our Unity game we have asset bundles. While porting the game to Facebook Gameroom, we wanted to handle asset bundle.
Currently we are not able to find the build target as GameRoom while creating the asset bundle.
Is it possible to create asset bundle for Gameroom? IF yes then what is the build target we need to select during creation of the asset bundle.


text:
Q: bootstrap issue, "fileupload" not working inside of a modal So, i am using a bootstrap modal, and inside of the modal, i want to use image upload, but when an image is selected, nothing happens, i am asuming it is a javascript issue, the script and the css is included outside of the modal in the header.
http://jasny.github.com/bootstrap/javascript.html#fileupload
Any suggestions? I asume it is a javascript issue
<?php
if (isset($_SESSION['login']) and !empty($_SESSION['login']) and $_SESSION['rank'] == 3) {

echo '

       <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>

Insert Post

    <form action="insert_post_sql" method="post" enctype="multipart/form-data">

    Select image
        Change<input type="file" />
        Remove

     </form>

     <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
     <input type="submit" button class="btn btn-primary" value="Submit Post">

   </form>
   ';
}
?>

A: Try to use Document Ready function because the Script is loaded prior to the Modal HTML
 $('document').ready(function(){
        $('#insert_post_modal').on('shown', function(){

           $('.fileupload').fileupload();

        });

    });

A: Try calling the fileupload on modal shown (i.e. when the user opens it):
$('#insert_post_modal').on('shown', function(){

   $('.fileupload').fileupload();

});

Can't test it right now though, I'm sorry

A: $(document).ready(function(){
$image_crop = $('#image_demo').croppie({
enableExif: true,
viewport: {
width:300,
height:300,
type:'square' //circle
},
boundary:{
width:400,
height:400
}
});


text:
Q: Multiple the same forms and POST method? I have multiple instances of the same form (name / email / message fields) on one page. They all share one class ('.contact-form') and different (dynamically generated IDs).
I validate them using jQuery Tools Validator (it's not relevant though as I have no problems with this at all):
$(".contact-form").validator();

The problem lies in my sendmail.php file I suppose, that's how I get all POST values & validate them:
//grab the fields
$address = trim($_POST['address']);
$title = trim($_POST['title']);
$message = $_POST['message'];

//check if empty
if(empty($name) || empty($title) || empty($message)) {
   $wrong = true;
}

if($wrong) {
        http_response_code(400);
} else {
    // do stuff
    http_response_code(200);
}

Now, the issues I'm facing are:

*

*I can't send any other forms excepting the very first on the page, for the rest (even if they're properly filled) I'm getting this error:

Notice:  Undefined index: address in mysitesaddress on line 3

*

*after I send the first form - the other forms doesn't act like expected - they are getting through even if all fields are left empty (validator displays errors on front end but then fires "success" after a second because sendmail.php returns "200 OK".

Any ideas how to fix it / check every form instead of just the first one / clear POST data after sending? I'm sure there's an easy way to do that in PHP, I'm not that familiar with that language (mostly a front-end guy) so any help would be much appreciated.
Thank you!
(I've been Googling for an answer for a while now, but looks like "POST" is a tricky name and I'm getting Wordpress/blogs/forums related stuff mostly...)
[update]
Here's the HTML code of each form:

    <form class="contact-form" action="sendmail.php" method="post" novalidate="novalidate">
        <input name="title" type="text" required="required" />
        <input name="address" type="email" required="required" />
        <textarea name="message" required="required" ></textarea>
        <input type="Submit" value="Submit" />
    </form>

        Success message that replaces form ^.

A: The notice implies the 'address' key does not exist.
You should check if the indexes in the $_POST variables are set/exist, e.g. using the PHP isset() function.
This could be caused because you aren't sending the address in every form, just in the first or something like that.
Sample code on how you could use isset to check:
if ( isset($_POST['address']) ) {
   //only set $address to the $_POST value if it is set
   $address = trim($_POST['address']);
}

A: I can't see your HTML form code, but I'm guessing your form tag looks like this
<form action="sendmail.php" method="post">

This will take all the fields from the form that was submitted and send them via $_POST to your sendmail.php. After you process the data (edwardmp gave a great tip for making sure the data was there before trying to assign the variables), you would then redirect the page to some type of success landing or back to the original form page. The method I've been using to do this is:
if($wrong) {
    $error = "Please check your entry and try again.";
    header("Location: http://example.com/formpage.html?error=" . htmlencode($error),true,303);
    exit();
} else {
    // do stuff
    $msg = "Your form was successfully submitted.";
    header("Location: http://example.com/formpage.html?msg=" . htmlencode($msg),true,303);
    exit();
}

This design makes it so the $_POST data is cleared by reloading the page, and allows you to send messages back to the originating page which you would display through $_GET['msg'], or $_GET['error']. This should stop the forms from submitting erroneously.


text:
Q: Radio, Dropdown, Check on same line I am trying to get a radio button, dropdown, and checkbox on the same line for where the second radio button appears.  I am using Bootstrap 4, but I do not need this to look or conform to bootstrap ideals.  Plain looking html is fine.
I thought that display:inline, or display:inline-block using a div around the second radio group should have done it, but the stubborn checkbox remains in the line below, rather than inline.
What I want:
   Line 1:  Radio button (Popular)
   Line 2:  Radio button (Order), Dropdown, Checkbox

What I have:
   Line 1:  Radio button (Popular)
   Line 2:  Radio button (Order), Dropdown
   Line 3:  Checkbox

Code below:

      <input style="height:1em; width:1em;" type="radio" class="form-check-input" value="popular" name="abc" checked>Popular

            <input style="height:1em; width:1em;" type="radio" class="form-check-input" value="order" name="abc" checked>Order

        <select id="user_tag_dropdown">
            <option>One</option>
            <option>Two</option>
        </select>

              <input type="checkbox"> All

A: try using it like this..

      <input style="height:1em; width:1em;" type="radio" class="form-check-input" value="popular" name="abc" checked>Popular

            <input style="height:1em; width:1em;" type="radio" class="form-check-input" value="order" name="abc" checked>Order

        <select id="user_tag_dropdown">
            <option>One</option>
            <option>Two</option>
        </select>

              <input type="checkbox"> All


text:
Q: what are prepackaged character stream classes? While reading Java Tutorials, the topic Basic I/o says, use InputStreamReader and OutputStreamWriter when there are no prepackaged character stream classes.
1)What are Pepackaged character  stream classes?
Does it mean, a file already has some text!

A: The term is quite vague and doesn't really seem to be defined anywhere, so good question.
As best I understand it it means things like FileInputStream, FileOutputStream, ByteArrayOutputStream, etc. Classes that have wrapped up a particular kind of stream for you and provide the functionality required to work with it.
Note that most of these streams are working with characters not bytes, and that is generally what you want in Java for dealing with String data in files. On the other hand though if you are reading a pure binary source then the data will come in as bytes and you can then use InputStreamReader to convert those bytes to characters.
So a prepackaged stream reader is one that already provides you the data pre-packaged in the form that you want it.

A: I believe it to mean classes which inherit Reader or Writer. Such classes "wrap" byte streams so as to convert them automatically to character streams. Example: FileReader, FileWriter; they can read text from files directly.
If no such classes exist for your particular stream needs but you know what you get out of it/put into it is text, then you must use these two wrapper classes.
Classical example: HTML. It is text, but what you get from sockets is byte streams; if you want to read it as HTML, use a Reader (with the correct encoding!) over the socket stream (but of course, many APIs today don't require you to do that).


text:
Q: Check jdk availability How can I manually check if jdk is installed on my machine, and if yes, what version?
If I had jdk in Windows 7, and now I installed Windows 8 separately on the same machine, do I need to reinstall the jdk? Or can I reuse it?

A: When you install java on windows it can go by default in one of the following locations:
C:\Program Files (x86)\Java
C:\Program Files\Java

If you look in both of these locations, you will see exactly which JDKs and JREs are installed.
If you installed it somewhere else and don't remember, you can still search for java.exe
If by "Can i use it", you mean for use with an IDE like Eclipse or Netbeans, the answer is yes. They can use the JDK files no matter where they are, and whether it has been installed on the OS or not.
java -version will only tell you about a java version that would be on the path, which is not always the case.

A: If you have two Windows Version and the java installed in a place where both can share it, you can reuse it.

A: In cmd window type

java

If you see java usage information then you have java installed.

java -version

which display current version of your java.
You may reuse it windows 7 java in windows 8.


text:
Q: How to prevent bypassing win.resizable(False, False) while using the -zoomed attribute in tkinter? When I use win.resizable(False, False) on a window that has the zoomed attribute set to true, the window still can be resized by moving the title bar of the window, or by using the "Super + Down Arrow" shortcut. Is there any way to prevent this?
example code, that can reproduce this:
import tkinter as tk

master = tk.Tk()

master.wait_visibility()
master.attributes("-zoomed", True)

master.resizable(False, False)

master.title("This window should not be resizable")

tk.mainloop()

Ubuntu 22.04.1
Gnome 42.5
X11

A: I was able to create a maximized window that could not be resized by doing the following:
import tkinter as tk

master = tk.Tk()
master.resizable(0, 0)  # prevent resizing
master.wait_visibility()  # wait for the window
master.state('zoomed')  # maximize the window

# this guard clause isn't strictly necessary,
# but it's a 'best practice' kind of thing
if __name__ == '__main__':
    master.mainloop()  # run

That said, I'm on Windows 10 so YMMV. I hope this helps!
P.S.: I noticed you're calling tk.mainloop() instead of master.mainloop(), which may or may not be a problem (at the very least, it's unorthodox) - just a heads-up!


text: Q: Smallest set of Liner equations, which exactly fit a set of points I have a set of 2-d points,(it can be of any arbitrary dimension n). I want to find the minimum set of straight lines(linear equations) which exactly passes through the given 2-d points (unlike regression, I dont want any error here).


text:
Q: Displaying a large amount of data in paging table without heavily impacting DB The current implementation is a single complex query with multiple joins and temporary tables, but is putting too much stress on my MySQL and is taking upwards of 30+ seconds to load the table. The data is retrieved by PHP via a JavaScript Ajax call and displayed on a webpage. Here is the tables involved:
Table: table_companies
Columns: company_id, ...

Table: table_manufacture_line
Columns: line_id, line_name, ...

Table: table_product_stereo
Columns: product_id, line_id, company_id, assembly_datetime, serial_number, ...

Table: table_product_television
Columns: product_id, line_id, company_id, assembly_datetime, serial_number, warranty_expiry, ...

A single company can have 100k+ items split between the two product tables. The product tables are unioned and filtered by the line_name, then ordered by assembly_datetime and limited depending on the paging. The datetime value is also reliant on timezone and this is applied as part of the query (another JOIN + temp table). line_name is also one of the returned columns.
I was thinking of splitting the line_name filter out from the product union query. Essentially I'd determine the ids of the lines that correspond to the filter, then do a UNION query with a WHERE condition WHERE line_id IN (<results from previous query>). This would cut out the need for joins and temp tables, and I can apply the line_name to line_id and timezone modification in PHP, but I'm not sure this is the best way to go about things.
I have also looked at potentially using Redis, but the large number of individual products is leading to a similarly long wait time when pushing all of the data to Redis via PHP (20-30 seconds), even if it is just pulled in directly from the product tables.

*

*Is it possible to tweak the existing queries to increase the efficiency?

*Can I push some of the handling to PHP to decrease the load on the SQL server? What about Redis?

*Is there a way to architect the tables better?

*What other solution(s) would you suggest?

I appreciate any input you can provide.
Edit:
Existing query:
SELECT line_name,CONVERT_TZ(datetime,'UTC',timezone) datetime,... FROM (SELECT line_name,datetime,... FROM ((SELECT line_id,assembly_datetime datetime,... FROM table_product_stereos WHERE company_id=# ) UNION (SELECT line_id,assembly_datetime datetime,... FROM table_product_televisions WHERE company_id=# )) AS union_products INNER JOIN table_manufacture_line USING (line_id)) AS products INNER JOIN (SELECT timezone FROM table_companies WHERE company_id=# ) AS tz ORDER BY datetime DESC LIMIT 0,100

Here it is formatted for some readability.
SELECT line_name,CONVERT_TZ(datetime,'UTC',tz.timezone) datetime,...
  FROM (SELECT line_name,datetime,...
          FROM (SELECT line_id,assembly_datetime datetime,...
                    FROM table_product_stereos WHERE company_id=#

                 UNION
                SELECT line_id,assembly_datetime datetime,...
                  FROM table_product_televisions
                 WHERE company_id=#
               ) AS union_products
         INNER JOIN table_manufacture_line USING (line_id)
        ) AS products
INNER JOIN (SELECT timezone
            FROM table_companies
            WHERE company_id=#
            ) AS tz
ORDER BY datetime DESC LIMIT 0,100

IDs are indexed; Primary keys are the first key for each column.

A: Let's build this query up from its component parts to see what we can optimize.
Observation: you're fetching the 100 most recent rows from the union of two large product tables.
So, let's start by trying to optimize the subqueries fetching stuff from the product tables.  Here is one of them.
              SELECT line_id,assembly_datetime datetime,...
                FROM table_product_stereos
               WHERE company_id=#

But look, you only need the 100 newest entries here. So, let's add
               ORDER BY assembly_datetime DESC
               LIMIT 100

to this query.  Also, you should put a compound index on this table as follows. This will allow both the WHERE and ORDER BY lookups to be satisfied by the index.
 CREATE INDEX id_date ON table_product_stereos (company_id, assembly_datetime)

All the same considerations apply to the query from table_product_televisions.  Order it by the time, limit it to 100, and index it.
If you need to apply other selection criteria, you can put them in these inner queries.  For example, in a comment you mentioned a selection based on a substring search.  You could do this as follows
              SELECT t.line_id,t.assembly_datetime datetime,...
                FROM table_product_stereos AS t
                JOIN table_manufacture_line AS m   ON m.line_id = t.line_id
                                                  AND m.line_name LIKE '%test'
               WHERE company_id=#
               ORDER BY assembly_datetime DESC
               LIMIT 100

Next, you are using UNION to combine those two query result sets into one.  UNION has the function of eliminating duplicates, which is time-consuming. (You know you don't have duplicates, but MySQL doesn't.) Use UNION ALL instead.
Putting this all together, the innermost sub query becomes this. We have to wrap up the subqueries because SQL is confused by UNION and ORDER BY clauses at the same query level.
           SELECT * FROM (
              SELECT line_id,assembly_datetime datetime,...
                FROM table_product_stereos
               WHERE company_id=#
               ORDER BY assembly_datetime DESC
               LIMIT 100
                         ) AS st
           UNION ALL
           SELECT * FROM (
             SELECT line_id,assembly_datetime datetime,...
               FROM table_product_televisions
              WHERE company_id=#
              ORDER BY assembly_datetime DESC
              LIMIT 100
                         ) AS tv

That gets you 200 rows. It should get those rows fairly quickly.
200 rows are guaranteed to be enough to give you the 100 most recent items later on after you do your outer ORDER BY ... LIMIT operation.  But that operation only has to crunch 200 rows, not 100K+, so it will be far faster.
Finally wrap up this query in your outer query material.  Join the table_manufacture_line information, and fix up the timezone.
If you do the indexing and the ORDER BY ... LIMIT operation earlier, this query should become very fast.
The comment dialog in your question indicates to me that you may have multiple product types, not just two, and that you have complex selection criteria for your paged display.  Using UNION ALL on large numbers of rows slams performance: it converts multiple indexed tables into an internal list of rows that simply can't be searched efficiently.
You really should consider putting your two kinds of product data in a single table instead of having to UNION ALL multiple product tables. The setup you have now is inflexible and won't scale up easily. If you structure your schema with a master product table and perhaps some attribute tables for product-specific information, you will find yourself much happier two years from now. Seriously. Please consider making the change.

A: Remember: Index fast, data slow. Use joins over nested queries. Nested queries return all of the data fields whereas joins just consider the filters (which should all be indexed - make sure there's a unique index on table_product_*.line_id). It's been a while but I'm pretty sure you can join "ON company_id=#" which should cut down the results early on.
In this case, all of the results refer to the same company (or a much smaller subset) so it makes sense to run that query separately (and it makes the query more maintainable).
So your data source would be:
(table_product_stereos as prod
INNER JOIN table_manufacture_line AS ml ON prod.line_id = ml.line_id and prod.company_id=#
UNION
table_product_televisions as prod
INNER JOIN table_manufacture_line as ml on prod.line_id = ml.line_id and prod.company_id=#)

From which you can select prod. or ml. fields as required.

A: PHP is not a solution at all...
Redis can be a solution.
But the main thing I would change is the index creation for the tables (add missing indexe)...If you're running into temp tables you didn't create indexes well for the tables. And 100k rows in not much at all.
But I cant help you without any table creation statements as well as queries you run.
Make sure your "where part" is part of youf btree index from left to right.


text:
Q: Python OS module, deleting folders hey guys why this line of code doesn't return anything. It's like it keeps running.... It deletes the file I want it to delete but the program does not exit.
os.system('cmd /k rmdir /s /q {}'.format(path))

A: > cmd /?

/C      Carries out the command specified by string and then terminates
/K      Carries out the command specified by string but remains

Try /c or just os.system('<your code without cmd /c >').
This is because parameter /k(keep) let cmd remains while /c(close) not.

A: A call to os.system will return only an exit value. If it's stuck - it may be waiting for a file lock, like a cmd shell in that subdirectory or an open file.
I would suggest using subprocess.call (or check call) with shell=True, which would eliminate the wrapping cmd call.
However, I would take this one step further and suggest using the shutil.rmtree function to recursively delete a directory.


text:
Q: Is there a relatively straightforward way to finalize a CD or DVD in C# or PowerShell? First, some clarification of terms.  By finalize, I don't mean closing a session; I mean writing a lead-out to a CD or DVD in such a way that information can no longer be added to it via the usual means (Roxio, Nero, Windows Explorer, etc.)
I've done a fair amount of research on this.  There are some open-source programs like InfraRecorder from which we could draw some inspiration, but they all seem to involve rather elaborate reams of C++ code using IMAPI, which seems like a very low-level way to do things.  None of the developers on our team have the C++ or IMAPI expertise to support such a code base.
The most promising resource on the internet appears to be this one, but it doesn't seem to include a finalize function.  Here is the code that "writes an image":
public void WriteImage(BurnVerificationLevel verification, bool finalize, bool eject)
{
    if (!_recorderLoaded)
        throw new InvalidOperationException("LoadMedia must be called first.");

    MsftDiscRecorder2 recorder = null;
    MsftDiscFormat2Data discFormatData = null;

    try
    {
        recorder = new MsftDiscRecorder2();
        recorder.InitializeDiscRecorder(_recorders.SelectedItem.InternalUniqueId);

        discFormatData = new MsftDiscFormat2Data
        {
            Recorder = recorder,
            ClientName = ClientName,
            ForceMediaToBeClosed = finalize
        };

        //
        // Set the verification level
        //
        var burnVerification = (IBurnVerification)discFormatData;
        burnVerification.BurnVerificationLevel = IMAPI_BURN_VERIFICATION_LEVEL.IMAPI_BURN_VERIFICATION_NONE;

        //
        // Check if media is blank, (for RW media)
        //
        object[] multisessionInterfaces = null;
        if (!discFormatData.MediaHeuristicallyBlank)
            multisessionInterfaces = discFormatData.MultisessionInterfaces;

        //
        // Create the file system
        //
        IStream fileSystem;
        _CreateImage(recorder, multisessionInterfaces, out fileSystem);

        discFormatData.Update += _discFormatWrite_Update;

        //
        // Write the data
        //
        try
        {
            discFormatData.Write(fileSystem);
        }
        finally
        {
            if (fileSystem != null) Marshal.FinalReleaseComObject(fileSystem);
        }

        discFormatData.Update -= _discFormatWrite_Update;

        if (eject) recorder.EjectMedia();
    }
    finally
    {
        _isWriting = false;
        if (discFormatData != null) Marshal.ReleaseComObject(discFormatData);
        if (recorder != null) Marshal.ReleaseComObject(recorder);
    }
}

The critical section of code seems to be this one:
discFormatData = new MsftDiscFormat2Data
{
    Recorder = recorder,
    ClientName = ClientName,
    ForceMediaToBeClosed = finalize // <-- Here
};

But this isn't a finalize function; it's a function that burns actual data onto a disk.  Do you have to actually create a new session to perform a finalization on an existing disk?

A: Set the ForceMediaToBeClosed flag on the IMAPI2.MsftDiscFormat2Data object and write out the disc with the close flag enabled.

*

*If you already know its your last session, set the flag, add your data to write and then write it out and it will close.

*If you have already written your last session, import the last session, set the flag and write to close.

Approach is described here: https://social.msdn.microsoft.com/Forums/en-US/ce1ff136-39a1-4442-bc5c-61c119b6f4f2/finalize-question?forum=windowsopticalplatform#2e968a94-7347-4d94-9332-00fe7cd0ba89
Below is a link to a nice Powershell burning script, all you'd have to do is update Out-CD with a new param to set $DiscFormatData.ForceMediaToBeClosed = true when you are ready for your closing write.
Link: https://www.adamtheautomator.com/use-powershell-to-automate-burning-cds/
FYI:
# this fetches all the properties (as you probably already know)
$DiscFormatData  = New-Object -com IMAPI2.MsftDiscFormat2Data ;
$DiscFormatData | Get-Member ;

A: The ForceMediaToBeClosed property of IDiscFormat2Data controls whether the IMAPI finalizes the disc after the next write:

Set to VARIANT_TRUE to mark the disc as closed to prohibit additional writes when the next write session ends.

The Image Mastering API does not provide an abstraction used specifically to finalize the disc, so we need to perform a write operation. The API will finalize a blank disc during the initial burn if we switch on ForceMediaToBeClosed with the main image writer. For an existing multi-session disc, we need to append another session.
Here's a simple PowerShell example that we can try so we don't need to build the project. The concepts are similar in C#:
$drives = New-Object -ComObject 'IMAPI2.MsftDiscMaster2'
$recorder = New-Object -ComObject 'IMAPI2.MsftDiscRecorder2'
$recorder.InitializeDiscRecorder($drives[0])  # Choose a drive here

$disc = New-Object -ComObject 'IMAPI2.MsftDiscFormat2Data'
$disc.ClientName = 'PowerShell Recorder'
$disc.Recorder = $recorder
$disc.ForceMediaToBeClosed = $true  # Finalize the next session

$image = New-Object -ComObject 'IMAPI2FS.MsftFileSystemImage'

if (!$disc.IsCurrentMediaSupported($recorder)) {
    throw 'Disc is not writeable.'
} elseif ($disc.MediaHeuristicallyBlank) {
    $image.ChooseImageDefaults($recorder)
} else {
    $image.MultisessionInterfaces = $disc.MultisessionInterfaces
    $image.ImportFileSystem() > $null
}

This sets up some boilerplate that we'll use below to burn a disc. We'll need to add error handling and capability detection for practical use, but it works fine as a demonstration. If we paste or dot-source this code into a PowerShell session, we can play with the COM objects interactively.
At this point, if we check the status of a blank or open disc, we should see a value of 2, 4, or 6 which correspond to the "blank" or "appendable" bitmasks (6 for both) enumerated on IMAPI_FORMAT2_DATA_MEDIA_STATE.
PS> $disc.CurrentMediaStatus  # 4 for an open, multi-session disc

Then, we can add some files. If we just want to close-off a multi-session disc, we don't need to add anything to the image. The API records the session's lead-in and lead-out with an empty data track.
PS> $image.Root.AddTree('path\to\root\folder', $false)

Finally, we'll burn our changes to the disc. Because we set $disc.ForceMediaToBeClosed to $true, this operation finalizes the disc, and no further write operations are allowed:
PS> $disc.Write($image.CreateResultImage().ImageStream)

If we inspect the disc status now, it should indicate that the disc is not writable:
PS> $disc.CurrentMediaStatus  # 16384 or 40960

For a single-session disc, we should see 16384 (0x4000, "finalized"). My system reports 40960 for closed, multi-session discs which contains the bits 0x2000 ("write-protected") and 0x8000 ("unsupported media"). We may need to eject or power-cycle some hardware to see accurate values after burning.
Remarks:

*

*In general, each session on a multi-session disc starts with a lead-in and ends with a lead-out. The lead-in of the last session permanently closes the media to further writes when we finalize a disc. This is why we need to append an additional session to an unclosed disc even if we have no more data to add.

*IMAPI will automatically finalize a disc if the free space drops below 2%.

*InfraRecorder—the tool mentioned in the question—does not use the IMAPI. This application provides a frontend to cdrtools which controls the device IO directly. If we just need to finalize unclosed discs, we may want to use the cdrecord CLI program included with this package to avoid maintaining an extra codebase:
PS> cdrecord -scanbus          # Show <drive> IDs to choose from
PS> cdrecord -fix dev=<drive>  # Close an open session

As a brief starting point, here's how we can finalize a multi-session disc:
PS> $session = cdrecord -msinfo dev=<drive>
PS> mkisofs -rJ -C $session -M <drive> 'path\to\root' | cdrecord dev=<drive> -

This achieves the same result as our PowerShell script that uses the IMAPI: we import the last session, create the image, and then burn a new session which finalizes the disc. By omitting the -multi argument to cdrecord, the command won't write the lead-in in a way that allows for continuation of a multi-session disc.
While we typically see this toolset on Unix-like systems, builds are available for Windows.

*For more advanced applications, we can use an implementation of the lower-level IDiscRecorderEx to query and send commands to the recording device.


text:
Q: Javascript Inheritance - this.element is undefined in subclass I'm trying to set up a parent class that extends a subclass, but whenever I attempt to reference this.element in the subclass when called from the superclass, it's undefined.  What am I doing wrong here?
$.widget("ui.testSuper", $.extend({}, $.ui.testSub.prototype,
{
    _init: function ()
    {
        $.ui.testSub.prototype._init();
    },
...
}));

$.widget("ui.testSub", $.ui.mouse,
{
    _init: function ()
    {
        this.element.addClass("some-class");
    },
...
});

$('#some-element').testSub({ }); // this works fine

$('#some-element').testSuper({ }); // this.element is undefined

A: When you extend $.ui.testSub it doesn't exists at those point. All you need to do is to swap those two blocks of code:
//Should be first
$.widget("ui.testSub", $.ui.mouse,
{
    _init: function ()
    {
        this.element.addClass("some-class");
    },
...
});

$.widget("ui.testSuper", $.extend({}, $.ui.testSub.prototype,
{
    _init: function ()
    {
        $.ui.testSub.prototype._init();
    },
...
}));

$('#some-element').testSub({ }); // this works fine

$('#some-element').testSuper({ }); // then it will work fine as well

See live example here
UPDATE
I got what you're saying. You need to call base method like this
$.ui.testSub.prototype._init.call(this);

So you will not loose the context of your element. Example is here

A: I'm not sure if using $.extend is the way to go here.
Here's how I typically extend jQuery UI widgets:
$.widget('ui.testSuper', $.ui.testSub {
    _create: function() {
        $.ui.testSub.prototype._create.call(this);
    }
});

I see you are using _init, so must be using an older version of jQuery UI.


text:
Q: Python executable script ModuleNotFound I am trying to better understand importing modules. I read about how to do this from here https://stackoverflow.com/a/14132912/14179793 and I can get it to work using solution 1. There is an additional variable that I need to figure out though.
This is a dummy project I am testing with:
.
├── a_package
│   ├── __init__.py
│   └── lib_a.py
├── b_package
│   ├── __init__.py
│   └── test_script.py
├── main.py
└── src
    └── src_lib
        └── src_lib.py

With this setup I can do:
python -m b_package.test_script
this is lib a function
This is src_lib_function.

test_script.py:
from a_package.lib_a import lib_a_function
from src.src_lib.src_lib import src_lib_function

if __name__ == '__main__':
    lib_a_function()
    src_lib_function()
    pass

The goal is to make b_package/test_script.py executable without using python test_script ie ./test_script
However, adding the shebang at the top #!/usr/bin/env python causes an import error:
$ ./b_package/test_script.py
Traceback (most recent call last):
  File "./b_package/test_script.py", line 2, in <module>
    from a_package.lib_a import lib_a_function
ModuleNotFoundError: No module named 'a_package'

I assume it is because python is not loading it as a module based off the above mentioned question but I am not sure how to resolve this.

A: I ended up using setuptools as suggested by kosciej16 to achieve the desired results.
New project structure:
.
├── a_package
│   ├── __init__.py
│   └── lib_a.py
├── b_package
│   ├── __init__.py
│   └── test_script.py
├── main.py
├── pyproject.toml
├── setup.cfg
└── src
    ├── __init__.py
    └── src_lib
        ├── __init__.py
        └── src_lib.py

setup.cfg:
[metadata]
name = cli_test
version = 0.0.1

[options]
packages = find:

[options.entry_points]
console_scripts =
    test_script = b_package.test_script:main

This allows the user to clone the repo and run pip install . from the top level then they can execute the script by just typing test_script


text:
Q: What is wrong with this POST request with json on android? I'm trying to perform a POST request to a server that wants the Content-Type set to application/json with name and email as some keys.  Currently, I'm getting a 406 error, which I'm assuming is working on the server side, but android can't handle the response.  How can I tweak the code to get a 200 response?
HttpClient client = new DefaultHttpClient();
HttpEntity entity;

try{
    JSONObject j = new JSONObject();
    j.put("name" , myName);
    j.put("email", myEmail);

    HttpPost post = new HttpPost(targetURL);
    post.setHeader("Content-Type", "application/json");

    StringEntity se = new StringEntity(j.toString(), HTTP.UTF_8);
    se.setContentType("application/json");
    post.setEntity(se);

    HttpResponse response = client.execute(post);
    entity = response.getEntity();

    Log.d("response", response.getStatusLine().toString());
} catch(Exception e){Log.e("exception", e.toString());}

Does that look about right?  Do I need one of those response handlers when creating the HttpClient?

A: This works for me with json-2.0.jar
        HttpClient client = new DefaultHttpClient();
        HttpConnectionParams.setConnectionTimeout(client.getParams(), MyApplication.HTTP_TIMEOUT); //Timeout Limit
        HttpResponse response;
        ArrayList<appResults> arrayList = new ArrayList<appResults>();
        String resul;
        try{

            HttpGet get = new HttpGet(urls[0]);

            response = client.execute(get);
            /*Checking response */
            if(response!=null){
                InputStream in = response.getEntity().getContent(); //Get the data in the entity
                resul = convertStreamToString(in);
                Gson gson = new Gson();
                Type listType = new TypeToken<ArrayList<appResults>>() {}.getType();
                arrayList = gson.fromJson(resul, listType);
                in.close();

of course in asynctask or thread.
But 406... it seems that your format on your webserver and your app are not consistent...


text:
Q: How can i make invisible the clusters without cluster centroid in python? I have a kmeans clustered object with 15 clusters. I rearranged the cluster_centers of the object and removed 5 specific cluster centers form that list. Now i want to visiulize my object and cluster centers. But i couldn't find a way to make some clusters invisible.
My originally clustered data is :

When i try to visualize my kmeans data object with its new cluster centroids i get this output:

I want to make invisible the clusters without "X" markers on it. How can i do that?
I used this code to plot the above:
plt.scatter(X_train[:,0], X_train[:,1],c=TrainData[1],cmap='gist_rainbow')
plt.scatter(new_centroids[:,0], new_centroids[:, 1],s = 150, c = 'black', label = 'Centroid', marker="x")
plt.show()

A: You can build a filter to exclude the undesired values.
You need to convert your TrainData[1] to a numpy array (if it isn't already), using np.array(TrainData[1]).
Here is an example using sklearns KMeans:

import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
import numpy as np

X_train = np.random.normal(size=(5000, 2))
kmeans_result = KMeans(n_clusters=15).fit(X_train)
new_centroids = kmeans_result.cluster_centers_
cluster_ids = kmeans_result.labels_
# cluster_ids = np.array(TrainData[1])

undesired1 = 3
undesired2 = 5
undesired3 = 7
filter = (cluster_ids != undesired1) & (cluster_ids != undesired2) & (cluster_ids != undesired3)
plt.scatter(X_train[filter, 0], X_train[filter, 1], c=cluster_ids[filter], cmap='gist_rainbow', alpha=0.4)
desired_centroid_ids = np.array([i for i in range(len(new_centroids)) if i not in [undesired1, undesired2, undesired3]])
plt.scatter(new_centroids[desired_centroid_ids, 0], new_centroids[desired_centroid_ids, 1], s=150, c='black',
            label='Centroid', marker="x")
plt.show()


text:
Q: Threshold image data using VTK (vtkImageThreshold) I have a 3D vector field that I am storing in a vtkImageData object. The vtkImageData object contains two arrays:

*

*a 3 component vtkDoubleArray (the vector x, y and z components)

*a 1 component vtkDoubleArray containing a separate quantity

I would like to extract the corresponding elements of the two arrays, for which the values of the 1 component array lie within a certain range. Here's what I've tried:
vtkSmartPointer<vtkImageThreshold> threshold =
        vtkSmartPointer<vtkImageThreshold>::New();
threshold->SetInputData(image);
threshold->SetInputArrayToProcess(1, image->GetInformation()); // 1 is the Energy array index
threshold->ThresholdBetween(1e-22, 2e-22);
threshold->Update();

vtkSmartPointer<vtkImageData> thresholdedImage = threshold->GetOutput();

I've also tried using vtkThresholdPoints but to no avail. Any suggestions would be much appreciated.

A: Looks like I can use this example:
vtkSmartPointer<vtkThresholdPoints> threshold =
        vtkSmartPointer<vtkThresholdPoints>::New();
threshold->SetInputData(image);
threshold->ThresholdBetween(1e-21, 2e-21);
threshold->SetInputArrayToProcess(0, 0, 0,
        vtkDataObject::FIELD_ASSOCIATION_POINTS, "Energy");
threshold->Update();

vtkSmartPointer<vtkPolyData> thresholded = threshold->GetOutput();

I didn't realise that this approach was applicable but it would seem so. This does change the type of my data from vtkImageData to vtkPolyData and I have very little idea what the arguments to vtkThresholdPoints::SetInputArrayToProcess() mean. However, it seems to do the job. I'd be happy to hear any alternative suggestions!


text:
Q: Display reesults from another html on same page using jquery web Below is my code of html and jquery, i want to dsiplay results on submit button on the same page rather than its goes on next page. But it is not returning me any results and go to next page.
HTML code
<form id="create" action="/engine_search/search/" method="get">
                            <input style="height:40px;" type="text" class="form-control" placeholder="Search" name="q">
                            <center>
                            <input style="float:left; margin-left:150px;" type="submit" class="btn btn-default" value="Search">
                                </center>
                         </form>

jquery code:
<script>
$(document).ready(function() {
$('#create').submit(function() { // catch the form's submit event
    $.ajax({ // create an AJAX call...
        data: $(this).serialize(), // get the form data
        type: $(this).attr('method'), // GET or POST
        url: $(this).attr('action'), // the file to call
        success: function(response) { // on success..
            $('#created').html(response); // update the DIV
        }
    });
    return false; // cancel original event to prevent form submitting
});
});
</script>

A: You should use event.preventDefault();
<script>
$(document).ready(function() {
$('#create').submit(function(event) { // catch the form's submit event
    event.preventDefault();
    $.ajax({ // create an AJAX call...
        data: $(this).serialize(), // get the form data
        type: $(this).attr('method'), // GET or POST
        url: $(this).attr('action'), // the file to call
        success: function(response) { // on success..
            $('#created').html(response); // update the DIV
        }
    });
    return false; // cancel original event to prevent form submitting
});
});
</script>

Look for console for any errors. It might be helpful.

A: <input style="float:left; margin-left:150px;" type="submit" class="btn btn-default" value="Search" onclick="return SubmitFunction(this);">

Javascript :
function SubmitFunction(thisId){
 $.ajax({ // create an AJAX call...
    data: $(thisId).serialize(), // get the form data
    type: $(thisId).attr('method'), // GET or POST
    url: $(thisId).attr('action'), // the file to call
    success: function(response) { // on success..
        $('#created').html(response); // update the DIV
    }
});

 return false; // cancel original event to prevent form submitting

}


text:
Q: Limit of startupeventargs.args array? I have 14 arguments being passed into through command line. However first one seems to be cut off for some reason and isn't reaching into startupeventargs.args.
What is the size of StartupEventArgs e  string array?
protected override void OnStartup(StartupEventArgs e)
{
    ParseArguments(e.Args);
}

private static void ParseArguments(string[] args)
{
    //args[args.Length + 1] = "-sn";

    Log.Write("Parsing {0} arguments...", args.Length);

    // Parse the command line arguments
    for (int i = 1; i < args.Length; i++)
    {
        //test Log.Write(args[i]);
        switch (args[i - 1])
        {
            case "-sn":
                // Parse the show name
                ShowName = args[i];
                break;

//...

EDIT:
it is called from another app written in c++:
sprintf(szCommandLine, "-sn %n -sd %s -w %d -h %d -t %d -l %d -th %d",
    szWebShow, szBaseDir, iWidth, iHeight, iTop, iLeft, threadID);

if(CreateProcess(PLAYWEB_EXE,szCommandLine, NULL, NULL, FALSE,
                 DETACHED_PROCESS, NULL, NULL, &startInfo, &procInfo)) {
    Log(LOGSTR("Web Show Started: %s ", szCommandLine));

command line:
(path to .exe) -sn "M000018\33.9999-2815-8-WS001" -sd c:\Player\Shows2 -w 1280 -h 720 -t 0 -l 0 th 1

A: Arrays in C# are zero based, from the docs:

C# arrays are zero indexed; that is, the array indexes start at zero

The array index needs to start at 0:
for (int i = 0; i < args.Length; i++)
{
    //.....

EDIT
Now you have added the explanation of how you are calling the process, I can see you have an issue with it. From the docs on the CreateProcess function, the second parameter is the command line and:

If both lpApplicationName and lpCommandLine are non-NULL, the null-terminated string pointed to by lpApplicationName specifies the module to execute, and the null-terminated string pointed to by lpCommandLine specifies the command line.

What you should be doing is something like this:
CreateProcess(NULL, szCommandLine....)

Where szCommandLine has the executable prefix, for example PLAYWEB_EXE -sn blah... etc


text:
Q: Numpy Indexing and creation of new array I am trying to understand what is going on inside the print statement.
I know indexing is taking place to create a 2D array however, I don't understand the order
x = np.arange(0,2*np.pi,0.001)
X = np.concatenate(([x], [np.ones(y.shape[0])]), axis=0)

print(X[[[0,1],[0,1]],[[0,0],[-1,-1]]])

Produces:
array([[0.   , 1.   ],
       [6.283, 1.   ]])

A: I looked into documentation and I think following example from there should explain that indexing:
From a 4x3 array the corner elements should be selected using advanced indexing. Thus all elements for which the column is one of [0, 2] and the row is one of [0, 3] need to be selected. To use advanced indexing one needs to select all elements explicitly. Using the method explained previously one could write:
x = array([[0, 1, 2],
           [3, 4, 5],
           [6, 7, 8],
           [9, 10, 11]])
rows = np.array([[0, 0],
                 [3, 3]], dtype=np.intp)
columns = np.array([[0, 2],
                    [0, 2]], dtype=np.intp)
x[rows, columns]

last line give
array([[0, 2],
       [9, 11]])

code in your question seems to do same operation (but with other values) as that example, but with slamming indices directly rather than creating rows and columns.
X[[[0, 1], [0, 1]], [[0, 0], [-1, -1]]] might be readed as get elements which are, counting from 0: (in 0th or 1st row) and (in 0th or last column)


text:
Q: How to overlay Segoe MDL2 Assets glyphs for use in WPF TreeViewItem.Header? I just read about overlaying glyphs. I am trying it out.
This is the simplified xaml portion to compose the TreeViewItem.Header
<TreeViewItem.Header>
  <StackPanel Orientation="Horizontal">
    <TextBlock Name="icon" FontFamily="Segoe MDL2 Assets"
       Text="" Foreground="Blue" Background="cyan" />
    <TextBlock Name="title"/>
  </StackPanel>
</TreeViewItem.Header>

It produces a header containing glyph ED0D like this:

However, I would like to overlay ED0C

onto glyph ED0D.
What avenues are available to me to perform such overlay to be used in the TreeViewItem.Header?

A: Put two TextBlocks on top of each other:
<StackPanel Orientation="Horizontal">
    <Grid TextElement.FontFamily="Segoe MDL2 Assets">
        <TextBlock Text="" Foreground="Cyan"/>
        <TextBlock Text="" Foreground="Blue"/>
    </Grid>

   <TextBlock x:Name="title"/>
</StackPanel>

Result:


text:
Q: A code from a TikZ-CD manual is not compiling Here is the code from page 2 in a TikZ-CD manual found here. I loaded \usetikzlibrary{cd}, and I loaded quotes.  (Immediately preceding this example, it says "labels can be placed on an arrow by means of the quotes syntax.")  Why is the following code not compiling?  How do I add \psi to the other arrow?
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,shapes,positioning,intersections,quotes,decorations.markings}
\usetikzlibrary{cd}

\begin{document}

\begin{tikzcd}

A \arrow[rd] \arrow[r, "\phi"] &B \\
&C

\end{tikzcd}

\end{document}


text:
Q: SVG text animated landing page not working in vscode I'm new to coding and I'm trying to do this to do line text svg animation. I followed the steps and tried to creat the file in figma and then create it in vscode. The word pops up but it doesn't animate and I've been searching to no avail on the why?
Can someone help me figure this out? I just want it to go from one end to the other.
<!doctype html>

  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="css/normalize.css" />

  <title>Document</title>

  <meta name="theme-color" content="#fafafa">

  <svg
    width="843"
    height="118"
    viewBox="0 0 843 118"
    fill="forward"
    xmlns="http://www.w3.org/2000/svg">
    id="Kink In Kolor"

    <mask id="Kink In Kolor path-1-outside-1"
    maskUnits="userSpaceOnUse"
    x="0.0880127"
    y="0.415993"
    width="843"
    height="117"
    fill="black">
      <rect fill="white" x="0.0880127" y="0.415993" width="843" height="117" />
      <path
        d="M57.52 113L16.192 67.208V113H3.08801V12.632H16.192V59.144L57.664 12.632H74.224L28.72 62.888L74.656 113H57.52Z" />
      <path
        d="M96.0591 21.272C93.5631 21.272 91.4511 20.408 89.7231 18.68C87.9951 16.952 87.1311 14.84 87.1311 12.344C87.1311 9.84799 87.9951 7.736 89.7231 6.008C91.4511 4.27999 93.5631 3.41599 96.0591 3.41599C98.4591 3.41599 100.475 4.27999 102.107 6.008C103.835 7.736 104.699 9.84799 104.699 12.344C104.699 14.84 103.835 16.952 102.107 18.68C100.475 20.408 98.4591 21.272 96.0591 21.272ZM102.395 34.088V113H89.2911V34.088H102.395Z" />
      <path
        d="M163.177 32.648C172.777 32.648 180.553 35.576 186.505 41.432C192.457 47.192 195.433 55.544 195.433 66.488V113H182.473V68.36C182.473 60.488 180.505 54.488 176.569 50.36C172.633 46.136 167.257 44.024 160.441 44.024C153.529 44.024 148.009 46.184 143.881 50.504C139.849 54.824 137.833 61.112 137.833 69.368V113H124.729V34.088H137.833V45.32C140.425 41.288 143.929 38.168 148.345 35.96C152.857 33.752 157.801 32.648 163.177 32.648Z" />
      <path
        d="M260.902 113L229.942 78.152V113H216.838V6.44H229.942V69.08L260.326 34.088H278.614L241.462 73.4L278.758 113H260.902Z" />
      <path d="M342.442 12.632V113H329.338V12.632H342.442Z" />
      <path
        d="M403.224 32.648C412.824 32.648 420.6 35.576 426.552 41.432C432.504 47.192 435.479 55.544 435.479 66.488V113H422.52V68.36C422.52 60.488 420.552 54.488 416.616 50.36C412.68 46.136 407.303 44.024 400.487 44.024C393.575 44.024 388.055 46.184 383.927 50.504C379.895 54.824 377.88 61.112 377.88 69.368V113H364.776V34.088H377.88V45.32C380.472 41.288 383.976 38.168 388.392 35.96C392.904 33.752 397.848 32.648 403.224 32.648Z" />
      <path
        d="M549.708 113L508.38 67.208V113H495.276V12.632H508.38V59.144L549.852 12.632H566.411L520.908 62.888L566.844 113H549.708Z" />
      <path
        d="M615.895 114.296C608.503 114.296 601.783 112.616 595.735 109.256C589.783 105.896 585.079 101.144 581.623 95C578.263 88.76 576.583 81.56 576.583 73.4C576.583 65.336 578.311 58.232 581.767 52.088C585.319 45.848 590.119 41.096 596.167 37.832C602.215 34.472 608.983 32.792 616.471 32.792C623.959 32.792 630.727 34.472 636.775 37.832C642.823 41.096 647.575 45.8 651.031 51.944C654.583 58.088 656.359 65.24 656.359 73.4C656.359 81.56 654.535 88.76 650.887 95C647.335 101.144 642.487 105.896 636.343 109.256C630.199 112.616 623.383 114.296 615.895 114.296ZM615.895 102.776C620.599 102.776 625.015 101.672 629.143 99.464C633.271 97.256 636.583 93.944 639.079 89.528C641.671 85.112 642.967 79.736 642.967 73.4C642.967 67.064 641.719 61.688 639.223 57.272C636.727 52.856 633.463 49.592 629.431 47.48C625.399 45.272 621.031 44.168 616.327 44.168C611.527 44.168 607.111 45.272 603.079 47.48C599.143 49.592 595.975 52.856 593.575 57.272C591.175 61.688 589.975 67.064 589.975 73.4C589.975 79.832 591.127 85.256 593.431 89.672C595.831 94.088 598.999 97.4 602.935 99.608C606.871 101.72 611.191 102.776 615.895 102.776Z" />
      <path d="M686.692 6.44V113H673.588V6.44H686.692Z" />
      <path
        d="M743.442 114.296C736.05 114.296 729.329 112.616 723.281 109.256C717.329 105.896 712.625 101.144 709.169 95C705.809 88.76 704.13 81.56 704.13 73.4C704.13 65.336 705.857 58.232 709.313 52.088C712.865 45.848 717.666 41.096 723.714 37.832C729.762 34.472 736.53 32.792 744.018 32.792C751.506 32.792 758.274 34.472 764.322 37.832C770.37 41.096 775.122 45.8 778.578 51.944C782.13 58.088 783.906 65.24 783.906 73.4C783.906 81.56 782.081 88.76 778.433 95C774.881 101.144 770.034 105.896 763.89 109.256C757.746 112.616 750.93 114.296 743.442 114.296ZM743.442 102.776C748.146 102.776 752.562 101.672 756.69 99.464C760.818 97.256 764.129 93.944 766.625 89.528C769.217 85.112 770.513 79.736 770.513 73.4C770.513 67.064 769.266 61.688 766.77 57.272C764.274 52.856 761.009 49.592 756.977 47.48C752.945 45.272 748.577 44.168 743.873 44.168C739.073 44.168 734.657 45.272 730.625 47.48C726.689 49.592 723.522 52.856 721.122 57.272C718.722 61.688 717.521 67.064 717.521 73.4C717.521 79.832 718.673 85.256 720.977 89.672C723.377 94.088 726.546 97.4 730.482 99.608C734.418 101.72 738.738 102.776 743.442 102.776Z" />
      <path
        d="M814.239 46.904C816.543 42.392 819.807 38.888 824.031 36.392C828.351 33.896 833.583 32.648 839.727 32.648V46.184H836.271C821.583 46.184 814.239 54.152 814.239 70.088V113H801.135V34.088H814.239V46.904Z" />
    </mask>
    <path
      d="M57.52 113L16.192 67.208V113H3.08801V12.632H16.192V59.144L57.664 12.632H74.224L28.72 62.888L74.656 113H57.52Z"
      stroke="#A12DCA" stroke-width="6" mask="url(#path-1-outside-1)" />
    <path
      d="M96.0591 21.272C93.5631 21.272 91.4511 20.408 89.7231 18.68C87.9951 16.952 87.1311 14.84 87.1311 12.344C87.1311 9.84799 87.9951 7.736 89.7231 6.008C91.4511 4.27999 93.5631 3.41599 96.0591 3.41599C98.4591 3.41599 100.475 4.27999 102.107 6.008C103.835 7.736 104.699 9.84799 104.699 12.344C104.699 14.84 103.835 16.952 102.107 18.68C100.475 20.408 98.4591 21.272 96.0591 21.272ZM102.395 34.088V113H89.2911V34.088H102.395Z"
      stroke="#A12DCA" stroke-width="6" mask="url(#path-1-outside-1)" />
    <path
      d="M163.177 32.648C172.777 32.648 180.553 35.576 186.505 41.432C192.457 47.192 195.433 55.544 195.433 66.488V113H182.473V68.36C182.473 60.488 180.505 54.488 176.569 50.36C172.633 46.136 167.257 44.024 160.441 44.024C153.529 44.024 148.009 46.184 143.881 50.504C139.849 54.824 137.833 61.112 137.833 69.368V113H124.729V34.088H137.833V45.32C140.425 41.288 143.929 38.168 148.345 35.96C152.857 33.752 157.801 32.648 163.177 32.648Z"
      stroke="#A12DCA" stroke-width="6" mask="url(#path-1-outside-1)" />
    <path
      d="M260.902 113L229.942 78.152V113H216.838V6.44H229.942V69.08L260.326 34.088H278.614L241.462 73.4L278.758 113H260.902Z"
      stroke="#A12DCA" stroke-width="6" mask="url(#path-1-outside-1)" />
    <path d="M342.442 12.632V113H329.338V12.632H342.442Z" stroke="#A12DCA" stroke-width="6"
      mask="url(#path-1-outside-1)" />
    <path
      d="M403.224 32.648C412.824 32.648 420.6 35.576 426.552 41.432C432.504 47.192 435.479 55.544 435.479 66.488V113H422.52V68.36C422.52 60.488 420.552 54.488 416.616 50.36C412.68 46.136 407.303 44.024 400.487 44.024C393.575 44.024 388.055 46.184 383.927 50.504C379.895 54.824 377.88 61.112 377.88 69.368V113H364.776V34.088H377.88V45.32C380.472 41.288 383.976 38.168 388.392 35.96C392.904 33.752 397.848 32.648 403.224 32.648Z"
      stroke="#A12DCA" stroke-width="6" mask="url(#path-1-outside-1)" />
    <path
      d="M549.708 113L508.38 67.208V113H495.276V12.632H508.38V59.144L549.852 12.632H566.411L520.908 62.888L566.844 113H549.708Z"
      stroke="#A12DCA" stroke-width="6" mask="url(#path-1-outside-1)" />
    <path
      d="M615.895 114.296C608.503 114.296 601.783 112.616 595.735 109.256C589.783 105.896 585.079 101.144 581.623 95C578.263 88.76 576.583 81.56 576.583 73.4C576.583 65.336 578.311 58.232 581.767 52.088C585.319 45.848 590.119 41.096 596.167 37.832C602.215 34.472 608.983 32.792 616.471 32.792C623.959 32.792 630.727 34.472 636.775 37.832C642.823 41.096 647.575 45.8 651.031 51.944C654.583 58.088 656.359 65.24 656.359 73.4C656.359 81.56 654.535 88.76 650.887 95C647.335 101.144 642.487 105.896 636.343 109.256C630.199 112.616 623.383 114.296 615.895 114.296ZM615.895 102.776C620.599 102.776 625.015 101.672 629.143 99.464C633.271 97.256 636.583 93.944 639.079 89.528C641.671 85.112 642.967 79.736 642.967 73.4C642.967 67.064 641.719 61.688 639.223 57.272C636.727 52.856 633.463 49.592 629.431 47.48C625.399 45.272 621.031 44.168 616.327 44.168C611.527 44.168 607.111 45.272 603.079 47.48C599.143 49.592 595.975 52.856 593.575 57.272C591.175 61.688 589.975 67.064 589.975 73.4C589.975 79.832 591.127 85.256 593.431 89.672C595.831 94.088 598.999 97.4 602.935 99.608C606.871 101.72 611.191 102.776 615.895 102.776Z"
      stroke="#A12DCA" stroke-width="6" mask="url(#path-1-outside-1)" />
    <path d="M686.692 6.44V113H673.588V6.44H686.692Z" stroke="#A12DCA" stroke-width="6" mask="url(#path-1-outside-1)" />
    <path
      d="M743.442 114.296C736.05 114.296 729.329 112.616 723.281 109.256C717.329 105.896 712.625 101.144 709.169 95C705.809 88.76 704.13 81.56 704.13 73.4C704.13 65.336 705.857 58.232 709.313 52.088C712.865 45.848 717.666 41.096 723.714 37.832C729.762 34.472 736.53 32.792 744.018 32.792C751.506 32.792 758.274 34.472 764.322 37.832C770.37 41.096 775.122 45.8 778.578 51.944C782.13 58.088 783.906 65.24 783.906 73.4C783.906 81.56 782.081 88.76 778.433 95C774.881 101.144 770.034 105.896 763.89 109.256C757.746 112.616 750.93 114.296 743.442 114.296ZM743.442 102.776C748.146 102.776 752.562 101.672 756.69 99.464C760.818 97.256 764.129 93.944 766.625 89.528C769.217 85.112 770.513 79.736 770.513 73.4C770.513 67.064 769.266 61.688 766.77 57.272C764.274 52.856 761.009 49.592 756.977 47.48C752.945 45.272 748.577 44.168 743.873 44.168C739.073 44.168 734.657 45.272 730.625 47.48C726.689 49.592 723.522 52.856 721.122 57.272C718.722 61.688 717.521 67.064 717.521 73.4C717.521 79.832 718.673 85.256 720.977 89.672C723.377 94.088 726.546 97.4 730.482 99.608C734.418 101.72 738.738 102.776 743.442 102.776Z"
      stroke="#A12DCA" stroke-width="6" mask="url(#path-1-outside-1)" />
    <path
      d="M814.239 46.904C816.543 42.392 819.807 38.888 824.031 36.392C828.351 33.896 833.583 32.648 839.727 32.648V46.184H836.271C821.583 46.184 814.239 54.152 814.239 70.088V113H801.135V34.088H814.239V46.904Z"
      stroke="#A12DCA" stroke-width="6" mask="url(#path-1-outside-1)" />
  </svg>

Hello world! This is HTML5 Boilerplate.

"></script>


text:
Q: pro.javacard.gp.GPException: STRICT WARNING: Unfused JCOP detected When trying to list the content of smart card using following command
gp -l

Getting following exception :
pro.javacard.gp.GPException: STRICT WARNING: Unfused JCOP detected
at pro.javacard.gp.GlobalPlatform.printStrictWarning(GlobalPlatform.java:184)
at pro.javacard.gp.GlobalPlatform.select(GlobalPlatform.java:213)
at pro.javacard.gp.GPTool.main(GPTool.java:334)

When searched , I got to know that card is not pre-personalized.
My question is what is Smart Card pre-personalization?
Who does this pre-presonalization? is it a vendor?

A: Pre-personalization for JCOP Cards consists of sending a set of commands to an applet named Root Applet.
Manufacturer installed this special applet to provide some special accesses for card providers (Mr Bodewes mentioned these accesses in his answer).
Root Applet AID named Transport Key and is securely transferred to card's provider or anybody whom requested not-fused cards from NXP. (This AID is specific per card or a set of cards requested by a provider)
The commands that this applet supports included some READ and WRITE commands for restrictrd area of EEPROM.
Final step and mandatory step of pre-personalization is sending a command named FUSE command to ROOT Applet. This command make Root Applet disabled forever.
Before pre-personalization, there is no Security Domain available to select on the card, and Root Applet is the only active entity on the card, but after pre-personalization you have access to security domain and no access to Root Applet anymore.
I think this info is confidential, so do not publish them! :)

A: Pre-personalization for a Java Card consists mainly of setting up parameters within the operating system. You should think of things like the ATR but also for instance the Global Platform key set, memory configuration etc.. After a card is "fused" these settings cannot be changed anymore.
Pre-personalization is not standardized. This means you have to contact the card manufacturer about the details. In this case that would mean NXP Semiconductors.
Fusing means that the pre-personalization phase is finished and that the settings cannot be changed anymore. It points to fusing a resistor to disable specific chip functionality. In current chip / operating designs it may well be a logistical process instead.
Chips should normally be fused when used in the field. Usually the pre-personalization is performed at the manufacturer for demo-cards or at secured premises of card or inlay manufacturers.
In general you should be authenticated to the card to perform pre-personalization. So having an unfused card may not grand you special powers.

Note that if you look at the word, pre-personalization may involve anything before personalization. So this could include e.g. applet loading. In that sense it is probably better to think of the fuse command to end the initialization phase. As there is no authority on this you will hear different names for the different phases of the process of chip manufacturing.

A: Most Smart card application require that certain program and/or data files be installed on each chip before the card can personalized and given to a specific cardholder.This general preparation of software or files on the card is done through an operation called pre-personalization.
So it is done by vendor or cardholder.

A: Pre-personalization is like a configuration on Smart card for specific requirement. There can be following steps in pre-personalization:
1) Changing historical bytes of ATR.
2) Installation of Security Domains and or applications.
3) Storage of Global Platform Secure Channel Keys.
4) Personalization of Security Domains.
... etc...
Why we need personalization?
We make a common Smart Card operating system so that it can be configured as per the requirement. Like configuration for Visa, Master Card etc...
So after loading Smart Card OS on a chip we need to personalize the card as per the required features.
Who does this pre-presonalization?
It depends either card manufactures or Vendor may configure as per the requirement.


text:
Q: mb_strpos(): Offset not contained in string I found this function to create an excerpt for long text. I use this method to manage also accents like è é à ò ì ù ....
function excerpt($string, $lenght = 50, $popover = false, $ellipsed = false) {

    if ( $ellipsed ) {

      $ellipse = "...";

      if ( $popover )
        $ellipse = '...';

    } else {
        $ellipse = "";
    }

    $boundaryPos = mb_strrpos(mb_substr($string, 0, mb_strpos($string, ' ', $lenght)), ' ');

    return mb_substr($string, 0, $boundaryPos === false ? $lenght : $boundaryPos) . $ellipse;

}

Some tests:
echo excerpt("Il treno è partito", 11);
//RETURN Il treno è

echo excerpt("Il treno è partito", 15);
//RETURN Il treno è part

echo excerpt("Il treno è partito", 20);
//RETURN WARNING mb_strpos(): Offset not contained in string

How can I fix error for the last test?

A: You need to check if the length of the string is less than your length parameter because you can't find 20-th offset of the string, which has length of 19.
P.S. You also have a typo in your length parameter of the excerpt function.
function excerpt($string, $length = 50, $popover = false, $ellipsed = false) {

    if ( $ellipsed ) {

      $ellipse = "...";

    if ( $popover )
        $ellipse = '...';
    } else {
        $ellipse = "";
    }

    if ( strlen($string) < $length ) {
        return $string . $ellipse;
    }

    $boundaryPos = mb_strrpos(mb_substr($string, 0, mb_strpos($string, ' ', $length)), ' ');

    return mb_substr($string, 0, $boundaryPos === false ? $length : $boundaryPos) . $ellipse;

}

echo excerpt("Il treno è partito", 11);
echo excerpt("Il treno è partito", 20);


text:
Q: Sum of divisors of numbers of the range ~ 10^6 I was trying to find the sum of divisors of numbers upto 106. The test cases are like of the order of 105. I have done some pre processing like
int divisors(int num)
{
    int sum=0;
    for(int i=1; i*i<=num; i++)
        sum += (num%i)? 0 : ((i*i==num)? i : i+num/i);
    return sum;
}

Is there any better method to do the same. Should I also make an array of prime numbers or something like that?

A: Hint.  It is easier to figure out how many numbers in a range that, say, 12 will divide than it is to bother figuring out which ones it divides.
This gives you a O(n) algorithm that allow you to calculate your answer in likely acceptable time for 106.
If you want it faster, hint 2 is that you only have to do this up to n/2 - after that you just need the sum of the numbers, because each is a factor only once.  There is a well-known formula for the sum of all of the integers up to 'n', that provides a short circuit.  Still O(n), but a better factor.
For faster still, hint 3 is that you only have to do this up to n/3 - you have 2x the sum of the range from n/3 to n/2 and then all of the range from n/2 to n.  Same performance comment as before.
Hint 4 is that as you repeat this there is a more general pattern you can figure out.  Get it right and performance becomes O(sqrt(n)) which is definitely fast enough.


text:
Q: Custom interface in Java Lambda expression I have a method from library, which look like this:
<T> T invoke(K key, EntryProcessor<K, V, T> entryProcessor, Object... arguments);

And EntryProcessor interface has a single method definition:
T process(MutableEntry<K, V> entry, Object... arguments) throws EntryProcessorException;

Unfortunately for my use case I need EntryProcessor with Serializable.
One solution is to make a new class implementing both EntryProcessor and Serializable, in that case I would have to create a different class for each different use case.
Normally, without Serializable, I can call invoke method as a lambda, which saves me from creating pack of specialized classes.
foo.invoke(1L, (entry, arguments) -> {
    ...
    return null;
});

Is there a way to extend this lambda with Serializable interface?

A: how about this?
Object[] arguments = new Object[0];
EntryProcessor<Long, String, Integer> it;

it = (EntryProcessor<Long, String, Integer> & Serializable) (entry, args) -> 1;

invoke(1L, it, arguments);


text:
Q: Icon Background on IE6 I'm developing a website (using asp.net by the way) and I'm having a problem with IE6.
When I use some icons near links, using background-image and padding-left on the links, the icons display nice on FF and Chrome but in IE6 they take a kind of "gray" background, and sometimes the flash strangely.
Any ideas? is there some CSS hack to solve this? Thanks everyone!

A: Are they .png files? IE6 has issues with alpha transparency in .pngs. There is a javascript fix though.
Edit, to clarify - If IE6 sees a .png with alpha transparency (which is different than the transparency in .gifs) it freaks out and renders that part the light gray I believe you are seeing. The javascript fix applies a filter to all the .pngs in the page. However, this does not work on .pngs that have been set as backgrounds via css.

A: Be careful with the PNG fix in IE6 - it uses a DirectX filter and it's relatively slow. If you have a lot of images on a page (for instance an icon on each row of 25 in a table) it can slow the page down quite a bit.
We found that the only performant solution was to server up aliased GIFs to IE6 and PNGs to everyone else.
Ho hum, it's just yet another reason to hate IE6 and all who sail in her.


text:
Q: PyQt5: Gtk-CRITICAL **: IA__gtk_widget_style_get: assertion 'GTK_IS_WIDGET (widget)' failed I'm getting this error with PyQt5, and I think I get this error only when I use QTextEdit. I tried using QLineEdit in the place of QTextEdit and it worked without problem. Using QTextEdit when I open the program I get that error and the program runs very slow. Error:(python:4843): Gtk-CRITICAL **: IA__gtk_widget_style_get: assertion 'GTK_IS_WIDGET (widget)' failed
import sys
from PyQt5.QtWidgets import (QWidget, QLabel, QLineEdit,
    QTextEdit, QGridLayout, QApplication)

class Example(QWidget):

    def __init__(self):
        super(Example, self).__init__()

        self.initUI()

    def initUI(self):

        title = QLabel('Title')
        author = QLabel('Author')
        review = QLabel('Review')

        titleEdit = QLineEdit()
        authorEdit = QLineEdit()
        reviewEdit = QTextEdit()

        grid = QGridLayout()
        grid.setSpacing(10)

        grid.addWidget(title, 1, 0)
        grid.addWidget(titleEdit, 1, 1)

        grid.addWidget(author, 2, 0)
        grid.addWidget(authorEdit, 2, 1)

        grid.addWidget(review, 3, 0)
        grid.addWidget(reviewEdit, 3, 1, 5, 1)

        self.setLayout(grid)

        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('Review')
        self.show()

if __name__ == '__main__':

    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())

A: I found a solution for this problem. Changing the style of the application
didn't show the error and everything worked properly.
Corrected Code:
if __name__ == '__main__':

    app = QApplication(sys.argv)
    app.setStyle("fusion") #Changing the style
    ex = Example()
    sys.exit(app.exec_())

More about styles here: http://doc.qt.io/qt-5/gallery.html