How to avoid big banks of buttons?

Question: What are some alternatives to having repetitive rows buttons that create large banks like the one shown below.
I think it's too visually dominant and distracting, not least because there's one of those optical illusions (where dots appear in the gaps when you scan.
Any potential solution will need to be touch and repsonsive friendly.
Comment: it makes the data in the rows appear blurry too
Comment: That optical illusion you refer to above is called the "Hermann grid illusion".
Answer: Buttons tend to convey actions, while it looks to me more like these are navigation links. Showing them just as regular links (following whatever style in your app) would be probably be much less imposing both visually and as an action to take.

You can also take this a step further, and provide some more useful information instead of simply displaying buttons or links, by showing the number of items (or some other type of information about them) relevant for each as a hyperlink:

If there is a limit, then you can show that as well (eg: 2 of 10).
This may also make the application more complex, or cause a performance hit that's not worthwhile, but it could be worthwhile especially if it saves the user time (and the need to navigate into several items to discover nothing is there).
Comment: Good input, thanks. Regarding the provision of more helpful information, unfortunately we're not really in a position to approach developers with anything more than "strip and tweak" changes. Right now, if it's a costly change/update, it's not going to get approved. Your advice is good though, but perhaps for a time when we can make some real changes.
Comment: Understood. I think you could still use navigation links, labelled just as "Users" "Roles" etc (updated my answer to elaborate on this).
Comment: Yup, I'm probably going to go with something like this, thanks.
Answer: CTA and Buttons
Call to action buttons appear in any given workflow to represent and enable completion of task priorities, as such, they are always distinct graphically as well as semantically; a verb is used for example "view" "download" etc
So having four buttons in a row creates a situation where CTA buttons are competing for users attention as well as being not clearly distinguishable. This does not only visually overwhelm users it also distracts them from focusing on what exactly needs to be done. below is a similar example to the one you shared:

Restructure and prioritize
To solve this issue you need to restructure and prioritize the different pieces of information you have in your the table. This will allow you to introduce structure and visual emphasis (icons and white space etc) and help you guide the user attention to the most important calls to action.
To come-up with a structure you could:

Aggregate actions in logical entities, For example "users" and User "applications"
Ask your users to provide a prioritized list of actions or groups of actions that they use the most.
Gather or obtain information about the use frequency for each of these actions.

The result of this exercise should hopefully allow you to layout snippets of information and action points in a manner that is most optimized for the task at hand. Below is a redesign of the table based on the example I shared above:

When laying-out the new design try to incorporate items left to right & top to bottom as this follows F-Shaped Pattern For Reading Web Content
Answer: The simple answer is to use a combobox like the following:

download bmml source – Wireframes created with Balsamiq Mockups
Comment: Not sure why this has been down voted so heavily as it's a legit solution. Not all answers need walls of text to be valid.
Comment: I think a check box for each element with a unified combobox is a good compromise.
Answer: Are all 4 buttons equally important? It might make sense to have the main action as a full button and tuck the rest into a button dropdown. It'll make it easier for users to tell which is the main action and still have the rest be accessible is a touch friendly fashion.
The second thing you can look at is button color. The blue is very strong against the light gray, which is what's causing the optical dots effect. A strong color make sense when use strategically to highlight the primary action, like a save button. When you have rows of buttons like this, you should introduce a secondary button type with a light button background color.
Comment: I'd like to avoid hiding stuff in dropdowns as much as possible, but it's a good point about color. We could just change to an empty button shape, like the "default" button in Bootstrap 3.
Answer: The table is distracting because of:

High contrast between the buttons and the tables.
Grid layout of the buttons creates an unfortunate grid illusion
The palette is visually distracting:  you have banded rows already, and then are superimposing a saturated darker blue.  That's a lot to deal with when the eye already has trouble navigating a complex table structure.
The button shape and color dominates the text, so it's not easy for users to discern that the buttons are actually the same for every row.

A designed approach:
Assuming the rows are of touch-friendly height, and you want to keep the "one-click" nature of the interface (i.e. you don't want to hide the buttons)...then if you follow the logic above you can just remove the high contrast, simplify the palette to gray, and fade the text a bit to render the options more grid-friendly, scannable, and harmonized with the color palette:

(You will probably need to darken the buttons because they seem to have lose their contrast when I took the screenshot)
Hope that helps

How to avoid big banks of buttons?


400 Bad Request (Flask + html)

Question: I keep getting a 400 Bad Request when I try to run my Flask project.
I have to do a project using Flask and HTML, and it was supposed to be a group project, so members would have to learn different parts of it to then gather everything. Sadly, my 'group' didn't do anything at all
Here's my code:
Flask
app = Flask(__name__, static_url_path="")

@app.route('/', methods=['POST','GET' ]) #1 - Login e criar conta

def PagInicio():
    button = request.form["button"]
    if request.method == 'POST':
        if button == "login":
            return render_template("Princ.html")
        elif button =="criar":
            return render_template("Criar.html")
        else:
            return render_template("Inicio.html")

    return render_template("Inicio.html")

HTML:

                <form class="vertical" method="POST" action="/">
                <fieldset>

                        Usuário
                        <input id="usuario" name="usuario" type="text" />

                        Senha
                        <input id="senha" name="senha" type="password" />

                        <button class="medium" value="login" Login</button>

                                    <button class="medium" value="criar" Criar</button>

                </form>

Comment: What is your question?
Comment: i just created this account, i didn't know if i should simplify my explanation or not
Comment: well, my code was supposed to be an app... i was just trying to integrate flask with html, but the error "400 bad request" keeps happening. I am not sure what should i do to make that work
Comment: @MattiJohn: when you run this code and try to access the Flask server, you get a 400 Bad Request response. That's it. The OP did make that part of the title.
Answer: You are trying to access the request.form dictionary, always:
button = request.form["button"]

This throws a 400 response error if there is no such value in the form. This is always the case when you have a GET request, request.form is only populated when there is POST data in a valid format.
Only try to access the button when you already confirmed you have a POST request:
def PagInicio():
    if request.method == 'POST':
        button = request.form["button"]
        if button == "login":
            return render_template("Princ.html")
        elif button =="criar":
            return render_template("Criar.html")
        else:
            return render_template("Inicio.html")

    return render_template("Inicio.html")

Next, you don't actually have any form element named button. You have button form elements but none have a name. Give all your buttons the same name attribute, varying the value attribute:

<button class="medium" name="button" value="login"> Login</button>

<button class="medium" name="button" value="criar"> Criar</button>

Note that you malformed the <button tags too.

400 Bad Request (Flask + html)


how to add progress view in moya swift?

Question: how to add progress view in moya swift ?,
is this correct. is this a correct way to use progressblock.
let instance = MoyaProvider<ServiceType>()

    self.view.showLoadingHUD()

    instance.request(.GetRouteDetail, callbackQueue: DispatchQueue.main, progress: { (response) in

        if response.completed{

            self.view.hideLoadingHUD()
        }else{

            self.view.showLoadingHUD()
        }

    }) { (result) in

        switch result{
        case .success(let response):
            print(response)

        case .failure(let error):

            print(error)
            self.view.hideLoadingHUD()
        }
    }

Comment: @Anbu.karthik  why u deleted ur answer?
Comment: I reopned my answer check once
Answer: You can simple hide your LoadingHUD in the result closure only
let instance = MoyaProvider<ServiceType>()

self.view.showLoadingHUD()

instance.request(.GetRouteDetail, callbackQueue: DispatchQueue.main, progress: { (response) in
// You can update the progress percent ...here or ignore it
}) { (result) in
    self.view.hideLoadingHUD()

    switch result{
    case .success(let response):
        print(response)
    case .failure(let error):
        print(error)
    }
}

Comment: what happen if api failed?
Comment: @VasanthanPrem - if api failed it automatically reach the failure part
Answer: just modify the hideLoadingHud in inside the success or failure block. bz that part result handler
 let instance = MoyaProvider<ServiceType>()

    self.view.showLoadingHUD()

    instance.request(.GetRouteDetail, callbackQueue: DispatchQueue.main, progress: { (response) in

    }) { (result) in
         self.view.hideLoadingHUD()
        switch result{
        case .success(let response):
            print(response)

        case .failure(let error):

            print(error)

        }
    }

how to add progress view in moya swift?


Understanding Fourier Transforms

Question: I'm trying to understand Fourier Transforms, so I thought I'd try to explain the following in an english sentence, but I can't.
If I bury myself in equations, I can trick myself into understanding the theory, but clearly I don't understand since I can't explain this simple picture (I realize it's not a periodic function, but I was hoping that by fully internalizing the theory, I would be able to explain what's going on in this picture).
I plotted 1000 random sorted integers between 0 and 1000 (in blue) and then plotted the discrete Fourier transform against that (in red). What is the meaning of the resulting graphs? I'm not even sure what the axes are.
Comment: I wonder if this would be more appropriate for the [math.SE] SE site. Do you see this question as statistical?
Comment: @gung I'll move. Sorry.
Comment: No need to apologize. Please don't cross post, though. That is against SE policy. Flag your question to be migrated. If you do post there, delete this one.
Comment: I can't reproduce. Do you know what you are doing?
Comment: @mathreadler I'm literally just `sorting` a `[list of 1000 unique random ints]` and then applying `fft` to that list.
Answer: You did not choose the easiest function to understand fourier transforms.
I advise you to begin with fourier series, which is applicable for any periodic function (such that its fourier series exists and converges, that includes all periodic continuous functions)
Try the fourier transform of a sum of sines.
Then, if you want to, you can calculate the fourier series of a square or triangle function, (it will have an infinite number of non-null points).
Try to sum the first twenty terms of a fourier series (for the triangle function for instance).
Then try some fourier transforms.
Answer: Lets notice some key aspects of the DFT graph first:
1) It "seems" to be periodic, and unfortunately the original spatial graph does not have slope 1 (i.e. f(x) = x), so the period is not 1000, but instead something around 630?
2) It looks "strongest" around the endpoints.  Because we are dealing with the discrete FT, if it is "strong" at the left end point, it will be strong at the right too.
3) I am not sure why the transformed plot is zero-ed out at $-500,$ this seems off to me.  One would expect the fourier transformed data ${\hat f(n)}$ to be approximately 500 for very small $n.$ Why? Because the mean value of $f(x)$ is $500$.
Now to discuss what these things mean.  The Fourier Transform (Discrete FT) is transforming your spatial function $f(x)$ to a reciporical space function ${\hat f}(n).$  This isn't magic, just look at the dimensions of the units in the transform,
\begin{equation}
{\hat f}(n) = \int f(x) e^{inx} \; dx.
\end{equation}
The exponential must be raised to a dimensionless quantity, so $n$ has the dimensions of $1/$length, if $x$ has dimensions length.  This means the $y$ axis of the transform graph has units proportional to $1/x.$ Also, if $x$ has units of time, then the Fourier space is commonly referred to as frequency space.  In physics, it many times is presented as momentum space.
How to interpret the result: Since variable $n$ can be though of as frequency, the $y$ axis is the relative "strength" of that frequency in your function $f.$  For example, if $f$ was the addition of two sine waves of different frequency, its ${\hat f}$ would have 2 nonzero values corresponding to those two frequencies. The DFT is typically a dirty looking graph, simply because you deal with non-smooth data, but the intepretation is the same.  Your original $f$ can be decomposed (or written as) a combination of low frequency waves, and ${\hat f}$ is telling you how strong those frequencies are present in $f.$
The last point corresponding to (1) above that I wanted to make was the periodicity.  Built into the DFT is the assumption that your data is periodic, with the period of the size of your data.  Meaning if you have $f$ defined on $0< x < 1000,$ the DFT assumes your function repeats after $x$ passes 1000. This is why the DFT graph appears periodic as well.  Generally, it shouldn't be interpreted that there are "really strong" high frequencies in your original $f.$
Comment: Good answer but probably needs more practice and trial and error first to know what we are doing.

Understanding Fourier Transforms


Where are cats in minecraft and can they be trained?

Question: While I am outside collecting resources I never see any cats around, what can they do for me?
Comment: You are free to ask these types of questions, but don't expect a very good reception; Minecraft, especially, as very detailed reference resources, and these questions don't demonstrate a very high level of effort on your part.  Arqade works and responds better to more effort; you get better answers, we get better content.
Comment: -1 for asking something easy to research.
Comment: O.K., I asked this as a simple thing because I was just wondering and preferred to this site instead of googling it to use my account some.
Answer: Cats are a friendly mob found in Jungle Biomes. They can be tamed with raw fish, and will change colors and become domestic. The one real use for them is to keep creepers away. While they won't deter a creeper charging at the player, creepers will stay farther away in general.
Read more here.
Comment: Just like real cats. They *supposedly* serve a purpose but they're never around when you need the damn things.


Can you use PEX for venting?

Question: Is there such an option as using PEX for an 1-1/2 vent ? I have a stretch where I need some flexibility for my pipe which is going to be difficult to achieve with copper or ABS.
this is related to this question
What fittings can I use to re-route my copper DWV pipe?
Comment: Check your locks code.  Some areas allow heat bending of pvc vent pipes
Comment: the PVC won't fit through that opening where I need it to be (remember where we discussed the 90 elbow I was looking for)
Answer: Pex is only legal for supply plumbing. It's not rigid enough for drain or vent use, as the lack of internal pressure could result in it being constricted.

Can you use PEX for venting?


Calculate age from 2 dates on SPSS - reference issue

Question: I am trying to calculate the age of some participants based of the date of birth (currently named 'age') and date of evaluation (currently name 'date')
I wrote this script, which seem to be the right one, but when I run it, the data cells remain empty.
Compute age=datediff(date,age,'years').

If I write the following, the new variable created has the correct values, which make me think the formula is right, but since theres a reference to the old variable in the formula it might create an error.
Compute age2=datediff(date,age,'years').

Therefore I was wondering why the first script didn't work and if there is a way to make it work.
Answer: I assume variables date and age are date variables. When you calculate the difference between them in a new variable, it is automatically a numeric variable, which goes well with the integer value of the function. But when you calculate it into an existing date variable, you get a missing value because a two digit integer has no meaning in a date variable.
If you insist on having variable age contain the result of the calculation, do this:
rename vars age=born.
Compute age=datediff(date,born,'years').

Comment: that wont work - once you've calculated `age` and it's a missing value, changing that to a numeric wont help. See suggested code in my edit.
Comment: That makes a lot of sense yes. I'll just change the variable type then.


dell p2419h ubuntu 75 hertz

Question: I have a Dell p2419h monitor and Ubuntu 21.04. Right now I have a maximum 60 hertz that I can set the monitor to. It should be 75. I did not find any information about drivers for Ubuntu or any recommendation or user guide. 60 hertz is not comfortable for eyes. Can my monitor work with 75 hertz on 1920x1080?
Answer:
Can my monitor work with 75 hertz on 1920x1080?

No, it can't, according to the manufacturer's published specifications:

Maximum Preset Resolution
1920 x 1080 at 60 Hz

Regarding your assertion "60 hertz is not comfortable for eyes" citations are needed. Most FHD monitors works at 60Hz and users don't complain. Even if that was the case - it isn't - asserting that an higher frequency would somehow improve it has no scientific basis.
Comment: but dell publish `Refresh Rate 75 Hz` for this model or it's mistake ?
Comment: No, not a mistake, just a misunderstanding. 75Hz can be achieved with lower than the native (and recommended) resolution.

dell p2419h ubuntu 75 hertz


Delphi & SAML (Web apps or desktop apps)?

Question: is the SAML protocol (Sing Sign ON) used soley for web apps and web services, or is it also used for standard applications?
REVISED:
I am looking for some windows (Standard Applications (not web based)) protocols for Single Sign On
Answer: If you are looking at Windows specifically, why not use Kerberos and Integrated Windows Authentication? It's built into Active Directory and Domain Controllers. It doesn't really work once you start crossing into the Internet and different security domains but it works well behind your firewall in a corporate environment.
However, SAML can be used for desktop applications. I've run into applications before that would retrieve the Kerberos ticket from the Desktop, make a WSTrust/RST call to an STS to validate the Kerb token and get back a SAML token in the RSTR that would be embedded into a Web Services call that the desktop application needed to make.
Answer: SAML allows secure web domains to exchange user authentication and authorization data and by definition would require an internet connection to do so. So no you would not want to use it for a desktop application.
Revised
here are the links for active directory implementation with Delphi.
http://www.agnisoft.com/white_papers/active_directory.asp
http://adsi.mvps.org/adsi/Delphi/index.html
Comment: What is it that you are trying to do though?
Comment: Actually, i was wondering if SAML could be used for SSO for a Windows domain?
Comment: I am looking for some windows (Standard Applications (not web based)) protocols for Single Sign On
Comment: It sounds like you would want to used Active Directory. Have you thought about that yet? I can post some links to help you integrate your delphi app with Active Directory.
Comment: Yes, that may be what I am looking for
Comment: I've revised my answer with those links. Hope this helps you out, let me know if it does.


Component vectors from a 3D vector

Question:
If vector $v_{xy}$ is a vector on the $xy$ plane of magnitude $r$, and $v_{yz}$ is a vector on the $yz$ plane also of magnitude $r$, then $v_{xy} + v_{yx}$ results in vector $v$ of magnitude $R$.
How, given any vector $v$ to start with, can you calculate the two vectors $v_{xy}$ and $v_{yx}$ (which both have equal magnitude $r$) that add together to produce $v$ ?
A solution can be expressed in either cartesian or preferably polar coordinates.
(For clarity, I am not seeking to resolve into unit vectors, but specifically find the 2 vectors of equal magnitude from perpendicular planes that add to produce the vector $v$ of magnitude $R$)
Answer: Impossible.
Add the two vectors of the same color to see each sum gives the black vector.

Now interpret that result.
Same thing in three dimensions:

Or more generally:
Comment: In your first example, all the vectors are in the same plane. I am specifically looking for two vectors from perpendicular planes.

If you look at the attached image in OP there is an example.
Answer: Did you mean to say that $v_{xy} + v_{yz}$ results in a vector $v$ of magnitude $R$? And did you mean to say the vector $v$ is given? (You referred to $R$ as a magnitude, and then as a vector). If the vector $v$ is given, and hence its magnitude $R$ as well, then you can find the vectors $v_{xy}$ and $v_{yz}$ lying in the $xy$-plane and $yz$-plane respectively as follows:
Let $v_{xy} = \left[ \begin{matrix}
v_{xy,1} \\
v_{xy,2} \\
0
\end{matrix} \right]
\text{ and }
v_{yz} = \left[ \begin{matrix}
0 \\
v_{yz,2} \\
v_{yz,3}
\end{matrix} \right]$
. Because these sum to the known vector $v =
\left[ \begin{matrix} v_1 \\
v_2 \\
v_3\end{matrix} \right]$,
we can immediately see that $v_{xy,1} = v_1$ and $v_{yz,3} = v_3$, so we now know those coordinates. What is left is to find the two coordinates $v_{xy,2}$ and $v_{yz,2}$.
To solve for these, we use the fact that $v_2 = v_{xy,2} + v_{yz,2}$, and
because both $v_{xy}$ and $v_{yz}$ have the same magnitude (and hence the same squared magnitude), we can write
$r^2 = v_{1}^2 + v_{xy,2}^2 = v_{yz,2}^2 + v_{3}^2$.
To solve this system of two equations, begin by substituting $v_{xy,2} = v_2 - v_{yz, 2}$ into the second equation, so we have
\begin{align*}
v_{1}^2 + (v_2 - v_{yz, 2})^2 & = v_{yz,2}^2 + v_{3}^2 \\
v_{1}^2 + v_2^2 - 2v_2 v_{yz, 2} + v_{yz, 2}^2 & = v_{yz,2}^2 + v_{3}^2 \\
 v_{yz, 2} & = \frac{v_{3}^2 - v_{1}^2 - v_2^2}{- 2v_2} \\
v_{yz, 2} & = \frac{v_{1}^2 + v_2^2 - v_{3}^2}{2v_2} \\
\end{align*}
and
\begin{align*}
v_{xy, 2} & = v_2 + \frac{v_{3}^2 - v_{1}^2 - v_2^2}{2v_2} \\
v_{xy, 2} & = \frac{v_2^2 + v_{3}^2 - v_{1}^2}{2v_2} .
\end{align*}
So the two vectors are
$
v_{xy} = \left[ \begin{matrix}
v_1 \\
\frac{v_2^2 + v_{3}^2 - v_{1}^2}{2v_2} \\
0
 \end{matrix} \right]
\text{ and }
v_{yz} = \left[ \begin{matrix}
0 \\
\frac{v_{1}^2 + v_2^2 - v_{3}^2}{2v_2} \\
v_3
 \end{matrix} \right]$.
Note: I've implicitly assumed that $v_2 \ne 0$. If $v_2 = 0$, then there are many such pairs of vectors, as the image in @David_G._Stork's answer shows.
Comment: That perfectly answers the question in cartesian. Thanks. Is there any way of doing the same just using polar?
Comment: Polar coordinates are a coordinate system for $\mathbb{R}^2$, but these vectors are in $\mathbb{R}^3$. You could use cylindrical or spherical coordinates for $\mathbb{R}^3$.
Comment: Sorry yes I do mean spherical. Is it possible to take a vector in spherical coordinates and find the 2 component vectors as above without reverting to cartesian?
Answer: This is a supplement to erikpekerson's answer rather than a complete answer in itself.
We can find the unknown $y$-coordinates of the two vectors by noting that they form the sides of a rhombus with the original vector as one diagonal. Thus, the orthogonal projections of $v_{xy}$ and $v_{yz}$ onto $v$ are both $\frac12v$, from which $v_{xy}\cdot v = \frac12v\cdot v = \frac{R^2}2.$ So, for $v_{xy}$ we have $$v_1^2+yv_2 = \frac{v_1^2+v_2^2+v_3^2}2 \\ y = {v_2^2+v_3^2-v_1^2\over 2v_2}$$ and similarly for $v_{yz}$.
For the same reason, the two vectors lie in the plane perpendicular to $v$ and halfway along that vector, i.e., the plane $v_1x+v_2y+v_3z=\frac{R^2}2$. The two vectors are the intersections of the lines $(v_1,s,0)$ and $(0,t,v_3)$ with this plane, which can be computed in various ways, including a direct computation using the Plücker matrices of these lines. For instance, for $v_{xy}$ we would get the homogeneous coordinates $$(v_1,0,0,1)\cdot(v_1,v_2,v_3,-R^2/2)\,(0,1,0,0) - (0,1,0,0)\cdot(v_1,v_2,v_3,-R^2/2)\, (v_1,0,0,1) = (-v_1v_2,v_1^2-R^2/2,0,-v_2),$$ which dehomogenizes to the same vector computed in other ways.

Component vectors from a 3D vector


S3 size limit on ApiGateway created by CloudFormation

Question: I have a cloud formation template that defines a new api gateway:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: API for getting planetary info
Resources:
  PlanetsApi:
    Type: AWS::ApiGateway::RestApi
    Properties:
      Name: "Planets API"

I have CodePipeline set up to create this as a change set and then execute the change set.
When the change set executes, it fails with the following error:
13:55:28 UTC-0400   CREATE_FAILED   AWS::ApiGateway::RestApi PlanetsApi S3 object size exceeds limit of 2 MB

I don't know where this limit is coming from, or why anything is being uploaded to S3. Google searches are turning up no useful information. Curiously, if I create the change set and execute through the CloudFormation console, I don't get any errors.
What am I doing wrong?
Answer: Had the same problem. And wow, I realized when I use aws cloudformation package, it creates a BodyS3Location with its properties (Bucket and key) under where I define my Type: AWS::ApiGateway::RestApi. This happens, even though I had not defined such parameters earlier in my template, before being processed by cloudformation package. This, then causes the error.
What I did to tackle this issue:

Let the CodePipeline to run, and fail (with the error)
Go to the AWS Console, find the failed stack, and expand Template
Find the lines in which BodyS3Location and its parameters are generated (for me they were in lines 22 to 24)
Add a command in buildspec.yml to delete these lines, after the
package command (example below)

aws cloudformation package --s3-bucket some-s3bucket --template-file ./template.yml --output-template-file ./packaged-template.yml
sed --in-place '22,24d' packaged-template.yml

commit and push to repo again
It must work now!

Note: This is not the best solution, this issue must be solved, from AWS end!

UPDATE:
It is something to do with the AWS CLI version. Try installing this version before running the cloudformation package command (in your CodeBuild), and you should be good to go.
pip install awscli==1.11.37


Windows 10 Overrides boot settings in UEFI BIOS, requires Live CD fix to repair

Question: I have been dual booting for years now and have problem I can't seem to solve myself. As we all know Windows is an arrogant dick, and in my case whenever I chose to boot to it it will, automatically without asking me, alter my boot up settings in my BIOS and make itself de-facto king. Mildly annoying as all I had to do with enter setup, change the boot order and carry on.
Now however it is ALSO deleting the grub entry option in my BIOS, meaning I need to load a Live-USB and perform a boot repair (or what have you) to fix it. Long winded just to fix grub.
Now, several questions:

How do I stop Windows 10 from doing this? (would fix all my problems)
Else, since this never used to happen, is there a way of remaking the Grub boot option in my BIOS without a long winded string of commands to reinstall grub? (why is the grub option now not sticking around)
Would I be better of not using EFI boot options if possible (all of my disks are less than 1TB) if that's possible.

Using an AsRock Z77 Extreme 4 motherboard. Have 3 SSD's laid out like this currently (in case my method is just wrong someone can correct me):

Disk A is 240GB and used for Windows. I left 550MB free for another EFI partition and let Windows do it's thing with the rest of the drive.
Disk B is 120GB and used for root, and it has a 'backup' partition on there (not required by either OS on boot).
Disk C can be ignored essentially, 1 partition, mounted to /home and used only by Linux.
NAME   FSTYPE   SIZE MOUNTPOINT          LABEL
sda           238.5G
├─sda1           16M
├─sda2 ntfs   237.9G
└─sda3 vfat     525M /boot/efi
sdb           119.2G
├─sdb1 ext4      62G /media/root/Furnace Furnace
└─sdb2 ext4    39.4G /
sdc             477G
└─sdc1 ext4     477G /home

What do now?
Comment: Regarding 1. we do not support Windows.  my solution was to remove Windows ;-) You can do that too: make a backup of personal files. put Ubuntu on all of the disks. install virtualbox, windows in there, the software you need in windows and restore your files.
Comment: Boot-Repair uses grub to reinstall grub. And grub uses the efibootmgr command to add & set ubuntu as first entry. Can you not use efibootmgr to change boot order? Some other alternatives: https://askubuntu.com/questions/486752/dual-boot-win-8-ubuntu-loads-only-win/486789#486789  and just boot order: http://askubuntu.com/questions/485261/change-boot-order-using-efibootmgr
Comment: I am able to use this to patch my boot issues. I am now back to my starting point as I cloned the Grub entry to stop it from being deleted (I always have a backup). Now I am down to the windows issue (not for this thread really but the linux community are more likely to have an answer to it than the Windows one). Thanks for you help.
Answer: Using 'efibootmgr' I was able to clone my grub entry (a couple of times to be sure) in order to stop this from happening.
efibootmgr -v
Boot0000* Grub - Linux  HD(1,GPT,0a6d5fbb-b2bf-45f9-a81a-9a8de8693dcd,0x800,0x106800)/File(\EFI\ubuntu\shimx64.efi)

I was then able to copy it (make a new one with identical params) like so:
sudo efibootmgr --create --disk /dev/sda --part 1 --write-signature --loader /EFI/ubuntu/shimx64.efi --label "Linux - Grub" --verbose

This obviously doesn't solve the Windows being a dick part (but as mentioned in comments, this is not the place for that).
Thanks,
Noki
Comment: This is not Grub specifically. This is to modify the EFI (BIOS) directly. Then grub references this to boot into whatever OS. I never directly solved this problem, it just went away by itself. Maybe a Windows update. Not that I use Windows much at all anymore.
Comment: Could you explain a bit more? As in, does your second code remake/reinstate the grub? or just backs it up after cloning it?


Boiler Won't Fire after adding Taco Relay 506-4 to Existing HW l8124a,c setup

Question: Boiler: Tranco (can't find model or other info anywhere on it)
Relay: Taco 506-4 (using Taco 007 calculator pumps)
Aquastat: Honeywell l8124a,c
I just finished installing two new zones and a new relay controller on my Tranco boiler and am now in the testing phase. When any thermostat calls for heat through the relay control the isolated end switch does it's job properly and closes the connection (as a dry contact). On the a'stat TT connections I measured that the connection is closed properly and the switch at the top (metal plate that clatters on and off- not sure on the name) closes correctly. At this point I would expect that B1/B2 would be energized and send some power down to my burner, but nothing is happening. I see a measly .05 volts on B1/B2 and even less on the burner contacts.
I know it's a possibility that my aquastat burner control is fried, but I'm hoping it's something more simple. The a'stat worked fine last winter and kicked off properly as expected.
Pics of the setup... Ignore the Hi/Low settings. I messed with them to see if the temp sensor was the issue.
Comment: What happens if you jumper past the relay? If that makes everything run normally the relay and/or its installation are the problem, if not you disrupted something else or have the relay connected _entirely_ incorrectly.
Comment: The only connection from the relay to the a'stat is from XX to TT. I have jumped TT and the metal plate clicked as normal but still no burner ignition.
Answer: The issue ended up being that my aquastat was busted. After exhausting all other possibilities I bought a new one and hooked it up and everything works fine.
I have no idea how the original broke, but it's safe to say that it did.


Export React component with two property

Question: I'm using MaterialUI and I have to export my components like this:
import withStyles, { WithStyles } from "@material-ui/core/styles/withStyles";

...

export default withStyles(styles)(Users);

Now I started to use i18next to use internationalization in my project but it want me to export my component like this:
export default translate("common")(Users);
The question is how can I satisfy both? How can I export with withStyles and translate?
Any help is appreciated
Answer: Both of those pieces of code produce a new component, so you can feed the result of one into the other. Done in one line, it would look like this:
export default withStyles(styles)(translate("common")(Users));

Or if it makes it easier to follow, here it is split on two lines.
const TranslatedUsers = translate("common")(Users);
export default withStyles(styles)(TranslatedUsers);

Answer: The purpose of higher-order components is to provide a way for components to be efficiently composed:
export default translate("common")(
  withStyles(styles)(Users)
);

It can be flattened with composition helpers, e.g. recompose:
import { compose } from 'recompose'

export default compose(
  translate("common"),
  withStyles(styles)
)(Users);


generate a post with an ajax and then send another ajax with post to another

Question: I am trying to print on a thermal printer, this, after performing a query and obtaining certain data, which I send to a hidden input, the problem is that I do not know how to insert and use the second ajax post to my file php for printing, I am using the Mike42 ECPOS library. would you be so kind to guide me?
function calcCredits(){
      /* variables from inputs */
      var last_credit= parseInt(document.getElementById("studentcredits").value);
      var namesec= document.getElementById("studentqr").value;
      var credits= parseInt(document.getElementById("money").value);
      var total_pay = credits * 35;
      var ttl_credits = last_credit + credits;
      /* Beggin Ajax */
        $.ajax({

          url:'addcredits.php',
          type:'post',
          data:{namesec:namesec,credits:credits},

          success:function(data){
            $.ajax({
                url: 'ticket.php',
                type: 'POST',
                success: function(response){
                      alert('Printing....');
                  }
                });
            }
        });
      }

this is the php that performs the search and shows the results
<?php

require 'database.php';
$con = new Database();
$pdo = $con->conectar();
$campo = $_POST["campo"];

$sql = "SELECT * FROM students WHERE student_qr LIKE ? OR student_secondname LIKE ? ORDER BY student_secondname ASC LIMIT 0, 10";
$query = $pdo->prepare($sql);
$query->execute([$campo . '%', $campo . '%']);

$html = "";
$data_query['result'] = $html;

while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $html .= "

                        Grupo
                        Nombre
                        Créditos

                        ".$row["student_group"]."
                        ".$row["student_name"]." ".$row["student_secondname"]." ".$row["student_lastname"]."
                        ".$row["student_credits"]."
                        <button type='button' class='btn btn-warning' id= 'show' onclick='show()' >Añadir Creditos</button>

    ";
}

echo json_encode($html, JSON_UNESCAPED_UNICODE);

and this is for printing
<?php

require __DIR__ . '/ticket/autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\EscposImage;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;

$nombre_impresora = "POS";
$connector = new WindowsPrintConnector($nombre_impresora);
$printer = new Printer($connector);

$printer->setJustification(Printer::JUSTIFY_CENTER);

    $printer->setJustification(Printer::JUSTIFY_LEFT);
    $printer->text("Producto Galletas\n");
    $printer->text( "2  pieza    10.00 20.00   \n");

$printer->setJustification(Printer::JUSTIFY_CENTER);
$printer->text("Muchas gracias por su compra\n");

$printer->feed(3);

$printer->close();

?>

sorry if it is not well structured I'm still practicing, thanks
Comment: From the code i see `location.reload()` is being called outside of the ajax success function. I suspect that may be the reason why your ajax calls fails. But need more info on the error you are facing
Comment: If I understand the issue correctly, then just make one call to some PHP file that fetches the data and prints it. If that's not what you're asking/having issues with, please clarify. It's a bit unclear since you've tagged the question with php, mysql and ajax, but only show the Ajax request (which is in JavaScript) but no PHP or MySQL. Also, is the printer connected to the client or the server?
Comment: Hello, the printer is connected to the server, the problem is that I don't know how to send the query data to the php for printing, I have removed the location.reload() part, for testing
Comment: I have added most of the code hoping you can help me
Comment: @GeorginaQ Can you check if this is useful for you?
https://stackoverflow.com/questions/51933513/jquery-usage-of-done-then-and-when-for-making-ajax-requests-in-a-giv
Answer: After the comments and contributions that helped me a lot, I noticed that my mistake was to forward the info to another file, when the printing could be treated within the first insertion php, so I added the ticket code and that's it.
this is the ajax function
function calcCredits(){

          $.ajax({
            /* Se envian datos por POST a PHP */
            url:'addcredits.php',
            type:'post',
            dataType: 'json',
            data:{
              studentqr:$('#studentqr').val(),
              credits:$('#credits').val(),
            },
          })
          .always(function(){
              console.log("complete");
          });
      }

and then, the php insert
<?php
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
include("conection.php");
include("ticket/autoload.php");

$credits = mysqli_real_escape_string($con, $_POST['credits']);
$studentqr = mysqli_real_escape_string($con, $_POST['studentqr']);

$stmt = $con->prepare("UPDATE students
  SET student_credits = (student_credits + ?)
  WHERE student_qr = ?");
$stmt->bind_param("is", $_POST['credits'], $_POST['studentqr']);
$stmt->execute();

$insert_query = $con->prepare("INSERT INTO historical_credits (id_student, credits_paid)
    SELECT id_student, ?
    FROM students
    WHERE student_qr = ?");
$insert_query->bind_param("is", $_POST['credits'], $_POST['studentqr']);
$insert_query->execute();

use Mike42\Escpos\Printer;
use Mike42\Escpos\EscposImage;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;

$nombre_impresora = "Termica";
$connector = new WindowsPrintConnector($nombre_impresora);
$printer = new Printer($connector);

$printer->setJustification(Printer::JUSTIFY_CENTER);

    $printer->setJustification(Printer::JUSTIFY_LEFT);
    $printer->text("Producto Galletas\n");
    $printer->text( "2  pieza    10.00 20.00   \n");

$printer->setJustification(Printer::JUSTIFY_CENTER);
$printer->text("Muchas gracias por su compra\n");

$printer->feed(3);

$printer->close();

$archivoActual = $_SERVER['PHP_SELF'];
header("refresh:2;url= + $archivoActual ");
mysqli_close($con);

?>

thanks a lot for your time


How to display 256MB of data in a user-acceptable time?

Question: Currently we have a buffer that is 256MB of data. Displaying all that at once is out the question since it will take a long, long time. I thought of dividing the 256MB in chuncks of 64MB each, then divided it in chunks of 8MB, this makes opening 8MB a lot faster or acceptable (2.4 minutes). The user interface should allow the user to select one block of data 64MB (256MB divide by 64MB), then it should allow the user to select one of the 8MB (64 MB divided by 8MB segments).
I thought of creating a rectangle with four squares each of them marked as 64MB, and below of it another rectangle with eight squares representing each 8MB. This will allows the user to select certain area of the data, but I'm not sure that this is the must acceptable presentation. Your feedback will be appreciated.
Comment: We may need to know a bit more about the circumstances: how will the user know which 64M-block is right for them? Is there a different measurement more appropriate for the domain (like time?)
Comment: "each of them marked as 64MB"?! Unless your users are **exceedingly** technical, it's best to hide the implementation details from them.
Comment: Our users are very technical, and they will view the 8MB buffer containing thousands of packets that are transmited from a port. They will use Wireshark to examine the packets and data looking for issues in protocols such as IP etc. The start/stop of TX packets is captured in a 256MB buffer. My idea was to have the user select the first 64MB, which will be parsed in chunks of 8MB for faster viewing, then have the user select the 8MB segment.
Comment: Sam, maybe it's just me, but I cannot digest more than 3-5 numbers at a time, let alone 8 or 256 Megabytes. Please consider explaining your use case and how you plan to present this much data to the user.
Comment: 256 / 8 = 32. Can you not just list the blocks in a table?
Answer: According to your description, what I got is that you want to represent the 64 MB of data in a proper format and that too in less size of 8MB's each.
One suggestion is that you can display the blocks of 64 MB's each (of total 256 MB). Let the blocks of 64 MB should be divided into 8 blocks of 8 MB each. (if possible). When the user will click on any 64 MB block, then all the 8 MB blocks are also displayed. After selecting the 64 MB block, user can select the smaller 8 MB block to view its detailed description.
Or you can give the facility to the user to hover over the 8 MB block to just view the contents.
This solution is according to one of the Norman's principle of good design : Interface should include good mappings that reveal the relationships between stages
Comment: Yes, that was the idea. This interface was going to set the select 64MB block, and the 8MB block segment with the same color as to show their selections. But is this a good way of doing it?
Comment: @Sam : Yes, you can use this idea and it is a good way. According to one of the Human Computer Interaction Principle please keep in mind that Users believe on : **Recognition rather than recall**. So if you display this according to your color conventions user may find it easy to use and recognize.
Answer: Your UX problem is a consequence of a technical problem, which is that the process of opening a buffer takes a long time.
If you stored the data in a properly indexed format, you would be able to quickly load only the data that is to be displayed on the screen at the moment.
(I'd recomment an embedded database engine like SQLite for this.)
Of course, converting the capture buffer into a database will also take a long time, but this needs to be done only once.
Comment: It may be a technical issue, but it's been posed on a UX site requesting User Experience solutions to this issue. Your answer of 'index the data properly' - while probably correct from a *technical* point of view - doesn't answer the question about how to deal with this issue that is happening from a *User Experience* perspective.
Comment: I agree with the answer and the cpmment. But I also believe that some UX problems _should_ be solved by solving the technical problem that is causing them - where the problem has a technical cause, ofcourse.


HTML5 & CSS media attributes media queries question

Question: I was wondering what does the operators and, only, not and the comma , do and mean when used with the media queries?
Are there any other operators that can be used with the media queries?
Answer: Please read the Media Queries Specification, it's only 1 page long. In summary though:

and means both things must match
, means one of the things must match
not means the query is true when it doesn't match
only is mentioned in the spec but I can't find a definition. I suspect it does nothing.
Comment: no, there's `min-` and `max-` variations on some keywords as well.  `all` is a reserved word as well (meaning all media types). Your answers are in the linked specification.
Comment: are these the only operators for media queries?


is there a way to set an array of dates all to the same Hour?

Question: I have an array of dates created from a date picker. When they are saved it also adds the hours and minutes. When I compare the dates to be equal some of them are an hour off because of daylight savings time.
Is there a way, after the date picker, to set each date to the same hour or do I have to go through the process of checking for daylight savings time and adding or subtraction an hour? Or should I run the array through a function to make them all equal?
func createDatePicker() {

    // format Display of date
    datePicker.datePickerMode = .date

    // assign datepicker to textfield
    dateTextField.inputView = datePicker

    // create toolbar
    let toolBar = UIToolbar()
    toolBar.sizeToFit()

    // add item Button
    let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action: #selector (doneClicked))
    toolBar.setItems([doneButton], animated: true)

    dateTextField.inputAccessoryView = toolBar

}

@objc func doneClicked() {

    //format the date display in text field
    let dateFormatter = DateFormatter()
    dateFormatter.dateStyle = .short
    dateFormatter.dateFormat = "MM-dd-yyyy"
    dateTextField.text = dateFormatter.string(from: datePicker.date)

    self.view.endEditing(true)

Answer: found a fix.
if let date = dateTextField.text {
     let dateFormatter = DateFormatter()
     dateFormatter.dateFormat = "MM-dd-yyyy"
     newDate = dateFormatter.date(from: date)!
     let tz = TimeZone.current
     if tz.isDaylightSavingTime(for: newDate) {
     print("date Changed")
     newDate += 3600

Comment: If you just need to check if two dates are on the same day you can use calendar method `func isDate(_ date1: Date, inSameDayAs date2: Date) -> Bool`


How to add items to xml programmatically ?

Question: I try to add item to xml contains items such as:
<item android:id="@+id/home3" android:title="Home" android:icon="@drawable/home"></item>
<item android:id="@+id/home3" android:title="Home2" android:icon="@drawable/home2"></item>
<item android:id="@+id/home3" android:title="Home3" android:icon="@drawable/home3"></item>

and I would like to add to this xml programmatically (dynamically).
Comment: You can't modify your *resources* at runtime. Besides not having access to the file, the `android:id` attributes are put as class members in the R. class at compile time.
Comment: Are you trying to modify resources at runtime?
Comment: Why would you want to do that
Comment: What? What are you trying to do? Do you really want to modify the **file**? Do you want to add new **items** automatically without having to type them? Or do you just want to add **menu items** (this looks like a menu to me) at runtime? Be clearer!
Comment: Yes I would like to modify resources at runtime
Comment: @mohammad rababah :- You want to add MENU ITEMS programmatically??
Comment: Not specifically add to or create resources programmatically...
Answer: Depends on what XML you're talking about. Couple things:

You can't add resources at runtime.
You can't change AndroidManifest at runtime.

However, I think the important part is why you'd want to do that. I'm guessing you're trying to build different APKs from the same codebase. And you can do that! Resources, the AndroidManifest, and even classes can be swapped out at build time!
The answer is product flavors. To implement them you need to do two things:

Add new resources to flavor specific directories in your project.
Add those flavors to your build.gradle file.

Step 1: Add Files To Swap
Here's an example application layout. There are other directories that I didn't include because they're not required to make my point:
├─ app
│  ├─ src
│  │  └─ main
│  │     ├─ java
│  │     │  └─ com/example/project
│  │     ├─ res
│  │     └─ AndroidManifest.xml
│  │  └─ productFlavor
│  │     ├─ java
│  │     │  └─ com/example/project
│  │     ├─ res
│  │     └─ AndroidManifest.xml
│  ├─ build.gradle

You don't have to include all directories in every flavor. And just as resources will "fall through" to the next best one if something doesn't exist, product flavors work the same way.
So, if I have a debug, or paid product flavor, I don't have to include different launcher icons if I want them to be the same. Only if I want them to be different.
Step 2: Define Product Flavors
Change you build.gradle to look something like this. You can override almost any option available in the defaultConfig--and probably more. I haven't pushed the limit:
android {
    defaultConfig {
        applicationId 'com.example.project'
        versionCode 4
        versionName '4.0'
    }
    productFlavors {
        project1 {
            applicationId 'com.example.project1'
            versionCode 1
            versionName '1.0'
        }
        project2 {
            applicationId 'com.example.project2'
            versionCode 2
            versionName '2.0'
        }
    }
}


Checkbox input triggering Bootstrap accordion collapse event

Question: Hello guys I'm using Bootstrap 5 accordion, the only problem I have is that the input checkbox is triggering the "collapse" event from the accordion, I tried to move the checkbox outside the range of the button from the accordion but that will look horrible.
I'm using Svelte, rendering each accordion with Each block with Data from the backend!
This is my code right now:

                    {#each objectives as objective}

                                <button
                                    class="accordion-button objectiveTitle collapsed"
                                    type="button"
                                    data-bs-toggle="collapse"
                                    data-bs-target={"#collapse" +
                                        objective.objectiveId}
                                    aria-expanded="false"
                                    aria-controls={"collapse" +
                                        objective.objectiveId}
                                >

                                        <input
                                            class="form-check-input"
                                            type="checkbox"

                                            value={objective.objectiveId}
                                            id="myCollapse"
                                            checked={objective.value}
                                            on:click={postObjective(
                                                objective.objectiveId,
                                                objective.value
                                            )}
                                        />

                                     {objective.title}
                                </button>

                                    {objective.description}

                    {/each}

The output of this code its
and this is the picture showing my problem after clicking on any checkbox:

I also tried to bind a bootstrap 5 function to the checkbox input but it didn't work
What can I do? Can you throw me any clue? Thank you!
Comment: Maybe you can remove the event listener from the checkbox?
Answer: I am not familiar with Bootstrap 5 as such, but a quick glance at your code shows this: <button on:click={postObjective(objective.objectiveId, objective.value )}>
This function is executed at render time and the return value added as the event listener for your on:click
The correct syntax would be <button on:click={() => postObjective(....)}>
As the code is now it probably does not do what you expect.
Edit:
In your case the input is also inside a button, clicking the input will therefore also click the button. To stop this from happening you have to prevent the event from bubbling up, Svelte has a handy helper for that: <button on:click|stopPropagation={() => postObjective(....)}>
Comment: that would be because when you click the input you also click the input, you have to stop it from bubbling up: `on:click|stopPropagation={() => ....}`
Comment: Hmmm... that did´nt work but i think its because the ``` on:click ``` its inside an input inside an button. It works well when i put my input outside the button but breaks the accordion.
Comment: Awesome, that did the work! Im gonna check more about stopPropagation(). Thank you very much


how to code an ip tracer program in c?

Question: i would like to code an ip tracer program in c , but i am not able to get a head start in it . Any e book , links or sample code would be of much needed help !!
Comment: Do you mean some utility like traceroute ?
Answer: Lots of examples on this site for how to implement this sort of thing in c
Answer: you will send icmp (ping) to the address, each time you extend the ttl (time to live) by 1 - and that's how you get the trace.
here some library that helps you use ping in c#
http://www.mentalis.org/soft/class.qpx?id=4
Comment: if you want to get the names of the ip's on the way.. you should use other libraries to make rdns calls...

how to code an ip tracer program in c?


Ubuntu 15.10 - no login screen after installing/removing packages

Question: I have tried to install package libepoxy0:i386 (I thought this can solve an error in one of application, nevermind).
I saw the question: Do you want to continue?, I hit Y, and then... When progress was ~22% I saw that earlier in console there was an information:
The following packages were automatically installed and are no longer required

with long list of packages... I remember that there was Firefox on this list and some packages with name containing unity or gnome. Then I stopped this operation and restarted Ubuntu, but now... I see only screen with Ubuntu logo and 5 flashing dots.
I tried to press Ctrl+Alt+F1 and use the console, but then there is no login question.
I saved the output from the console (after I stopped removing/installing package) to the file and I'd like to paste it here (maybe could be helpful), but I saved it on a disk before restart and I don't even know how to open it, because I cannot run Ubuntu.
Can I do something different than reinstalling Ubuntu?
Comment: try turning off your computer then when you turn it back on immediately hold down the shift key. hopefully this will get you into the grub screen . .choose advanced options and then choose recovery mode.. in there there is an option for dpkg to fix broken packages .. try that and see if that helps
Answer: Use the live boot mode from an installation disk or USB flash drive.  then mount the root partition and block devices.  thereafter, chroot to the mounted location and you can run apt-get install ubuntu-desktop and other missing packages.
if you have lvm volumes instead of plain old partitions (this isn't necessary on newer Ubuntu distributions. I think 14.04+):
apt-get install lvm2
vgchange -a y

Mount the Ubuntu root partition (lvm partitions are under /dev/mapper, otherwise they are /dev/sda[1-9])
mkdir /mnt/system
mount /dev/mapper/ubuntu--vg-root /mnt/system
mount /dev/sda1 /mnt/system/boot
for i in /dev/pts /dev /proc /sys; do mount -B $i /mnt/system$i; done
chroot /mnt/system

first, make sure dependencies and broken packages are fixed:
apt-get -f install

Try to figure out what is missing or corrupt and (re)install it.
apt-get install ubuntu-desktop
apt-get install linux-image-generic linux-headers-generic


Code smells reporting/tracking tool

Question: I was wondering if you know any tools that help keep track of "code smells". So that team members could report some finding in the code and then possibly vote on the most problematic ones (in terms of future project development).
Any experiences?
Answer: Have you looked at find bugs or check style?  Both of these are pretty good for this.
I would also recommend pmd.  These let you analyse common problems such as not setting method parameters final.
Lastly, I'd recommend using Sonar as this will highlight any code errors in order of priority.  Such as code that is knowingly going to through a NPE, it will highlight this to you and can be integrated with Jenkins.
All these together can really help you move towards the "Clean Code" mantra.
Comment: These tools seem to focus on automatic detection of code smells. Whereas I am interested in more manual approach where team members are actually reporting only what drives them mad.
Comment: In that case, you could write your own rules in check style or PMD.  I've done something similar as I always got sick of people using duplicate GUIDs so I've started writing my own rule for duplicate GUID strings.  You could then integrate these rules into Sonar so they fire automatically.
Comment: Still, this approach would assume that I can formalize code smell in terms of rules. I don't want it. I would prefer to consider each case separately and let developer decide whether a part of code needs to be refactored.

Then Jira or Bugzilla would be fine. However these are "general purpose" tools. I hoped there are some tools dedicated to keep track of parts of code (with some enhancements like code context information, class collaborators, usage etc.).

Code smells reporting/tracking tool


In the steam summer sale 2017 once you change the sticker layout, can you change it back to normal?

Question: In the steam summer sale 2017 once you change the sticker layout, can you change it back to normal?
Answer: I assume you ask how to restore the original position of the stickers on their page. You can go back to the original layout by removing the stickers and reapplying them.


Black screen and later garbled screen after installation 14.04, where should I begin?

Question: Just a foreword, this is my first foray into anything Linux related. Please forgive me if my lingo isn't up to par.
I just installed Ubuntu 14.04 last night. After I removed the installation disk (when I was prompted to do such) and restarted, the computer started up and I was eventually prompted to put in my passphrase. After that was successfully accepted, the screen went black but my cursor still showed up and I was able to move it around. I tried ctrl+alt+del but to no avail. A few minutes of just the screen led to:
[121.855415] nouveau E[    DRM] GPU lockup - switch to software fbcon

[142.180021] nouveau E[Xorg[1254]] failed to idle channel 0xcccc0001 [Xorg[1254]]

With that second line repeating but with different numbers in the brackets. So I looked around for people in similar situations and found that most people went to GRUB and added
"nomodeset" after quiet splash. However, I couldn't figure out how to deal with the $vt_handoff that was present right after "quiet splash" in GRUB. So, I just stuck nomodeset after $vt_handoff and hit ctrl+X.
After the encryption prompt working successfully (as it has every time), I was actually brought to the desktop screen. I thought I had fixed the situation when a problem report window popped up asking me to support the bug report and the screen went fuzzy. It made it difficult for me to document what the bug report contained but I was able to make some stuff out:
Executable path

  /usr/bin/Xorg

Package

  Xserver-xorg-Core 2: 1.15.1-0ubuntu2

ProblemType

  Crash

Title

  Xorg crashed with SIGABRT

Apport Version

  2.14.1-0ubuntu3.2

Architecture

  Amd64

At this point, it was difficult to discern what was in the report. Moving the cursor around somehow caused the screen to look better for a bit but scrolling down through report made things difficult again.
I restarted again after that to see that I'm back to a black screen with the cursor which leads me to believe that "nomodeset" did not stick and I'll have to reapply it.
The computer with the problems is a Dell Dimension E521 with BIOS 1.1.11. I did the 64-Bit install from a Live Disc while using Windows XP.
Does anybody have an idea what to do? If you guys needs more info on the computer, I'll get is ASAP. Thank you.
Comment: Please provide the output of `lspci | grep VGA`. Also while running in the Live CD you saw any of those problems?
Comment: Oh and check that your system is updated running `sudo apt-get update && sudo apt-get dist-upgrade`
Answer: To make nomodeset permanent edit the file /etc/default/grub using one of those:

Alt+F2 and then write gksu gedit /etc/default/grub
In a terminal sudo gedit /etc/default/grub

change GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" to GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset" and finally run sudo update-grub2 (this will regenerate the grub entries).
Regarding the bug report window, if it gets annoying you can disable it using one of the methods above to edit /etc/default/apport and changing enabled to 0.
Comment: Okay, so I did most everything you asked to.

First off, I didn't see anything weird happen during the install. Nothing weird happened until booted for the first time (i.e. taking the disc out and taking out the Live CD).

lspci | grep VGA gave me:
03:00.0 VGA compatible controller: NVIDIA Corporation G72 [GeForce 7300 LE] (rev a1)

I did the updates as well.

I changed the file permanently in /etc/default/grub and the black screen and cursor is no longer a problem.

But touching the left side of the screen with the cursor causes the screen to become garbled again.
Comment: Are you using some driver for that card? (Search for "Additional drivers" in the dash). [This answer of a similar question](http://askubuntu.com/a/455982/33871) says installing nvidia current helps (in your case it seems you are using Nouveau)
Comment: Yeah, I found three other drivers in Additional drivers and used one of them and now my screen isn't going crazy. The Ubuntu logo when I log in isn't shiny like it used to be, but, really, it's a small price to pay. Thanks for all your help!


Installed Kubuntu in external SSD and now I can't load Windows without it

Question: I have a computer running Windows 10. Because I wanted to use an Ubuntu based OS, I installed Kubuntu on an external SSD. I have a Lenovo y50-70 laptop, which has a button (next to the power button) that allows one to select which hard drive to boot without going directly to the internal hard drive. In the past I had done this and had no problems. However this time something went wrong.
If I have the hard drive connected to my computer when powering it up, I get the GRUB menu that allows me to select which OS I want to use. When I do not have it connected, I get the following message:
<code>error: no such device: 43519df1-eaa6-4ae44-74b9d66931ff.
error: unknown filesystem.
Entering rescue mode...
grub rescue> _
</code>
What I wanted (and what I was able to do in the past) is that when I normally boot my machine (regardless if I have the hard drive connected or not) that it will boot my Windows. When I want to use Kubuntu, I need to use the special "Boot menu" (by pressing the button next to the power up button) while having the device connected.
For some reason GRUB became the default booting system and I don't know how to make the system go directly to the Windows loader. For me to enter Windows now, I need to have my SSD connected as to allow GRUB to be found. How can I fix this?

I don't think this is a duplicate of the question Is it possible to boot Ubuntu using the Windows bootloader? because this is not a normal dual-boot. My Kubuntu is installed on an external drive and during the process the Windows bootloader was replaced. Now I can't boot Windows (which is inside the laptop's hard drive) without having the external one connected. That being said, they have same similarities which could be argued to be enough for this questions to be a duplicate.
Comment: Possible duplicate of [Can't boot without Flash Drive plugged in](https://askubuntu.com/questions/125494/cant-boot-without-flash-drive-plugged-in) and [Unable to boot into Windows after installing Ubuntu, how to fix?](https://askubuntu.com/questions/217904/)
Comment: Reboot your machine and press `del` key and reach `BIOS Setup` screen. Now observe how many bootloaders are there. Please list them.
Comment: I suggest you read https://en.wikipedia.org/wiki/Power-on_self-test , https://en.wikipedia.org/wiki/BIOS , https://en.wikipedia.org/wiki/Master_boot_record , https://en.wikipedia.org/wiki/GUID_Partition_Table , https://en.wikipedia.org/wiki/UEFI . One will have the Answer. Read the others to understand that one.
Answer: So the answer was similar to that proposed by Romeo Ninov. I installed EasyBCD, went to the tab BCD Deployment and clicked Write MBR. All of this while not having connected my external SSD to my computer. Now it is properly working.
Here is a picture showing what I did:
Comment: Since an older BIOS/MBR system, you just needed to use Something Else install option and install grub to external drive. Then you would not have overwritten the Windows MBR in the internal drive. Then set BIOS to default boot external. If not plugged in, then BIOS will go to second choice & boot internal. With grub in the Internal drive you had to have external drive to boot at all. You also could have used Boot-Repair to install new BIOS boot loaders to each drive.


How to run ansible task with multiple array variables?

Question: There is host_vars/my_host.yml file which include array variables:
<code>---
my_array_variable_1: '"arr1_el1" "arr1_el2"'
my_array_variable_2: '"arr2_el1"
my_array_variable_3: '"file1" "file2"'
</code>
There is task main.yml that doesn't work as I suppose:

<code>- name: my task.
  shell: |
    echo "{{ my_array_variable_1[] }} {{ my_array_variable_2[] }}" >>/home/user/{{ my_array_variable_3[] }}
</code>
1) How can I get this result:
<code># cat /home/user/file1
arr1_el1
arr2_el1
# cat /home/user/file2
arr1_el2
arr2_el1
</code>
2) How can I get this result:
<code># cat /home/user/file1
arr1_el1
arr1_el2
arr2_el1
# cat /home/user/file2
arr1_el1
arr1_el2
arr2_el1
</code>
3) How can I get this result:
<code># cat /home/user/file1
arr1_el1
arr2_el1
# cat /home/user/file2
arr1_el2
</code>
I'm searching, but can't find clear example neither ansible official docs nor via search engines.
Please help with result or get url to revelant documentation or example.
Regards
UPD: Find that I need to use dictionary and "with_dict" to create Associative array like this
How should I write task to get all elements like at mine result 2 or particular values like at result 3
UPD2: I've found example at ansible docs how to work with dicts but how to include it to host_vars file? I get the error below:
<code>An unhandled exception occurred while running the lookup plugin 'dict'
</code>
Answer: I just use dict module. This allows forming arrays of any complexity through dictionaries.
Comment: Please, fix the link.
Comment: sorry for delay)


WP8 platform on Cordova cannot run: CordovaBrowser_NavigationFailed

Question: I already built the same application on iOS and Android, but now I'm trying to build it for Windows Phone 8. The problem is that when I attempt to run it on the emulator I get this error:
CordovaBrowser_NavigationFailed :: www/www/index.html
And the application doesn't run, it only displays a black screen.
I already updated Cordova to 5.0.0, and recreated the platform trice, but I still get the same error.
These are steps to reproduce the error:

cordova platform add wp8
open the VS Solution project project.sln
run as Emulator 720p (or any one, I already tried everyone)

Or just run: cordova emulate wp8 and the emulator shows the splash-screen and then the black screen.
I'm on Windows 8 Enterprise and using Visual Studio Ultimate 2013 v12.0.31101.00 Update 4.
Answer: Cordova 5.0.0 hasn't been tested on VS 2013 Update 4. If you want to use 5.0, you should download VS 2015 RC and refer to Known Issues section for Cordova 5.0 . Thanks.
Comment: I have the same problem with VS 2015. Any help?
Comment: Same issue with VS 2015 and cordova 6.3.1


Evaluate string in javascript without eval

Question: I have some variables
var a = true;
var b = false;
var c = true;

and an array
var array = ['a', 'b', 'c'];

How is it possible to evaluate the elements to their corresponding truth value?
I know I can use eval(), but since it is considered harmful, are there any other options?
In some cases I will rather have the 'truth' assignment as
var truth = {'a': true, 'b': false, 'c': true};

and it seems, eval() doesn't take another option (e.g. eval('a+b', {a: 1, b: 3}) = 4)
Comment: Are you aware of bracket notation, such as `window['a'] == true` if `a` is a global variable?
Comment: Don't refer to variables using strings. Why do you need to do that? The variables whose names are given by the elements already have values--why do you need to "evaluate" them? Your final example can be handled easily as a function, written `add(({a, b}) => a+b)({a: 1, b: 3})`.
Comment: Let's be clear though... `eval` is a tool, just one generally used for evil.  It can be used fine and properly if used carefully and sparingly.  I'd never ship any library code with it, but I'd also probably never run into whatever craziness you appear to try to be doing.  : )  Really, your problem most likely lies in how you're trying to attack it in the first place, not in some magical need for an eval-like construct.
Comment: you can use this script to make eval safe, and optionally white-list globals for the code: http://danml.com/js/subeval.js
Answer: While this doesn't answer your question, it should do what you need to do.
Rather than making those variables, you can make them properties of a local object -- then use them.
var obj = {
   a: true,
   b: false,
   c: true
};

var array = ['a', 'b', 'c'];

array.forEach(function(val) {
  console.log("Value ", val, "is ", obj[val]);
});

Because of how things are named, you could also access
obj.a = false;

or
obj["b"] = true;

Comment: Exactly what I need. Thanks
Answer: Javascript unfortunately only provides eval that works with scopes that are out of the control of the programmer (in Python instead you can provide what should be the global and the local environment).
To achieve what you want to do the solution is implementing your own language. It may seem a huge thing but indeed it may be doable and even reasonable depending on what you need it for.
If that is needed just for configuration normally the solution in the Javascript world is to use a single JSON object, giving up with the possibility of having small helper functions or conditionals in the configuration itself.
Answer: If your variables are global, you can use window or this (when this points to the window object).

var a = true;
var b = false;
var c = true;
var array = ['a', 'b', 'c'];
for(var i = 0; i < array.length; i++){
  console.log(this[array[i]]);
}
Comment: Just to make it more clear to OP, global variables in javascript are keys of `window` object.


Querystring on Routes in angular

Question: I would like to configure my routes to be able to accept any integer after its' URL.
For example,
<code>/product/id/1242
</code>
This integer will be accessed by the API factory as a value to be queried by the API.
I have read doc's on setting up routes, but haven't been able to do to it. If i enter a URL with an integer, it just redirects to the login page.
<code>angular.module('myapp123.routes', [])

.config(['$stateProvider', '$urlRouterProvider',
    function($stateProvider, $urlRouterProvider) {

        $urlRouterProvider.otherwise("/login");
        //$location.path('/product').search('queryStringKey', value).search( ...);
        $stateProvider

            .state('login', {
                url: '/login',
                views: {
                    'menuContent': {
                        templateUrl: 'app/core/login/login.html'
                    }
                },
                controller: function ($ionicHistory, $scope) {
                    console.log('Clearing history!');
                    $ionicHistory.nextViewOptions({
                        historyRoot: true,
                        disableBack: true
                    });
                }

            })

            .state('product', {
                url: '/product',
                when:('/product/id/product_id')
                views: {
                    'menuContent': {
                        templateUrl: 'app/components/product/product.html'
                    }
                }

            })
</code>
Answer: According to the docs This should do the trick. [0-9] limits the product Id to numbers.
<code>.state('product', {
                url: '/product/id/{productId:[0-9]}',
                views: {
                    'menuContent': {
                        templateUrl: 'app/components/product/product.html'
                    }
                }
</code>
Answer: Thanks- wasn't able to get your version working for some reason.
A work-around I've found, which works:
<code>        .state('product', {
        url: '/product/id/:product_id',
        templateUrl: 'app/components/product/product.html',
        controller: function($scope, $stateParams) {
            $scope.product_id = $stateParams.product_id;
        }
    })
</code>

Querystring on Routes in angular


Need assistance with CSS - aligning data without tables

Question: I am trying to learn CSS, especially I am trying to get away from tables, which are so easy to use.
I created jsfiddle to see what I have done:
http://jsfiddle.net/HMtSY/
I can't align all data into proportional cells. Please assist

    Product
    Model Price
    Qty

    This is the product title
    mdsdre12es
    9.95 1

    Product 2
    mds12es
    1119.95 199

    This is the product title product 100000
    as 9.95
    22221

//CSS
.cartItem
{
    display: table-cell;
    padding: 5px;
    width: 600px;
    min-width: 600px;
    float:left ;
}
.cartProductTitle
{
    display: table-cell;
    padding: 5px;
    width: 350px;
    min-width: 350px;
}
.cartProductModel
{
    display: table-cell;
    padding: 5px;
    width: 150px;
    min-width: 150px;
}
.cartProductPrice
{
    display: table-cell;
    padding: 5px;
    width: 30px;
    min-width: 30px;
}
.cartProductQty
{
    display: table-cell;
    padding: 5px;
    width: 30px;
    min-width: 30px;
}

Comment: If it's tabular data you're displaying, please use a table
Answer: Not all tables are evil!
Tables for layout are, but this isn't tables for layout, you're displaying tabular data, as in, data which should be displayed with a table!
This means that using a table in your case is perfectly acceptable, and even the correct solution.
So yes, use a table in this case. It's not layout, so it's fine :)
Answer: You are creating problems rather than solving them, since an HTML table is the right approach here, but if someone insists, it is possible to simulate HTML tables in CSS (and this might even be meaningful if your data format is generic XML and not HTML). You just need to specify display: table-row for elements that structurally correspond to table rows, like .cartItem elements in your case. (It would also be natural to wrap all such elements in a container, for which you set display: table.)
So just set .cartitem { display: table-row } and remove the float settings. It is natural to remove all the width settings, letting browsers determine the widths of columns, which is one of the basic advantages of using tables (in HTML or as emulated in CSS). Moreover, the last two cells of each row should be right-aligned, as they contain numeric data.
See jsfiddle.


Pseudo-Nilpotency Question:

Question: Theorem: Let $V$ be a vector space over $\mathbb{C}$, and let $A: V \to V$ be a linear map. Let $P(t) $ be a polynomial such that P(A) = O, and let
$$P(t) = (t - \alpha_1)^{m_1}....(t-\alpha_n)^{m_r}$$
be its factorzation, the $\alpha_1, \alpha_2, .... , \alpha_r$ being the distinct roots. Let $W_i$ be the kernel of $(A - \alpha_i I)^{m_i}$. Then $V$ is the direct sum of the subspaces $W_1, ... , W_r$.
The author of my textbook (Serge Lang, Linear Algebra UTM) states that the following claim follows from the above theorem.
Claim: Let $V \neq \lbrace O \rbrace $ be a finite-dimensional complex vector space. Let $A: V \to V$ be a linear map. Then there exists a number $\alpha$ and an integer $r\geq1 $ such that $(A - \alpha I)^r = O$.
My problem is that I don't see how.
Comment: That's certainly not true without more hypotheses.
Comment: How do you know?
Answer: I just realized that Qiaochu is correct.
Consider the matrix $A = \begin{bmatrix}1 & 0\\0 & 0\end{bmatrix}$. Assume that $(A - \alpha I)^r = 0$. Then:  $${\begin{bmatrix}1-\alpha & 0\\0 & -\alpha\end{bmatrix}}^r=\begin{bmatrix}(1-\alpha)^r & 0\\0 & (-1)^r \alpha\end{bmatrix}=0$$, necessitating that $\alpha = 0$. However $(1-(0))^r = 1^r = 1$, contradicting our assumption that $(A - \alpha I)^r = 0$. Therefore no such $\alpha$ and $r$ exist for this matrix, invalidating the claim.

Pseudo-Nilpotency Question:


does EXP, PG and JP rewards change with a Ba'al's Level?

Question: So i defeated Ba'al iv Goldie which came to me at Level 18 but i reduced it level down to 1 to find out if it had any quirks like the other Ba'als i defeated.
with only 1,000 HP against a party of Level 30's it was a quick battle but i was surprised to find that i scored over 200 JP as a reward (EXP and PG i wasn't too concerned).
So i am wondering if all Ba'al's will reward me the same EXP, PG and JP regardless of what level i reduce them down to with my ship?
Comment: I fixed the answer after completing my data gathering, so I hope the information is useful for you.
Answer: The short answer: Yes, the Maximum Ba'al level does affect PG, EXP, or JP earned, while the current level does not. This means a level 30 Ba'al gives more exp than a level 25 Ba'al, but reducing their level to 1 does not change the reward of those 2 Ba'als.  Also different Ba'als give different rewards, just like monsters.
Chompillionaire Ba'als are all around 10000 PG, 143 EXP, and 12 JP and have such a low HP, don't waste your time firing your ships at one. A level 30 Chomp Ba'al has just under 600 hp, and the reason for killing them is PG.
I have tested between levels 1-5 and they all ended up with the same amount, so the current/reduced Ba'al level does not affect the rewards (this is testing with similar level Ba'als).
To give an idea, I will give a few Ba'als that I have fought that were all reduced to level 1.
27@1 means they started at level 27 and were reduced to level 1.
Firstborn
27@1: 3091 PG, 5081 EXP, 301 JP
30@1: 3275 PG, 5494 EXP, 330 JP
34@1: 3520 PG, 6045 EXP, 369 JP
Turtledove
24@1: 1938 PG, 3112 EXP, 272 JP
25@1: 1979 PG, 3204 EXP, 282 JP
Ba'al vi; Snowcap
60@1: 3408 PG, 6418 EXP, 621 JP
Neo Snowcap
34@1: 4030 PG, 7397 EXP, 369 JP
I can add more if it makes everyone feel better about the data, but essentially the only thing that affects the rewards are the Maximum Ba'al level (or the level it started on) and the Ba'al you fight.


Rank corresponding to next available date from another dataframe

Question: Can someone help me with the below requirement?
DF1:
 Item       Day            Rank
  A     2020-01-12
  A     2020-01-13
  B     2020-01-13

DF2:
  Item        Day            Rank
   A       2020-01-10         1
   A       2020-01-11         2
   A       2020-01-14         3
   B       2020-01-14         4
   B       2020-01-17         5

If we have Day in DF1 which is not present in DF2, then I want to fetch the rank for DF1 date from the next date corresponding to the date in DF2.
Here 2020-01-12 in DF1 doesn't have any rank so it should search from DF2 for the next date which is 2020-01-13 & the corresponding rank should be coming as output.
Final Output(DF1):
 Item       Day            Rank
  A     2020-01-12          3
  A     2020-01-13          3
  B     2020-01-13          4

Answer: Here is a base R solution (assuming your column Day in both DF1 and DF2 are already of class Date)
DF1 <- do.call(rbind,
               c(make.row.names = F,
                 lapply(split(DF1,DF1$Item), function(v) {
                   z <- subset(DF2,Item == unique(v$Item))
                   v <- within(v, Rank <- findInterval(Day, z$Day)+ min(z$Rank))
                   }
                   )
                 )
               )

such that
> DF1
  Item        Day Rank
1    A 2020-01-12    3
2    A 2020-01-13    3
3    B 2020-01-13    4

DATA
DF1 <- structure(list(Item = c("A", "A", "B"), Day = structure(c(18273,
18274, 18274), class = "Date"), Rank = c(NA, NA, NA)), row.names = c(NA,
-3L), class = "data.frame")

DF2 <- structure(list(Item = c("A", "A", "A", "B", "B"), Day = structure(c(18271,
18272, 18275, 18275, 18278), class = "Date"), Rank = 1:5), row.names = c(NA,
-5L), class = "data.frame")

Comment: @ThomaslsCoding - I have multiple rows in the DF1 then correspondingly I want to find the rank from DF2 based on next available Day
Comment: There is slight change in the requirement. Need a logic for the day with respect to each Item. Can you please help in identifying the logic for the same
Answer: We can use fuzzy_join
library(dplyr)
fuzzyjoin::fuzzy_left_join(df1, df2, by = c("Item" = "Item", "Day" = "Day"),
           match_fun = list(`==`, `<=`)) %>%
   group_by(Item.x, Day.x) %>%
   slice(1L) %>%
   mutate(Rank.x = coalesce(as.integer(Rank.x), Rank.y)) %>%
   select(-ends_with("y")) %>%
   rename_all(~names(df1))

#  Item       Day         Rank
#  <fct>     <date>     <int>
#1   A     2020-01-12     3
#2   A     2020-01-13     3
#3   B     2020-01-13     4

Comment: If we increment the Day value by 1 then that Day is also not present. Let's assume in DF2 day 2020-01-12 & 2020-01-13 both are not present then day 2020-01-14 rank should be considered
Comment: There is slight change in the requirement. Need a logic for the day with respect to each Item. Can you please help in identifying the logic for the same
Comment: Thanks Ronak but it is taking quite a lot of time for just 32k rows
Answer: You can use findInterval like:
DF1$Rank <- DF2$Rank[findInterval(DF1$Day, c(0,DF2$Day), left.open = TRUE)]
DF1
#         Day Rank
#1 2020-01-12    3
#2 2020-01-15    5

In case DF2 is not sorted:
i <- order(DF2$Day)
j <- findInterval(DF1$Day, c(0,DF2$Day[i]), left.open = TRUE)
DF1$Rank <- DF2$Rank[i[j]]

Or in case DF2$Rank is 1:nrow(DF2) and DF2 is sorted.
DF1$Rank <- findInterval(DF1$Day, c(0,DF2$Day), left.open = TRUE)

Data:
DF1 <- data.frame(Day=as.Date(c("2020-01-12", "2020-01-15")), Rank=NA)
DF2 <- data.frame(Day=as.Date(c("2020-01-10", "2020-01-11", "2020-01-13"
  , "2020-01-14", "2020-01-17")), Rank=1:5)

For the updated Question:
DF1 <- data.frame(Item=c("A","A","B"), Day=as.Date(c("2020-01-12", "2020-01-13", "2020-01-13")), Rank=NA)
DF2 <- data.frame(Item=c(rep("A",3),rep("B",2)), Day=as.Date(c("2020-01-10", "2020-01-11", "2020-01-14", "2020-01-14", "2020-01-17")), Rank=1:5)

DF1$Rank <- unlist(sapply(unique(DF1$Item), function(i) {DF2$Rank[DF2$Item==i][findInterval(DF1$Day[DF1$Item==i], c(0,DF2$Day[DF2$Item==i]), left.open = TRUE)]}))
DF1
#  Item        Day Rank
#1    A 2020-01-12    3
#2    A 2020-01-13    3
#3    B 2020-01-13    4

Have also a look at Join one data frame to another by membership in a range
Comment: Need a logic for the day with respect to each Item. Can you please help in identifying the logic for the same.
Comment: @AnshulSaravgi Can you clarify if `DF2` is *sorted* or not and if `DF2$Rank` is simply `1:nrow(DF2)` or not?
Comment: DF2 = as.data.frame(DF2 %>% group_by(Item) %>%
                              mutate(rank = rank(Day)) %>%
                              arrange(Day))


Stop meta key activating host desktop in remote sessions

Question: recent windows convert, so apologies if I'm not across a lot of the terminology.
I'm using Kubuntu 19.04 on my laptop, which is a mix of personal and work use.
When at work, most of my job is done in remote desktop sessions (RDC) on Windows servers.
Currently I'm using KRDC as my remote session client, but today I noticed the same problem working on a local QEMU/Virt-Manager VM.
When I am full screened in a remote session, and I press the Meta key (or windows key) in order to open the start menu on the remote session, the key press is being grabbed by my laptop OS. This results in the application launcher opening in Plasma, which pulls the session out of full screen. The key press is also being passed to the remote session, as the remote windows start menu will also open.
THis is obviously extremely disruptive, as it affects all meta+ shortcuts, such as opening the run command or explorer.
How can I prevent my laptop OS from intercepting and acting on the meta key presses when I am full screen in a remote session?
I'm not even sure where to start looking for answers, whether it's application specific or a global keyboard setting. I'm also having trouble phrasing the problem in order to search.
Thank you for any help.
Answer: Setup your Apllication Launcher to open up when you press Alt + F1
Setup Application Launcher Shortcut
Edit ~/.config/kwinrc with your prefered text editor and find the line:
[ModifierOnlyShortcuts]

If you use the default Dock edit it to:
[ModifierOnlyShortcuts]
Meta=

If you use Latte Dock edit it to:
[ModifierOnlyShortcuts]
Meta=org.kde.lattedock,/Latte,org.kde.LatteDock,

Then restart kwin with kwin_x11 --replace & disown
This is only a workaround because now you always have to use Alt + F1 to upen the Application Launcher.


Remove focus from editText in dialog when keyboard is down

Question: I have an AlertDialog with an edit text in it. When you hit the back key, the keyboard goes down (as it should), but the edit text is still with focus. If you hit the back key again, the whole dialog disappears.
I want to remove the focus from the edit text inside the dialog upon hiding the keyboard, but can't figure out how to.
Note that I don't want to override the onBackPressed or something similar, because I just want to control what happens when the back button is pressed when the dialog is up.
Any ideas?
Answer: The solution to my problem was partially as @kabuto178 said - I used a focusable frameLayout as the parent of my EditText, and then when called the edittext.clearFocus() upon hitting the back key, the parent frameLayout gained the focus:
final FrameLayout parent = new FrameLayout(context);
final EditText v = new EditText(context);
parent.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.WRAP_CONTENT));
parent.addView(v);
parent.setFocusableInTouchMode(true);
v.requestFocus();

Answer: Well the EditText widget has a method that can be used edittext.clearFocus(); sets the focus back to the first focusable view in the activity, but if you have only one view in the activity then there will be no other view to shift the focus to or you can manually set focus to another view in the layout which will remove the cursor. To get control of focus on the backpressed you have to override the onBackPressed() as I know it.


c++ linux compile error: undefined reference to `main'

Question: I have looked for this error and tried a few of the solutions, but have not found anything, at this point I would just like to compile it.
The error I am getting is:
/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crt1.o: In function `_start':
/build/buildd/eglibc-2.10.1/csu/../sysdeps/i386/elf/start.S:115: undefined reference to `main'

using:
g++ -lglut Solar.cpp

the code is here:
using namespace std;
#include <stdio.h>
#include <GL/glut.h>
#include "math.h"

class Solar {

  int main(){
    initializeGL();
    //Stars Alpha = new Stars(5.0);
    //Stars *Alpha = new Stars(5.0);
    //Planets *Awe = new Planets(.6,2,30,"Awe",0.0,0.0,0.0);
    paintGL();
    return 0;
  }

  vid initializeGL(){
      glShadeModel(GL_SMOOTH);

      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
      glClearDepth(1.0f);

      glEnable(GL_DEPTH_TEST);
      glDepthFunc(GL_LEQUAL);

      glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

      // lighting stuff
      GLfloat ambient[] = {0.0, 0.0, 0.0, 1.0};
      GLfloat diffuse[] = {0.9, 0.9, 0.9, 1.0};
      GLfloat specular[] = {0.4, 0.4, 0.4, 1.0};
      GLfloat position0[] = {1.0, 1.0, 1.0, 0.0};
      glLightfv( GL_LIGHT0, GL_POSITION, position0 );
      glLightfv( GL_LIGHT0, GL_AMBIENT, ambient );
      glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuse );
      glLightfv( GL_LIGHT0, GL_SPECULAR, specular );
      GLfloat position1[] = {-1.0, -1.0, -1.0, 0.0};
      glLightfv( GL_LIGHT1, GL_POSITION, position1 );
      glLightfv( GL_LIGHT1, GL_AMBIENT, ambient );
      glLightfv( GL_LIGHT1, GL_DIFFUSE, diffuse );
      glLightfv( GL_LIGHT1, GL_SPECULAR, specular );

      glEnable( GL_LIGHTING );
      glEnable( GL_LIGHT0 );
      glEnable( GL_LIGHT1 );
      glEnable( GL_COLOR_MATERIAL );

      /* Draws the Grid*/
      drawRGrid();
  }

  void resizeGL( int width, int height ){
    height = height?height:1;

    glViewport( 0, 0, (GLint)width, (GLint)height );

    // update projection matrix
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,.10f,200.0f);

    // modeview matrix is simply identity
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
  }

  void paintGL(){

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    //set camera position using gluLookAt
    glLoadIdentity();
    gluLookAt(0.0f,0.0f,0.0f,0.0f,0.0f,-200.0f,0.0f,1.0f,0.0f);

  }

  void doCircle(double x, double y, double radius){
    glEnable(GL_BLEND);
    double y1=y+radius;
    double x1=x;
    glBegin(GL_LINE_STRIP);
    for(double angle=0.0f;angle<=(2.0f*3.14159);angle+=0.01f){
      double x2=x+(radius*(float)sin((double)angle));
      double y2=y+(radius*(float)cos((double)angle));
      glColor3f(1.0,1.0,1.0); //White
      glVertex2d(x1,y1);
      y1=y2;
      x1=x2;
    }
    glEnd();
    glDisable(GL_BLEND);
  }

  void drawRGrid(){
    float xCirc = 0;
    float yCirc = 0;
    int numCircles = 5;
    int threesixty = 360;
    int numLines = 20;

    //draws my circles
    for (int i=0; i < numCircles;i++ ){
      doCircle(1.0,1.0,i);
    }

    //draws my lines
    for (int j=0; j < threesixty / numLines;j+= numLines){
      // multiply by numCircles to get to extend to
      // that length
      drawLines(sin(j)*numCircles,sin(j)*numCircles);
    }

  }

  void drawLines(float xCirc, float yCirc){
    glBegin(GL_LINES);
    glVertex2f(0,0);
    glVertex2f(xCirc,yCirc);
    glEnd();
  }

};

Any help will be great appreciated!
Comment: Duplicate of [What is the proper declaration of main?](http://stackoverflow.com/questions/4207134/what-is-the-proper-declaration-of-main) (It wasn't a duplicate at the time it was asked, but the FAQ question has been updated to cover the answer to this question.)
Answer: You have declared main() as a member function.
The main() function called when the application starts up needs to be a non-member function in the global namespace.
A good introductory C++ book would explain this.
Comment: my java comes through, ok, thank you very much for the link as well.
Comment: @Jim:  That's why you should get a good introductory C++ book.
Answer: You declared main in class Solar. main is supposed to be a free function, i.e. not contained within a class.
Answer: main cannot be found because the function you wrote is called Solar::main (in truth, it has a much funnier name). You need to move it below class Solar. Then you probably want to change class Solar into struct Solar until you introduce member variables. At last, you may want to rewrite main to be
extern "C" int main (int /* argc */, char *const * /* argv */) {
    Solar solar;
    solar.initializeGL();
    //Stars Alpha = new Stars(5.0);
    //Stars *Alpha = new Stars(5.0);
    //Planets *Awe = new Planets(.6,2,30,"Awe",0.0,0.0,0.0);
    solar.paintGL();
    return 0;
}

Comment: Why should the OP prefer to use `struct` if there are no member variables?
Comment: It's shorter but otherwise equivalent to `class { public: ... };`


Group by date using datatable

Question: I have a problem while grouping my datatable,
Here is the data,

Date                Location
23/07/2014 10:30    Near Highway
23/07/2014 11:30    Near Highway
23/07/2014 12:30    Near Highway
24/07/2014 01:00    From Texas
24/07/2014 01:10    From Texas
24/07/2014 01:20    From Texas
24/07/2014 01:30    From Texas

And I want to group by and manipulate the start time, end time and duration based on the location.

Date        Start time      End time        Duration        Location
23/07/2014  10:30           12:30           2 hour 00 min   Near Highway
24/07/2014  01:00           01:30           0 hours30 min   From Texas

Kindly help me to bring up this solution. Thanks in advance.
Comment: Can you show me the Query that you had tried
Comment: the problem is , i cant edit the query since it is the default log data. I need to manipulate using c# datatable or linq stuffs...
Comment: Yes group by location but i need to bring the start time and end time from the row data
Answer: I think this should work:
<code>    DataTable dt = new DataTable();
    dt.Columns.AddRange(new DataColumn[]
    {
        new DataColumn("Date",typeof(DateTime)),
        new DataColumn("Location",typeof(string)),
    });
    dt.Rows.Add(DateTime.ParseExact("23/07/2014 10:30", "dd/MM/yyyy HH:mm", new CultureInfo("fr-fr")), "Near Highway");
    dt.Rows.Add(DateTime.ParseExact("23/07/2014 11:30", "dd/MM/yyyy HH:mm", new CultureInfo("fr-fr")), "Near Highway");
    dt.Rows.Add(DateTime.ParseExact("23/07/2014 12:30", "dd/MM/yyyy HH:mm", new CultureInfo("fr-fr")), "Near Highway");
    dt.Rows.Add(DateTime.ParseExact("24/07/2014 01:00", "dd/MM/yyyy HH:mm", new CultureInfo("fr-fr")), "From Texas");
    dt.Rows.Add(DateTime.ParseExact("24/07/2014 01:10", "dd/MM/yyyy HH:mm", new CultureInfo("fr-fr")), "From Texas");
    dt.Rows.Add(DateTime.ParseExact("24/07/2014 01:20", "dd/MM/yyyy HH:mm", new CultureInfo("fr-fr")), "From Texas");
    dt.Rows.Add(DateTime.ParseExact("24/07/2014 01:30", "dd/MM/yyyy HH:mm", new CultureInfo("fr-fr")), "From Texas");

    DataTable dt2 = new DataTable();
    dt2.Columns.AddRange(new DataColumn[]
    {
        new DataColumn("Date"),
        new DataColumn("Start time"),
        new DataColumn("End time"),
        new DataColumn("Duration"),
        new DataColumn("Location")
    });
    var groups = dt.AsEnumerable().GroupBy(row => row["Location"]);
    foreach (var group in groups)
    {
        Console.WriteLine(group.Key);
        var groups2 = group.OrderBy(row => row["Date"]).GroupBy(row => Convert.ToDateTime(row["Date"]).ToString("dd/MM/yyyy"));
        foreach (var group2 in groups2)
        {
            Console.WriteLine("\t" + group2.Key);
            var list = group2.ToList();
            var startDate = Convert.ToDateTime(list[0]["Date"]);
            var endDate = Convert.ToDateTime(list[list.Count-1]["Date"]);
            TimeSpan ts = endDate-startDate;
            dt2.Rows.Add(group2.Key, startDate.ToString("HH:mm"), endDate.ToString("HH:mm"), ts.Hours + " hour " + ts.Minutes + " minutes", group.Key);
        }
    }
</code>

Group by date using datatable


How to find a Orc from a specific tribe in Shadow of War?

Question: I want to get the Marauder Legendary set in the Shadow of War. I found the list on what to do to get each item
<code>Gear                How To Unlock
Marauder Sword      Kill a Legendary Marauder Slayer or Marauder Berserker
Marauder Dagger     Kill a Legendary Marauder Assassin or Marauder Tracker
Marauder Bow        Kill a Legendary Marauder Marksman
Marauder Armor      Kill a Legendary Marauder Tank or Marauder Destroyer
Marauder Cloak      Kill a Legendary Marauder Beastmaster or Marauder Trickster
Marauder Ringcraft  Kill a Legendary Marauder Commander
</code>
How do I find the orc of the specific tribe? After some research I saw that in the Orc's subtitle name the tribe is written however I have been running around and I could not find a Marauder yet. In addition consider there is a desired Maurauder orc how can I make him Legendary. Some guides mention that I just need to die to him and the orc becomes legendary however if I am correct this is only Based on probability.
Answer: First of all, you can interrogate orcs to know the identity of captains or warchiefs, once you have informations on them, you can browse to seek what you look for. Unfortunately, every tribes can be found in every zones, it is random as the class they will have. Don't hesitate to kill the ones that doesn't fit your needs and wait time at the tower so new orcs will replace them.
To make your orc legendary, you can let him kill you a bunch of time but you can also make him fight your followers by ambushing him and letting him win, death threating him etc. Another risky method is to kill them and hope they will "cheat death"
Comment: Or recruit the orc, make him legendary and beat him up untill he betrays you. Then simply kill him. Note that making the orc your bodyguard makes it easier to stab him in the back.