Checking if two values match from one to another table

Question: So I started doing a app with JavaScript ORM- Sequelize.
I have a table called Workouts.js where the exercises are the id's in a table called Exercises.js.

Workouts.js

id
exercise_one
exercise_two
exercise_three
date

1
1
2
4
2022-02-21

2
4
3
2
2022-02-23

3
3
1
1
2022-02-25

I have another table called Workout_Volume.js which has the following values:

Workout_Volume.js

id
workout_id
exercise_id
sets
reps
weight

1
1
1
3
10
60

2
1
4
4
12
40

3
3
3
3
15
30

4
2
4
5
5
80

So my question is what is the correct way to validate in Workout_Volume.js workouit_id and exercise_id match as in Workouts.js when creating and updating Workout_Volume.js?

Workouts.js

const workout = (sequelize, DataTypes) => {
    const Workout = sequelize.define(
        'workouts', {
        exercise_one: {
            type: DataTypes.INTEGER(), allowNull: false,
            references: { model: "exercises", key: "id" },
            validate: {
                notNull: { msg: "You need to provide exercise_id !" }
            }
        },
        exercise_two: {
            type: DataTypes.INTEGER(), allowNull: true,
            references: { model: "exercises", key: "id" },
        },
        exercise_three: {
            type: DataTypes.INTEGER(), allowNull: true,
            references: { model: "exercises", key: "id" },
        },
        exercise_four: {
            type: DataTypes.INTEGER(), allowNull: true,
            references: { model: "exercises", key: "id" },
        },
        exercise_five: {
            type: DataTypes.INTEGER(), allowNull: true,
            references: { model: "exercises", key: "id" },
        },
        exercise_six: {
            type: DataTypes.INTEGER(), allowNull: true,
            references: { model: "exercises", key: "id" },
        },
        exercise_seven: {
            type: DataTypes.INTEGER(), allowNull: true,
            references: { model: "exercises", key: "id" },
        },
        exercise_eight: {
            type: DataTypes.INTEGER(), allowNull: true,
            references: { model: "exercises", key: "id" },
        },
        date: {
            type: DataTypes.DATEONLY, allowNull: false,
            validate: {
                notNull: { msg: "You need to provide date !" }
            }
        }
    },
        {
            timestamps: false,
            freezeTableName: true,
        })
        Workout.associate = models => {
            Workout.belongsToMany(models.exercises, {
                foreignKey: "exercise_one",
                through: 'exerciseOne',
                targetKey: "id"
            })
            Workout.belongsToMany(models.exercises, {
                foreignKey: "exercise_two",
                through: 'exercisTwo',
                targetKey: "id"
            })
            Workout.belongsToMany(models.exercises, {
                foreignKey: "exercise_three",
                through: 'exerciseThree',
                targetKey: "id"
            })
            Workout.belongsToMany(models.exercises, {
                foreignKey: "exercise_four",
                through: 'exerciseFour',
                targetKey: "id"
            })
            Workout.belongsToMany(models.exercises, {
                foreignKey: "exercise_five",
                through: 'exerciseFive',
                targetKey: "id"
            })
            Workout.belongsToMany(models.exercises, {
                foreignKey: "exercise_six",
                through: 'exerciseSix',
                targetKey: "id"
            })
            Workout.belongsToMany(models.exercises, {
                foreignKey: "exercise_seven",
                through: 'exerciseSeven',
                targetKey: "id"
            })
            Workout.belongsToMany(models.exercises, {
                foreignKey: "exercise_eight",
                through: 'exerciseEight',
                targetKey: "id"
            })
            Workout.belongsTo(models.workout_volume, {
                foreignKey:"id",
                targetKey: "workout_id",
                through: "workout_volume"
            })
        }

    Workout.sync()
    return Workout
}
module.exports = workout

Workout_Volume.js

const workoutVolume = (sequelize, DataTypes) => {
    const Workout_Volume = sequelize.define(
        'workout_volume', {
        workout_id: {
            type: DataTypes.INTEGER, allowNull: false,
            references: { model: "workouts", key: "id" },
            validate: {
                notNull: { msg: "You need to provide workout_id !" }
            }
        },
        exercise_id: {
            type: DataTypes.INTEGER, allowNull: false,
            validate: {
                notNull: { msg: "You need to provide exercise_id !" }
            },
        },
        sets: {
            type: DataTypes.INTEGER, allowNull: false,
            validate: {
                min: 1,
                max: 100,
                notNull: { msg: "You need to provide sets!" }
            }
        },
        reps: {
            type: DataTypes.INTEGER, allowNull: false,
            validate: {
                min: 1,
                max: 100,
                notNull: { msg: "You need to provide reps!" }
            }
        },
        weight: {
            type: DataTypes.INTEGER, allowNull: false,
            validate: {
                min: 0,
                max: 1000,
                notNull: { msg: "You need to provide sets!" }
            }
        }
    },
        {
            timestamps: false,
            freezeTableName: true,
        },
    )
    Workout_Volume.associate = models => {
        Workout_Volume.belongsTo(models.workouts,{
           foreignKey: "workout_Id",
           as: "workoutId",
           targetKey: "id"
        })
    }
    Workout_Volume.sync()
    return Workout_Volume
}

module.exports = workoutVolume

My thoughts on making is:

To make associations with exercise_id to each exercise value in Workouts.js. The problem is that the exercises are 8 and I think the project will become more hard-coded;
Don't make assosiactions but make a for loop where I will check if the requested workout_id and exercises_id match the Workout.js values;
Or if there is better way to consturct the tables so it makes more sence
Or if there is better way to construct tables or something else.

workoutVolume.controller.js

const models = require('../models');
const Workout_Volume = models.workout_volume;

exports.getAllWorkouts_Volume = async (req, res) => {
    try {
        const workout_volume = await Workout_Volume.findAll()
        return res.status(200).send(workout_volume)
    } catch (error) {
        return res.status(500).send(error)
    }
}

exports.getWorkout_Volume = async (req, res) => {
    try {
        const workout_volume = await Workout_Volume.findByPk(req.params.id)
        res.status(200).send(workout_volume)
    } catch (error) {
        return res.status(500).send(error)
    }
}

exports.createWorkout_Volume = async (req, res) => {
    try {
        const exerciseExists = await Workout_Volume.findAll({
            where: {
                exercise_id: req.body.exercise_id,
                workout_id: req.body.workout_id
            },
            attributes: ["exercise_id", "workout_id"]
        })
        if (exerciseExists.length !== 0) {
            return res.status(500).send("Exercise already done for this workout!")
        }
        await Workout_Volume.create(req.body)
        return res.status(201).send(req.body)
    } catch (error) {
        return res.status(500).send(error)
    }
}

exports.updateWorkout_volume = async (req, res) => {
    try {
        const workout_volume = await Workout_Volume.findByPk(req.params.id)
        console.log(req.body)
        const exerciseExists = await Workout_Volume.findAll({
            where: {
                exercise_id: req.body.exercise_id,
                workout_id: req.body.workout_id
            },
            attributes: ["exercise_id", "workout_id"]
        })
        if (exerciseExists.length !== 0) {
            return res.status(500).send("Exercise already done for this workout!")
        }
        await workout_volume.update(req.body)
        return res.status(200).send(req.body)
    } catch (error) {
        return res.status(500).send(error)
    }
}

The problem here is that when I create I can't create invalid workout_id but can create exercise_id which is not in Workout.js.
Also when I try to update it already the length is !== 0
Answer: You definitely need to create a table/model Workout_Excercise instead of adding columns in Workout table/model. That way you will have as many exercises in a certain workout as you want.
And the second great benefit of having Workout_Excercise is that you will be able to create a correct foreign key from Workout_Volume to Workout_Excercise:
Workout.hasMany(models.workoutExercises, {
                foreignKey: "workoutId",
            })
WorkoutExercise.belongsTo(models.exercises, {
  foreignKey: "exerciseId",
})
WorkoutExercise.hasMany(models.workout_volume, {
                foreignKey: "workoutExerciseId",
            })
WorkoutVolume.belongsTo(models.workout_exercise, {
                foreignKey: "workoutExerciseId",
            })

Comment: Added to the answer


Is it possible to create complex images (like cross functional flowchart) with Graphviz?

Question: I need to create a complex image with lanes (like a cross functional flowchart). Is it possible to use Graphviz to automatically (based on a csv file) generate something like the picture below? If not, how can I achieve that?
Answer: You could probably render some of it in Graphviz, such as in the cluster example, but Graphviz isn't really suited to this type of diagram. Its strength is directed graphs and hierarchical info.
Have a look at some of the declarative graphics libraries such as Altair or Matplotlib or Plotly. There is various levels of support for plotting axes in the style of lanes, then the rest is mostly textual annotations.
Answer: Technically, Graphviz could probably do it, but the spline connecting the 12 triangular nodes would be the only "easy" part of the effort.  For everything else, you would explicitly position/draw the nodes, swimlanes, and arrow edges.  Ugh!
The dpic variant of the pic language is closer fit, but I don't think it supports rotated text
I'd look at TikZ, Asymptote, and/or straight SVG
I don't know what your input file looks like, but the mapping to your output language will be challenging.  Good luck.


Rsync problem...filenames

Question: I'm trying to back up users Chrome Sessions with Rsync with the following command:
rsync -e "ssh -i new.key" -r --verbose -tz --stats --progress --delete \
'/cygdrive/c/Users/jay/AppData/Local/Google/Chrome/User Data/Default/Current Session' \
user@host:"/chrome sessions/"

Except this doesn't work exactly, as I get a file called chrome in a sessions directory that is already present on the server.
Why is this?
Answer: You need to escape the space in "chrome sessions":
rsync -e "ssh -i new.key" -r --verbose -tz --stats --progress --delete
'/cygdrive/c/Users/jay/AppData/Local/Google/Chrome/User Data/Default/Current Session'
user@host:"/chrome\ sessions/"
The double quotes are parsed and stripped by the local shell, keeping the two words together as a single argument to rsync. Rsync connects to the remote host and spawns a new shell.  That shell sees two arguments: "chrome" and "sessions".  If you have a quoted string with an embedded escape, the escape survives the trip to your remote host and tells the shell to ignore the space.
Answer: try it like this:
rsync -r --verbose -tz --stats --progress --delete '/cygdrive/c/Users/jay/AppData/Local/Google/Chrome/User Data/Default/Current Session' -e  "ssh -i new.key" user@host:"/chrome sessions/"

Rsync problem...filenames


Failing injection SubjectRepository to DataService in gradle multiproject [spring data]

Question: I have issue with injecting repository to service.
It's my first project in spring.
I made a tutorial from this site:
http://blog.netgloo.com/2014/10/27/using-mysql-in-spring-boot-via-spring-data-jpa-and-hibernate/
and i don't know what is wrong. I try annotation @EnableJpaRepositories, @Repository in interface but didn't help me.
All code is on my github: https://github.com/kklimczak/OpenStudies
Stacktrace:
<code>Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [pl.konradklimczak.openstudies.data.Subject.SubjectRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
</code>
Answer: @Transactional
@Repository
use this two annotation in your SubjectRepository from

import org.springframework.stereotype.Repository; import
  org.springframework.transaction.annotation.Transactional;
Comment: add to springboot main class annotations "@EntityScan" and @EnableJpaRepositories resolve my error! :) Thanks :)
Comment: @ kklimczak Use this annotation in yours spring-boot main class  and basepackage is yours project base package
"@SpringBootApplication"
"@ComponentScan(basePackages = "project base package")"
@EntityScan(basePackages ="project base package")
@EnableAutoConfiguration
@EnableJpaRepositories(basePackages = "project base package")


Identifying an ellipsoid from $9$ planes that are tangent to it

Question: The algebraic (implicit) equation of an ellipsoid is
$ (r - C)^T Q (r - C) = 1 $
where $ r = [x, y, z]^T $ is a point on the ellipsoid surface, and $ C = [C_x, C_y, C_z]^T $ is the center of the ellipsoid.  $Q$ is a $3 \times 3$ symmetric, positive definite matrix.
In diagonalized form, $Q = R D R^T $ where $D$ is a diagonal matrix of the reciprocal of the square of the semi-axes of the ellipsoid, and $R$ is a rotation matrix that gives the orientation of the ellipsoid in space.
Define $X = \begin{bmatrix} r \\ 1 \end{bmatrix} $ then the equation of the ellipsoid becomes
$ X^T G X = 0 $
where
$ G = \begin{bmatrix} Q && - Q C \\ - C^T Q && C^T Q C - 1 \end{bmatrix} $
A tangent plane $ N^T X = 0 $ to the ellipsoid satisfies
$ N^T G^{-1} N = 0 $
So with the $9$ planes, solve
$0 = N_i^T G^{-1} N_i , \hspace{15pt} i = 1, 2, \dots, 9$
for the entries of $G^{-1}$ which is symmetric.  This equation is linear in the entries of $G^{-1}$ and there are $10$ unknowns.  Using Gauss-Jordan elimination, the entries of $G^{-1}$ can be solved as an arbitrary nonzero scalar times a constant vector.  Setting the scalar to a variable $\dfrac{1}{t}$, we generate the matrix $G^{-1} = \dfrac{1}{t} G_0^{-1}$.  Inverting, $G = t G_0$.  Using the definition of $G$ we can solve for the scalar $t$ and thus find $Q$ and $C$.
We will have
$ G_0 = \begin{bmatrix} G_{011} && G_{012} \\ G_{012}^T && G_{022}  \end{bmatrix} $
$ Q = t G_{011} $
$ Q C = - t G_{012} $
It follows that $C = - G_{011}^{-1} G_{012} $
And to determine $t$, consider the $(2, 2)$ scalar
$ t C^T G_{011} C - 1 = t G_{022} $
And this can be solve for $t$ in a straight forward manner.  Now that we have the value of $t$, matrix $Q$ is known.
Finally, we diagonalize $Q$ to find the semi-axes and the orientation of the ellipsoid.
That's how I approached the problem of identification of the ellipsoid from the given $9$ planes tangent to it.
Any alternative suggestions and hints and solutions are greatly appreciated.
Answer: You are correct that the constraints from the tangent planes
$$
N_i^\top G^{-1} N_i = 0, \quad \forall\,i = 1, 2, \dots, 9 \tag{1}
$$
are linear in $G^{-1}$. However, only using these constraints would also allow for the trivial solution $G^{-1} = 0$. It can be shown that
$$
G^{-1} =
\begin{bmatrix}
Q^{-1} - C\,C^\top & -C \\
-C^\top & -1
\end{bmatrix} \tag{2}
$$
so the bottom right entry of $G^{-1}$ should be equal to minus one ($G^{-1}_{44} = -1$). Together with the six constraints from that $G$ and thus $G^{-1}$ is symmetric ($G^{-1}_{ij} = G^{-1}_{ji}, \forall\,i\neq j$) yields a total of 16 constraints, and thus uniquely defines $G^{-1}$.
Solving for $G^{-1}$ can be done in a structural way by writing all linear constraints in one system of linear equations. For this one can use the Kronecker product and vectorization, such that $(1)$ for each $i$ is equivalent to
$$
\left(N_i^\top \otimes N_i^\top\right) \text{vec}(G^{-1}) = 0.
$$
Combining all these linear constraints into one set of linear equations yields
$$
\underbrace{
\begin{bmatrix}
N_1^\top \otimes N_1^\top \\
\vdots \\
N_9^\top \otimes N_9^\top \\
\begin{matrix}
 0 & 1 & 0 & 0 & -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -1 & 0 & 0 & 0 \\
 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & -1 & 0 & 0 & 0 & 0 & 0 & 0 \\
 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 0 & 0 \\
 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & -1 & 0 \\
 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1
\end{matrix}
\end{bmatrix}}_{A\in\mathbb{R}^{16\times16}} \text{vec}(G^{-1}) =
\underbrace{\begin{bmatrix}
0 \\ \vdots \\ 0 \\ -1
\end{bmatrix}}_{b}. \tag{3}
$$
If each $N_i$ is chosen such that $A$ is nonsingular, then $(3)$ can be solved using
$$
\text{vec}(G^{-1}) = A^{-1} b. \tag{4}
$$

If it is preferred to having to solve a smaller system of linear equations, it is also possible to use reduced coordinates $y\in\mathbb{R}^9$, such that when they are projected to $\text{vec}(G^{-1})$, for example using the following transformation
$$
\text{vec}(G^{-1}) =
\underbrace{\begin{bmatrix}
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\
0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0
\end{bmatrix}}_T y -
\underbrace{\begin{bmatrix}
0 \\ \vdots \\ 0 \\ 1
\end{bmatrix}}_v, \tag{5}
$$
the symmetry and $G^{-1}_{44} = -1$ constraints are always satisfied. Substituting $(5)$ into $(3)$ yields
$$
\underbrace{\begin{bmatrix}
N_1^\top \otimes N_1^\top \\
\vdots \\
N_9^\top \otimes N_9^\top
\end{bmatrix}\!T\,}_{\tilde{A}\in\mathbb{R}^{9\times9}}\,y =
\underbrace{\begin{bmatrix}
N_1^\top \otimes N_1^\top \\
\vdots \\
N_9^\top \otimes N_9^\top
\end{bmatrix}\!v\,}_\tilde{b}. \tag{6}
$$
And thus, similarly to $(4)$, $(6)$ can be solved for $y$ and thus $\text{vec}(G^{-1})$ using $(5)$, using
$$
\text{vec}(G^{-1}) = T\,\tilde{A}^{-1} \tilde{b} - v. \tag{7}
$$

It can be noted that, besides $(7)$ being slightly less computationally expensive to solve than $(4)$, it would also be easier to expand to having more than 9 (but maybe noisy) tangent planes and obtain a least squares solution. Namely, the symmetry and $G^{-1}_{44} = -1$ constraints are hard constraints, but $(1)$ could have some uncertainty and thus doesn't have to be satisfied exactly. The least squares solution can then be obtained using
$$
\underbrace{\begin{bmatrix}
N_1^\top \otimes N_1^\top \\
\vdots \\
N_M^\top \otimes N_M^\top
\end{bmatrix}\!T\,}_{\hat{A}\in\mathbb{R}^{M\times9}}\,y =
\underbrace{\begin{bmatrix}
N_1^\top \otimes N_1^\top \\
\vdots \\
N_M^\top \otimes N_M^\top
\end{bmatrix}\!v\,}_\hat{b}, \tag{8}
$$
with $M>9$ the number of tangent planes, and
$$
\text{vec}(G^{-1}) = T\,\left(\hat{A}^\top \hat{A}\right)^{-1}\hat{A}^\top \hat{b} - v. \tag{9}
$$


What are the template variables to identify that a page is a term or user?

Question: I'm trying to modify a theme so that when the term page or user profile page are displayed it doesn't generate the title at the top.  I figured out how to do it on nodes but I just can't figure out what variable is used in the following code to identify a user or term page.  Any thoughts?
Here's the code from my page.tpl.php in a Bootstrap v3 theme:
<?php if (!isset($node)): ?>

<?php print $title; ?>

<?php endif; ?>

The above example suppresses the title when the page being viewed is a node.  I'd like to get this to work for user and term pages as well.
Answer: I think a better way to hide the title on user and taxonomy term pages would be to use a preprocess_page function in your themes template.php. This way you are keeping your page.tpl.php cleaner and separating logic.
/**
* Implements hook_preprocess_page
*/
function MY_THEME_preprocess_page(&$variables) {
    if( (arg(0)=='user' && arg(2)=='') || (arg(0)=='taxonomy' && arg(1)=='term' && arg(3)=='') ) {
        $variables['title'] = FALSE;
    }
}

This will only hide the title on the view pages, but it will still be there when editing content. This is done by checking that arg(2) is empty on user pages and arg(3) is empty on taxonomy term pages as if editing content these would contain the string "edit".
As pointed out by clive the line in your page.tpl.php would need to read:
<?php if ($title): ?>

<?php print $title; ?>

<?php endif; ?>

Once you have added this code then you will need to clear the cache to see the changes.
Comment: Logically this is definitely the better approach for what the OP wants. Using `menu_get_object()` would arguably be  preferable (I'm not `arg()`'s biggest fan either). There would be a slight change to the template here too, just to use `if ($title)` rather than `if (!isset($node))`. Otherwise you'll wind up with empty ``s
Comment: Would using this method clear the title variable that's actually in place or set a new one to be tested against?  See, I don't want to lose the actual title for breadcrumbs and meta data.  I just want to suppress it's output at the top of the page.
Comment: @Rob You'll only lose it in the context of the variables available in the page.tpl.php - it won't affect the rest of the page build (meta title is in html.tpl.php for example, different template with different vars). Breadcrumbs are already processed by that point too. Just check the rest of your page template file for more occurrences of `$title`...if you see none, you're golden
Answer: There aren't any by default, but you can add them easily enough using hook_preprocess_page():
function MYTHEME_preprocess_page(&$vars) {
  if ( ($term = menu_get_object('taxonomy_term', 2)) ) {
    $vars['term'] = $term;
  }
  elseif ( ($account = menu_get_object('user', 1)) ) {
    // Best not to use $vars['user'], it'll only overwrite something.
    $vars['user_page_account'] = $account;
  }
}

And then in the template file:
if (isset($term)) {
  // term page
}
elseif (isset($user_page_account)) {
  // user profile
}

You might find false positives in there, as you'll get (for example) a term object on the taxonomy/term/[id]/edit page. Whether that affects you will depend on what theme you're using for what page. If it's a problem, you can use arg() to check what's in the URL, e.g.
if ( ($term = menu_get_object('taxonomy_term', 2)) && !arg(3)) {
  ...

Comment: @arpitr Yeah the 2nd arg corresponds to the position of the entity ID in the URL, when it's split into an array by the '/' character (zero-based)
Comment: You can use `menu_get_item()` to get the actual router item and then figure out what to do from there.  That can avoid multiple calls to `menu_get_object()` if you don't know what to use for `$type`.  Though I think this gets weird when you have page manager overrides.
Comment: I was about to mention menu_get_object() before I came across https://drupal.org/node/1468006, but trick was passing argument as '2', right?
Comment: I was trying to think of a way to not use arg() and this is it. If you use $variables['title'] = FALSE; in your preprocess_page function then there will be no need to edit the page.tpl.php at all...
Answer: I tried both of the methods indicated and for various reasons they didn't quite work.  Thus I opted for a css option.  I added this to my css code for users and I'll add it for nodes and terms as well.  Problem solved-ish.  It's not elegant and it ends up making some of my pages looks a bit odd but it does work.
body.page-user h1.page-header {
  display: none;
}


How to configure selendroid and test mobile application

Question: I was trying to implement Selendroid in my pc.
I do as follows
1.Installed JDK
2.Installed eclipse
3.Installed SDk
4.Created Environmental Variables
5.Created a Java Application in eclipse
6.Mapped  Selendroid Standalone jar,Selendroid Standalone with dependencies, Selendroid Client and Selenium Client.I used the command in console as follows
java -jar selendroid-standalone-0.17.0-with-dependencies -apk myapk.apk
And verified status using http://localhost:4444/wd/hub/status.I created android application and was stuck after this,What do after this?
Answer: here is  their official site link http://selendroid.io/setup.html  from where you can  complete instruction regarding your question if you face any issue  than feel free to contact
Comment: import io.selendroid.client.SelendroidDriver;
is not working


Pra que servem e quais as diferenças entre Grunt x Gulp?

Question: Já ouvi falar muito de Grunt e Gulp, porém ainda não entendi pra que funcionam eles exatamente. as minhas dúvidas, são as seguintes:

 Pra que eles servem?
 Existe alguma relação entre eles?
 Eles podem ser comparados ao bower, por exemplo?
 Teria algum exemplo de como/ou quando usar um ou outro?
Answer:
Pra que eles servem?

De modo simples e resumido, ambos servem para automatizar e simplificar o seu fluxo de trabalho e processos.
Por exemplo, eu utilizo Grunt para fazer o processo dos meus arquivos em SASS e gerar um CSS minificado, sem ter que copiar meu arquivo, enviar para um serviço online para minificar, ou pior (e muito menos provável), fazer na mão. Outro exemplo, seria a concatenação de arquivos JS, enviar seus arquivos para uma hospedagem online através de uma conexão ftp, etc. São diversas opções.

Existe alguma relação entre eles?

Sim e não. Sim, pois ambos possuem a mesma finalidade, automatizar e simplificar processos. Não pois o modo como são feitos diferem um do outro e ai a questão muda bastante, pois começa a entrar mais em uma questão de preferência do que qual é melhor.

Eles podem ser comparados ao bower, por exemplo?

Não. Bower está para ser comparado com NPM. Ambos são gerenciadores de pacotes, por exemplo, você irá usá-los para fazer download de um plugin, enquanto grunt ou gulp será usado para processos (ou tarefas) dentro desses plugins. Bower e NPM teriam mais como finalidade você fazer download do bootstrap, por exemplo, verificar a versão e manter atualizado, tudo isso sem precisar ir de fato ao site do bootstrap e fazer isso manualmente.

Teria algum exemplo de como/ou quando usar um ou outro?

Como já citado nas respostas acima, mas só para reforçar. Existem diversas tarefas que eles podem executar, vou citar as que eu mais uso através do Grunt:

Concatenar e processar arquivos de SASS e Compass;
Remover classes não usadas de um arquivo CSS quando comparado aos arquivos html;
Minificar o arquivo CSS e fazer compressão em gzip;
Concatenar e minificar arquivos JS;
Compactar o projeto e executar upload para uma conexão ftp, colocando o projeto online;

Ou seja, todo esse processo é executado automaticamente pelo Grunt. Eu só preciso executar a linha de comando, exemplo grunt execBuild (baseado nas minhas configurações e pacotes) e todas essas tarefas serão executadas automaticamente. Então você pode ver um exemplo bem prático, funcional e que automatiza bastante as tarefas.
Já imaginou fazer isso tudo na mão?
Comment: Excelente! Muito boa resposta!


How to fix proxyconnect tcp: tls: first record does not look like a TLS handshake

Question: In How to consume a REST API in Go  a fully working example code is provided to call a public REST API. But if I try the sample this error occurs:
error getting cat fact:
      Get "https://catfact.ninja/fact":
      proxyconnect tcp: tls: first record does not look like a TLS handshake

The documentation about http states

For control over proxies, TLS configuration, keep-alives, compression, and other settings, create a Transport:

and from the Transport documentation:
    // DialContext specifies the dial function for creating unencrypted TCP connections.
    // If DialContext is nil (and the deprecated Dial below is also nil),
    // then the transport dials using package net.
    //
    // DialContext runs concurrently with calls to RoundTrip.
    // A RoundTrip call that initiates a dial may end up using
    // a connection dialed previously when the earlier connection
    // becomes idle before the later DialContext completes.
    DialContext func(ctx context.Context, network, addr string) (net.Conn, error)

So I assume that I have to configure Dialcontext to enable an insecure connection without TLS  from my client to the proxy. But I do not know how to do this. Reading these:

How to do proxy and TLS in golang;
How to HTTP/HTTPS GET via Proxy; and
How to do a https request with bad certificate?

did not help either. Some have the same error proxyconnect tcp: tls: first record does not look like a TLS handshake and explain the cause:

This is because the proxy answers with an plain HTTP error to the strange HTTP request (which is actually the start of the TLS handshake).

But Steffen's reply has no sample code how to set up DialContext func(ctx context.Context, network, addr string) and both Bogdan and cyberdelia suggest to set tls.Config{InsecureSkipVerify: true} for example like this
    tr := &http.Transport{
        TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
    }
    client := &http.Client{Transport: tr}

But the above has not effect. I still get the same error. And the connection is still calling https://* instead of http://*
This is the sample code and my attempt to include the above recommendations and adapt it:
var tr = &http.Transport{ TLSClientConfig:
                           &tls.Config{InsecureSkipVerify: true}, }
                           // lacks DialContext config
var client*  http.Client = &http.Client{Transport: tr} // modified * added
// var client *http.Client // code from tutorial

type CatFact struct {
    Fact   string `json:"fact"`
    Length int    `json:"length"`
}

func GetCatFact() {
    url := "http://catfact.ninja/fact" // changed from https to http
    var catFact CatFact

    err := GetJson(url, &catFact)
    if err != nil {
        fmt.Printf("error getting cat fact: %s\n", err.Error())
    } else {
        fmt.Printf("A super interesting Cat Fact: %s\n", catFact.Fact)
    }
}

func main() {
    client = &http.Client{Timeout: 10 * time.Second}
    GetCatFact()
    // same error
    // proxyconnect tcp: tls: first record does
    //                   not look like a TLS handshake
    // still uses https
    // for GET catfact.ninja
}

How can the connection be configured to use unencrypted connection from myClient over the proxy to the server? Will setting the DialContext func(ctx context.Context, network, addr string) help to do this? How can it be done?
Answer: I just tried:
package main

import (
    "context"
    "crypto/tls"
    "encoding/json"
    "fmt"
    "net"
    "net/http"
    "time"
)

type CatFact struct {
    Fact   string `json:"fact"`
    Length int    `json:"length"`
}

// Custom dialing function to handle connections
func customDialContext(ctx context.Context, network, addr string) (net.Conn, error) {
    conn, err := net.Dial(network, addr)
    return conn, err
}

// Function to get a cat fact
func GetCatFact(client *http.Client) {
    url := "https://catfact.ninja/fact"  // Reverted back to https
    var catFact CatFact

    err := GetJson(url, &catFact, client)
    if err != nil {
        fmt.Printf("error getting cat fact: %s\n", err.Error())
    } else {
        fmt.Printf("A super interesting Cat Fact: %s\n", catFact.Fact)
    }
}

// Function to send a GET request and decode the JSON response
func GetJson(url string, target interface{}, client *http.Client) error {
    resp, err := client.Get(url)
    if err != nil {
        return fmt.Errorf("error sending GET request: %w", err)
    }
    defer resp.Body.Close()

    if resp.StatusCode != http.StatusOK {
        return fmt.Errorf("received non-OK HTTP status: %d", resp.StatusCode)
    }

    err = json.NewDecoder(resp.Body).Decode(target)
    if err != nil {
        return fmt.Errorf("error decoding JSON response: %w", err)
    }

    return nil
}

func main() {
    // Create a custom Transport with the desired settings
    tr := &http.Transport{
        Proxy: http.ProxyFromEnvironment,  // Use the proxy settings from the environment
        DialContext: customDialContext,    // Use the custom dialing function
        TLSClientConfig: &tls.Config{
            InsecureSkipVerify: true,  // Skip certificate verification (not recommended in production)
        },
    }

    // Create a new HTTP client using the custom Transport
    client := &http.Client{
        Transport: tr,
        Timeout:   10 * time.Second,
    }

    // Call the function to get a cat fact
    GetCatFact(client)
}

It includes:

A custom dialing function customDialContext:
That function is currently a simple wrapper around net.Dial, but it provides a place where custom dialing logic could be introduced if necessary. It serves as a custom dialing function that is used to create network connections.

Transport configuration:

The revised code configures a custom http.Transport with specific settings, including a custom dialing function, proxy settings from the environment, and a TLS configuration that skips certificate verification (for testing).
The original code also attempted to configure a custom http.Transport, but it only included a TLS configuration to skip certificate verification, and did not set a custom dialing function or proxy settings.

Client configuration:

The revised code creates a new http.Client using the custom http.Transport, and sets a timeout of 10 seconds.
The original code also attempted to create a new http.Client with a custom http.Transport, but later in the main function, it overwrote the client variable with a new http.Client with a default Transport and a timeout of 10 seconds, effectively discarding the custom Transport.

Function signatures:

The revised code modifies the GetCatFact and GetJson functions to accept an *http.Client parameter, allowing them to use the custom http.Client created in main.
The original code did not pass the http.Client to these functions, so they would have used the default http.Client provided by the net/http package.

URL:

The revised code reverts the URL back to "https://catfact.ninja/fact" in the GetCatFact function, as the server redirects HTTP requests to HTTPS anyway.
The original code had changed the URL to "http://catfact.ninja/fact" in an attempt to avoid the TLS handshake error.

Beeing new to Go, I would expect that some "special" values must be passed to the signature func customDialContext(ctx context.Context, network, addr string) (net.Conn, error) to change the TLS handshake to "non-tls" or to ignore errors.
But I can not see anything like setting TLS version or something similar. What and where is the magic that makes Go to ignore the handshake error?

The customDialContext function in the code provided above does not contain any logic to specifically ignore TLS handshake errors or to change a TLS handshake to a non-TLS connection. It only provides a custom dialing function, which, in the provided form, just directly calls net.Dial without any special handling.
The mechanism to ignore TLS certificate verification errors is actually provided by the TLSClientConfig field of the http.Transport struct, specifically by setting the InsecureSkipVerify field to true:
tr := &http.Transport{
    TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}

That configuration tells Go to skip verifying the server's certificate chain and host name, which is a part of the TLS handshake process. However, it does not ignore other types of TLS handshake errors or switch to a non-TLS connection. It is generally not advisable to use InsecureSkipVerify: true in production environments, as it disables important security checks.
If you want to force a non-TLS (plain HTTP) connection, you would generally just use an http:// URL instead of an https:// URL. However, if the server or proxy server redirects HTTP to HTTPS (as is the case with http://catfact.ninja/fact), then the client will follow the redirect and switch to a TLS connection.
Comment: Perfect; this worked out of the box.  Beeing new to Go i would expect that some "special" values must be passed to the signature `func customDialContext(ctx context.Context, network, addr string) (net.Conn, error)` to change the TLS handshake to "non-tls" or to ignore errors. But i can not see anything like [setting TLS version](https://learn.microsoft.com/en-us/dotnet/api/system.security.authentication.sslprotocols?view=net-7.0) or something similar. What and where is the magic that makes Go to ignore the handshake error?
Comment: @surfmuggle I have edited the answer to address your first comment.


como forçar uma caixa de dialogo ficar acima da outra?

Question: Tenho 1 caixa de dialogo que chama uma 2, só que essa 2 precisa ficar acima da 1
como forço isso via javascript? ou qualquer outra forma, menos z-index que tentei e não tá indo.
Comment: o estilo z-ndex só funciona no objeto que já existe uma position previamente definida. Tente definir position para suas caixas de dialogo e aplique o z-index.
Comment: @BrunoCastro eu já fiz isso. eu já usei exatamente esse código em outro trecho e funciona perfeitamente, mas quando repito esse mesmo trecho em outra parte ele não funciona. Tem algum js que posso forçar?
Comment: Então, por favor, edite sua pergunta e adicione o código que você tentou fazer. Atente-se também em gerar um [mcve].
Comment: Coloca mais coisas para podermos te ajudar.
Answer: Como você não postou algum código ou algo do tipo fiz um exemplo com divs , se meu exemplo não servi edite a pergunta, e comente abaixo para que eu possa modificar podendo assim te ajudar melhor.

$(function(){
  $('#mostrarDiv').click(function(){
    $('.div2').show(250);
  });
  $('#ocultarDiv').click(function(){
    $('.div2').hide(250);
  });
});
.div1{
  position: absolute;
  top: 0;
  left: 0;
  width: 200px;
  height: 200px;
  background: green;
}

.div2{
  display:none;
  position: absolute;
  top: 30;
  left: 30;
  z-index: 5;
  width: 200px;
  height: 200px;
  background: red;
}

#mostrarDiv{
  position: absolute;
  top: 300px;
}

#ocultarDiv{
  position: absolute;
  top: 300px;
  left: 130px;
}

<input type="button" id="mostrarDiv" value="Chamar div 2">
<input type="button" id="ocultarDiv" value="Ocultar div 2">


How to simplify $\frac{(x - 1)(7x + 6)}{(x - 1)(x + 1)^2 }-\frac{ 7}{ (x + 1)}$?

Question: Iam having trouble simplifying this expression:$$\frac{(x - 1)(7x + 6)}{(x - 1)(x + 1)^2  }-\frac{ 7}{  (x + 1)}$$
What are the steps to simplify this?
I know you expand $(x + 1)^2$ to $(x + 1)(x + 1)$, and that you need to find a common denominator before adding the numerators together.
The final answer is $\quad\displaystyle\frac{-1}{x^2 + 2x + 1}.$
Thanks.
Comment: I think someone got the problem wrong: looks like it should be a $-$, not a $+$.
Answer: We want to simplify the following:
$$\frac{(x-1)(7x + 6)}{(x-1)(x+1)^2} - \frac {7}{(x+1)}$$
First, we cancel the common factor $(x-1)$ in the left-hand fraction:
$$\frac{(x-1)(7x + 6)}{(x-1)(x+1)^2} - \frac {7}{(x+1)} = \frac{(7x + 6)}{(x+1)^2} - \frac {7}{(x+1)}$$
Now we find a common denominator to add the fractions, and see that we want both denominators to be $(x+1)^2$. To accomplish this, we can multiply the numerator and the denominator of the second fraction by the factor of $(x+1)$:
$$\frac{(7x + 6)}{(x+1)^2} - \frac{7}{(x+1)} \cdot \frac{(x+1)}{(x+1)} = \frac{(7x + 6)}{(x+1)^2} - \frac {7(x+1)}{(x+1)^2}$$ $$ = \frac{(7x + 6 - 7(x+1))}{(x+1)^2} \;=\;\frac{ -1}{(x+1)^2} $$ $$\;=\;\frac{-1}{x^2 + 2x + 1}$$
Comment: How did you get (x+1)^2 on the right hand side?
Comment: Because both denominators: $(x+1)$ and $(x+1)^2$ - divide $(x+1)^2$. Notice that $\dfrac{7(x+1)}{(x+1)^2} = \dfrac{7}{(x+1)}$
Comment: Ohh okay. Sort of starting to understand.
Comment: Why not by (x+1)^2?
Comment: Yeah I see you times by (x+1) to the right hand fraction, but shouldn't it be (x+1)^2, you times 7 by (x+1) not (x+1)^2, I don't understand why.
Comment: Because we only needed an extra factor of $(x+1)$ in the denominator of $\dfrac{7}{(x+1)}$ to get $(x+1)(x+1) = (x+1)^2$ in the denominator. So we multiplied both numerator and denominator of $\dfrac{7}{(x+1)}$ by $\dfrac{(x+1)}{(x+1)}$ giving us $\dfrac{7(x+1)}{(x+1)(x+1)} = \dfrac{(7(x+1)}{(x+1)^2}$. Then we can simply add the numerators to get the result, since now the denominators of the fractions are equal.
Comment: So you can just take what you need and ignore the rest? Hmm..I thought you had to times the right hand fraction by the left denominator and the left hand fraction by the right denominator.
Comment: If we multiplied numerator and denominator by $(x+1)^2$, we'd end up with $\dfrac{7}{(x+1)} \cdot \dfrac{(x+1)^2}{(x+1)^2} = \dfrac{7(x+1)^2}{(x+1)^3}$, and we still wouldn't be able to subtract it from the other fraction!
Answer: If x$\neq$1, you can cancel $(x-1)$ in the numerator and denominator of $\frac{(x - 1)(7x + 6)}{(x - 1)(x + 1)^2  }$ so,
$$\frac{(x - 1)(7x + 6)}{(x - 1)(x + 1)^2  }-\frac{ 7}{  (x + 1)}=\frac{7x + 6}{(x + 1)^2  }-\frac{ 7}{  (x + 1)}$$
Now, if x$\neq$-1 you can multiply and divide $\frac{7}{x + 1}$ by $(x+1)$ and add the fractions:
$$\frac{7x + 6}{(x + 1)^2  }-\frac{ 7}{  (x + 1)}=\frac{7x + 6}{(x + 1)^2  }-\frac{7(x+1)}{  (x + 1)^2}=\frac{7x + 6-7(x+1)}{(x + 1)^2}=\frac{-1}{(x + 1)^2}$$
Comment: Why do you not times the right fraction by (x+1)^2?
Comment: @Cypras, because i need have a denominator in the two fractions such that both are equal, this, because you know that if i have two fractions $\frac{A}{B}$ and $\frac{C}{B}$ then, the sum of the 2 fractions is $\frac{A+C}{B}$ and so it is easier to add, (it is equivalent to searching the common denominator, which is the same thing amWhy said)
Comment: @amWhy, sorry, I started writing before, but when I published the answer I had not yet seen another answer.


Shortest seek time first algorithm using Comparator

Question: Working on a SSTF algorithm using java.util.Comparator
This is what i have so far:
private int nextHeadPosition;

public SSTF(int currentHeadPosition) {
    nextHeadPosition = currentHeadPosition;
}

@Override
public int compare(DiskRequest r1, DiskRequest r2) {
    if (nextHeadPosition - r1.getTrackNumber()  < nextHeadPosition -  r2.getTrackNumber()) {
        nextHeadPosition = r1.getTrackNumber();
        return -1;
    } else if (nextHeadPosition - r1.getTrackNumber() > nextHeadPosition - r2.getTrackNumber()) {
         nextHeadPosition = r2.getTrackNumber();
        return 1;
    } else {
        return 0;
    }
}

with an initial head position of 50 it is producing this order:
[100, 99, 50, 45, 44, 1]

The output I am trying to produce:
[50, 45, 44, 1, 99, 100]

this might not be posible with comparator

edit
SSTF
for a queue of requests that have track numbers, the first request to be serviced will be the track that is closest to the current position of the head. Each subsequent request will be ordered by least distance from the position of the last request.
so for a queue with tracks [100, 99, 50, 45, 44, 1] and a current head position of 50, the first request will be 50. The next will be the track closest to 50, which is 45 in this case. lather rinse repeat.
Comment: i don't get your problem
Comment: What did you expect to get? What is the problem here?
Comment: Your expression `nextHeadPosition - rw.getTrackNumber()` makes no sense.  If you want to compare two fields, you have to do them independently.
Comment: How did you calculate that expected ordering?
Comment: @shark manually applying the SSTF algorith
Comment: @Austin can you write the steps down? in which order did you compare the items? can you get the same expected output by hand by reversing the array? Peter made a good point about just comparing in a `compare()` call. What is this `nextHeadPosition` and where is it used?
Comment: How this code is being called?
Comment: `Collections.sort(requests, new SSTF(50))`
Answer: First, you want to compare the distance between the track and the head position, so you have to use the absolute value in your conditions.
if (Math.abs(nextHeadPosition - r1.getTrackNumber())  < Math.abs(nextHeadPosition -  r2.getTrackNumber()))

But your compare method modifies the object, which is not a good idea since you don't know how Collections.sort() (I guess that's what you're trying to use) will use it. You have to write your own sorting algorithm I think.
Comment: Thanks, I knew it was something small, its still giving an incorrect result of `[44, 45, 50, 99, 1, 100]` but it's closer. This is purely academic to see if it could be done with Comparator. no production code has been harmed in my shenanigans
Answer: problem line is
 if (nextHeadPosition - r1.getTrackNumber()  < nextHeadPosition -  r2.getTrackNumber()) {

nextHeadPosition =50
r1.getTrackNumber()=99
r2.getTrackNumber()=45
if((50-99) < (50-45)) translates to if(-44< 5)
Using Math.abs is one solution . Also if you show us code where you are using provided code... it will be better to help.


Trial ball in international matches

Question: Is there any chance of bowling a trial ball before the start of the innings in international cricket history like street cricket or local cricket matches?
Answer if yes:

When did they stop this practice?
What is the reason for that?

If No:

What is the reason for not including this sportive thing in
international cricket?
Comment: I don't think any justification needs to be given for it _not_ being included. If one thinks that international cricket should include a trial ball, then one needs to make a case for it. I can't see how sportsmanship has anything to do with it.
Answer: No, you cannot practice on the pitch see The Laws of Cricket. The reason is the state of the pitch, and any wear on it, is an important part of how a game of cricket unfolds. Practicing on the pitch would alter its state and therefore could be used as a tactic in some way, so is not permitted.
Comment: good answer, but qn is not about practice, it's about trial ball which is bowled in our street cricket matches
Comment: Whether you call it practice and warm up or a 'trial ball' the rules are very clear that it is not permitted on the pitch for the reasons given. International cricketers certainly warm up before the game, generally on the outfield, you're just not allowed to do so on the match pitch itself.
Comment: Sorry, first sentence should read "Whether you call it practice OR warm up..". Too old to edit.
Comment: ur answer is, `in international cricket history trial balls were not bowled in any match` is it?
Comment: in ur answer, `Practicing on the pitch would alter its state and therefore could be used as a tactic in some way, so is not permitted.` Iam not asking about practicing in the pitch,it's abt `just bowl a single ball to the opening batsman by the opening bowler which is not counted in the match.` did u get me?
Comment: Have you read the link I posted?
Answer: Trial ball is not permitted in international cricket. There is no law regarding this. If any trial ball would be allowed, there would be a law on that.
Also, there is a law regarding trial run up. (17.4)

4.Trial run up
A bowler is permitted to have a trial run up provided the umpire is
satisfied that it will not contravene either of Laws 42.9 (Time
wasting by the fielding side) or 42.13 (Fielder damaging the pitch).

So it is clear that a bowler can take a trial run up but can't bowl a trial ball (after taking a run up). Mostly opening bowlers take trial run up (maybe to adjust on the field).

Trial ball in international matches


What is this chord, and how do I name chords like this

Question: I've written a piece that has this chord (notes from lowest to highest):

I'm not quite sure how to name this chord, most of my attempts have been confusing [such as E-7(5)/B♭]. It's definitely a B♭ centered sound, with G also being a strong note contextually. What would be the cleanest way to name this? Are there strategies for naming chords like this?
Edit: Here is the entire chord progression used:
Comment: Or it's a C13 missing the root.
Comment: The way to describe this progression is with notation.  Even if we did manage to contrive a chord symbol, it wouldn't really help anyone to either play or analyse it.
Comment: Why do you need to name it?
Comment: Context needed. Out of context I could call it maybe Gm6/9, with 7 not played. Or maybe Eø7add4? Or maybe something else?
Comment: @phoog mostly improv reasons
Answer:
Are there strategies for notating chords like this?

The bass note matters a lot for the chord sound. It's rare to have upper structure notes in the bass. It's not because they necessarily sound bad, but because the bass note is so dominating that it may no longer sound as an upper structure. In your case, Bb could be the root of a Bb chord, could be a third of a G chord, maybe could be a b5 of an E chord, but is rather unlikely to be the b13 of a D chord, or the b9 of an A chord.
This gives us three candidates:

Bbmaj7#46
Gm69/Bb
Eø7add4/Bb (or Em7b5add4/Bb)

As PiedPiper suggests, one more possibility is for the chord to be missing the root, a.k.a. rootless voicing. C13 is a really good suggestion! It includes 3: E, and b7: Bb, which are the most important tensions, and then some more. Also, importantly, it doesn't include F, which is 4, which often blurs the chord's identity.
But how to choose one of those? This depends on the context.
Ask yourself "what does it sound like?" What other, simpler chord you could play instead to move the harmony in a similar way. This may mean removing additional notes from your chord, but also adding some which are omitted. Could you replace it with a C triad? This depends on the context, the key, the preceding chords, and most importantly, the following ones. How the harmony flows, what resolves to what?
What you propose, E-7(5)/B♭, isn't right. There isn't really such a thing as a 5. A perfect fourth sounds like a perfect fourth. Em7b5 is quite a common chord, on the other hand.
Edit:
Within the context, I would interpret the whole progression as:
Em7b5add4/Bb Am7 Gm7 Dmadd4add2
Why this choice? Please compare it with this simplified progression:

This is of course subjective, but to me it seems these simple chords grasp the essence of the progression, and what you have is just more "color" notes. The V→I relations between E and A, and then G and D dominate the movement, especially given the lack of other strong dissonances and resolutions.
The last chord feels quite unresolved, due to the added 4, but within the context I hear it as Dm.
Comment: Yes, I'd vote for rootless C13. :)
Answer: If you want to name that chord with a chord symbol and Bb feels like the root then call it a Bbmaj13(b5) or Bbmaj7(b5,13). I would not call it a #11 because when most people see #11 they will voice that note in an upper octave. I prefer not to use inversions and/or rootless designations when there is a logical spelling for a chord in root position. In this case the context shows other chords are not rootless. Root position chords will usually show harmonic function better than their inversion counterparts. It will also usually make it easier for constructing bass lines and improvising over,
The truth of the matter is chord symbols are an inexact science and will not always give you the desired results when played by other musicians. If you want those notes in that order from low to high then just write out the voicings like you did instead of using chord symbols.


Working out the normalization of $\mathbb C[X,Y]/(X^2-Y^3)$

Question:
I'm trying to identify the normalization of the ring $A := \mathbb C[X,Y]/\langle X^2-Y^3 \rangle$ with something more concrete.

First, $X^2-Y^3$ is irreducible in $\mathbb C[X,Y]$, making $\langle X^2-Y^3\rangle$ prime, so $A$ is a domain and it makes sense to talk about its normalisation, i.e., its integral closure in $\mathrm{Frac}(A)$. Then, we try to understand $\mathrm{Frac}(A)$: the composite arrow
$$ \mathbb C[X,Y] \twoheadrightarrow A \hookrightarrow \mathrm{Frac}(A) $$
maps every element not in $\langle X^2-Y^3 \rangle$ to an invertible one in $\mathrm{Frac}(A)$. By the universal property of the localization, it defines an arrow $h : \mathbb C[X,Y]_{\langle X^2-Y^3\rangle} \to \mathrm{Frac}(A)$ making the following diagram commute :
$$ \begin{matrix}
\mathbb C[X,Y] & \twoheadrightarrow & A & \hookrightarrow & \mathrm{Frac}(A) \\
\downarrow &&&& \| \\
\mathbb C[X,Y]_{\langle X^2-Y^3\rangle} & &\stackrel h \longrightarrow & & \mathrm{Frac}(A).
\end{matrix}$$
The arrow $h$ is onto: for $P,Q \in \mathbb C[X,Y], Q \notin \langle X^2-Y^3 \rangle$, $h(P/Q) = \pi(P) // \pi(Q)$ (denoting '/' the fraction of the left localization, '//' the one in $\mathrm{Frac}(A)$, and $\pi \colon \mathbb C[X,Y] \twoheadrightarrow A$). Then, we have a description of the fraction field of $A$ as
$$\mathrm{Frac}(A) \simeq \mathbb C[X,Y]_{\langle X^2-Y^3\rangle} \,\big/\, \ker (h) \simeq \{P/Q \in \mathbb C(X,Y) \mid Q \notin \langle X^2-Y^3\rangle\} \,\big/\, \langle X^2 - Y^3 \rangle.$$
Am I correct so far ? If so, I'm having trouble to determine algebraic integers in this $A$-algebra. Any hint ?
Answer: Hints:

Show that $t=X/Y$ is integral over $A=\Bbb{C}[X,Y]/(X^2-Y^3)$.
Show that $A[t]=\Bbb{C}[t]$ is integrally closed.

The general facts related to this:

integral closure of the coordinate ring of an algebraic curve is broken only at singular points (here the cusp at the origin), so the coordinate ring of a non-singular curve is integrally closed.
in the case of a curve, the integral closure of the coordinate ring (inside the function field) is the intersection of the DVRs containing $R$ - this is why integral closure can be studied locally

There is more to be said about the interplay between integral closure and local behavior of varieties, but I don't know/remember more. Waiting for somebody else to take over...
Comment: So blowig up the cusp here removes the singularity, and also gives the integral closure.
Comment: Thanks. So first hint is obvious : $T^2-Y$ admits $t$ as root. As $X=t^3$ and $Y=t^2$ in $\mathrm{Frac}(A)$, it gives $A[t] = \mathbb C[t]$. Now, $t$ is not algebraic over $\mathbb C$, which make $\mathbb C[t]$ isomorphic to the $\mathbb C$-algebra of polynomial in one variable $\mathbb C[T]$. As $\mathbb C$ is factorial, so is $\mathbb C[T]$. Factorial implies integrally closed, which concludes (integers over $A$ are integers over $A[t]$, so in $A[t]$ ; conversely, $A[t]$ is integral over $A$). Is that what you had in mind with those 2 hints ?
Comment: @JyrkiLahtonen The normalization, at least for one-dimensional varieties over alg. closed fields, corresponds merely to resolution of singularities. Indeed, in dimension 1, the obstruction to a variety being non-singular is normality. Namely, it's not hard to show that a curve is non-singular if and only if its coordinate ring is a Dedekind domain, which since the coordinate ring are already one-dimensional and Noetherian, is equivalent to integrally closed. Of course, integral closedness is local, and the basic problem is that at the point $(x-a,y-b)$ where the curve has a singularity
Comment: @JyrkiLahtonen The classic example is the cone $z^2=xy$ in $\mathbb{A}^3$. The basic thing is that, for an affine variety, being non-singular is the same as having your coordinate ring be regular (this just means your localizations at maximals are all regular local). In dimension $1$, being regular is equivalent to normal, but for higher dimensions this fails to be true. So, if you'd rather think in algebra land, find a ring $R$ which is normal, but is not regular and take its spectrum. Of course, as we've said, we will necessarily have that $\dim R>1$. Does that help at all?
Comment: @Anakhand AlexYoucis knows this stuff better than I do, but I think a key point is that $t=X/Y$ is a local parameter for the relevant *place* of the function field. Or, the key point in a smooth model of the function field. Wait for a more detailed explanation from him.
Comment: Correct, Pece. You may want to wait for an algebraic geometer to show up, and say more :-)
Comment: @JyrkiLahtonen Just out of curiosity, what would you want an algebraic geometer to say? Geometrically, the normalization of the cuspidal cubic (CC) is the parabola, which has coordinate ring $k[t]$. So, the normalization of the coordinate ring of the CC is isomorphic to $k[t]$. More explicitly, the normalization gives rise to the reverse maps of coordinate rings which finds that $X\mapsto t^3$ and $Y\mapsto t^2$. So, we see that the element of the coordinate ring of the CC that is missing is $t=\frac{X}{Y}$.
Comment: @Alex: Thanks for asking. I have this recollection that normalization is equivalent to finding a smooth model for curves, but with higher dimensional varieties there is more going on. May be answering that would take us too far afield? I guess I could ask that question myself, but the recollection is too vague to turn it into a useful question.
Comment: @JyrkiLahtonen you can show that its coordinate rings localization, say $A(C)_{(x-a,y-b)}$, does not have principally generated maximal ideal, and so not a DVR (which, in our case, is equivalent to integrally closed since A(C) is already dimension 1 and Noetherian). Does that at all answer anytyhing for you?
Comment: Sure, thanks @Alex. If there is an easy to describe 2-dimensional counterexample to integral closure being equivalent to non-singular, that would be a nice completion, but "may take us too far afield" :-)
Comment: Of course, I meant localization at every prime is regular local :)
Comment: @JyrkiLahtonen: But we also need to check whether there is a map $t \mapsto (f(t),g(t))=(x,y)$, or in the above case: $t\mapsto (t^3,t^2)$ ?
What if we can't find such a map?
Comment: @Alex Thanks for your insights. Do you also have geometric intuition for the element that needs to be added to the ring to normalize it? In this example, we needed to add $t = X/Y$ to normalize the ring. How does this relate geometrically to the cusp on the curve? Is there some inuition that would lead us to consider this element instead of, say $Y/X$, or any other element (without checking algebraically)?


Is considered a bouncer if a batsman hits it?

Question: Suppose a bowler bowls a shoulder height ball at the batsman and the batsman hits a four or gets out. Can the ball be called as a bouncer?
Comment: Your question is unclear. Are you asking: Is it considered a bouncer *if a bowler bowls a shoulder height ball?* or *a batsman hits a bouncer ball* anything else?
Comment: Do you mean will it be declared a no ball?
Answer: The law/meaning of the bouncer is the ball bounces above shoulder height irrespective of a batsman hits it or not. So it is considered a bouncer even if a batsman hits it and gets runs or out.
Answer: As per ICC rules, Bouncer is declared when bowler bowls above batman's shoulder height.Because its pretty obvious that if ball is above shoulder height, Batman might be not able to play it.
So Everytime when bowler bowls above shoulder height, Leg umpier straight away declare it as NO BALL wheather batman hits it or not.
Comment: This answer is incorrect a bouncer must be over head height to be no balled instantly.  It would need to meet the criteria under the laws for the bowlers end umpire to no ball and warn.


R - One line, two colors in plotly

Question: Haven't quite found a good answer to this.
I'd like to have only one line with different colors rather than separating the two lines.
library(plotly)
library(reshape)
library(RColorBrewer)

fig <- plot_ly(big[1:100,], y = ~price, x = ~time, type = 'scatter', mode = 'lines+markers', color = ~ as.factor(dir))%>%
  layout(legend=list(title=list(text='smoker')), title = "String 'smoker' values mean discrete colors",
         plot_bgcolor='#e5ecf6')
fig

Warning messages:
1: In RColorBrewer::brewer.pal(N, "Set2") :
  minimal value for n is 3, returning requested palette with 3 different levels

2: In RColorBrewer::brewer.pal(N, "Set2") :
  minimal value for n is 3, returning requested palette with 3 different levels

Basically I just want to connect these lines as if they were one.
EDIT: a black line with colored points would be fine as well.

Data:
dput(head(big,100))
structure(list(time = structure(c(1647246002.24923, 1647246002.79761,
1647246003.33618, 1647246004.39149, 1647246004.44229, 1647246005.04222,
1647246005.61024, 1647246006.19858, 1647246006.74267, 1647246007.28133,
1647246007.82673, 1647246007.86367, 1647246008.44411, 1647246008.98759,
1647246009.02739, 1647246010.60053, 1647246011.15027, 1647246011.17698,
1647246011.72366, 1647246012.79303, 1647246013.33196, 1647246013.87512,
1647246015.96322, 1647246015.99679, 1647246016.53583, 1647246017.08083,
1647246017.6256, 1647246018.17829, 1647246018.71606, 1647246019.25767,
1647246019.79644, 1647246020.33468, 1647246020.8824, 1647246021.94552,
1647246022.01591, 1647246023.6453, 1647246024.18459, 1647246024.72267,
1647246025.26541, 1647246025.8108, 1647246026.36594, 1647246027.00413,
1647246027.5502, 1647246028.08886, 1647246028.12655, 1647246028.19781,
1647246029.25628, 1647246029.7948, 1647246029.82717, 1647246029.88239,
1647246030.94222, 1647246030.98792, 1647246031.02387, 1647246031.56251,
1647246032.10701, 1647246033.68004, 1647246034.21849, 1647246034.75698,
1647246034.79206, 1647246035.33537, 1647246035.88073, 1647246036.41933,
1647246037.47445, 1647246038.02743, 1647246038.56629, 1647246039.11172,
1647246039.69961, 1647246040.24075, 1647246040.78262, 1647246040.81593,
1647246040.84878, 1647246040.89548, 1647246041.44543, 1647246043.02019,
1647246043.56719, 1647246044.11148, 1647246045.17907, 1647246045.73629,
1647246046.2821, 1647246047.33841, 1647246048.92821, 1647246049.47257,
1647246050.01503, 1647246050.04984, 1647246050.58807, 1647246051.13286,
1647246051.6825, 1647246052.7956, 1647246053.49162, 1647246054.03274,
1647246054.57456, 1647246055.632, 1647246055.66697, 1647246055.70239,
1647246056.25411, 1647246056.79885, 1647246057.87931, 1647246058.42802,
1647246060.52577, 1647246061.07338), tzone = "UTC", class = c("POSIXct",
"POSIXt")), price = c(13344.77, 13343.52, 13342.27, 13343.27,
13343.02, 13343.27, 13343.27, 13342.27, 13344.77, 13345.02, 13344.52,
13345.52, 13345.02, 13345.05, 13345.52, 13345.27, 13345.52, 13345.77,
13346.27, 13346.52, 13345.52, 13345.02, 13345.77, 13346.02, 13345.52,
13346.02, 13347.77, 13347.02, 13345.77, 13346.77, 13347.27, 13347.52,
13349.02, 13349.02, 13349.27, 13350.77, 13350.52, 13351.02, 13348.77,
13348.27, 13348.77, 13349.52, 13349.27, 13348.52, 13347.77, 13348.27,
13348.77, 13350.77, 13350.27, 13351.27, 13351.52, 13352.02, 13351.77,
13352.02, 13351.52, 13350.52, 13351.02, 13351.52, 13351.77, 13351.27,
13351.52, 13351.27, 13351.27, 13351.77, 13350.77, 13351.52, 13351.77,
13352.52, 13353.52, 13353.77, 13354.27, 13355.77, 13356.27, 13355.52,
13354.02, 13353.77, 13353.52, 13355.27, 13355.52, 13356.27, 13357.02,
13358.77, 13358.52, 13358.02, 13358.27, 13358.02, 13357.77, 13355.77,
13356.02, 13356.27, 13356.02, 13356.27, 13356.52, 13356.05, 13356.52,
13357.02, 13357.52, 13358.77, 13358.52, 13357.77), weekday = c("Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon",
"Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon"
), threshup = c(13353.27, 13352.02, 13350.77, 13351.77, 13351.52,
13351.77, 13351.77, 13350.77, 13353.27, 13353.52, 13353.02, 13354.02,
13353.52, 13353.55, 13354.02, 13353.77, 13354.02, 13354.27, 13354.77,
13355.02, 13354.02, 13353.52, 13354.27, 13354.52, 13354.02, 13354.52,
13356.27, 13355.52, 13354.27, 13355.27, 13355.77, 13356.02, 13357.52,
13357.52, 13357.77, 13359.27, 13359.02, 13359.52, 13357.27, 13356.77,
13357.27, 13358.02, 13357.77, 13357.02, 13356.27, 13356.77, 13357.27,
13359.27, 13358.77, 13359.77, 13360.02, 13360.52, 13360.27, 13360.52,
13360.02, 13359.02, 13359.52, 13360.02, 13360.27, 13359.77, 13360.02,
13359.77, 13359.77, 13360.27, 13359.27, 13360.02, 13360.27, 13361.02,
13362.02, 13362.27, 13362.77, 13364.27, 13364.77, 13364.02, 13362.52,
13362.27, 13362.02, 13363.77, 13364.02, 13364.77, 13365.52, 13367.27,
13367.02, 13366.52, 13366.77, 13366.52, 13366.27, 13364.27, 13364.52,
13364.77, 13364.52, 13364.77, 13365.02, 13364.55, 13365.02, 13365.52,
13366.02, 13367.27, 13367.02, 13366.27), nextup = c(69L, 68L,
38L, 52L, 52L, 52L, 52L, 38L, 69L, 70L, 69L, 71L, 70L, 70L, 71L,
71L, 71L, 72L, 72L, 72L, 71L, 70L, 72L, 72L, 71L, 72L, 81L, 72L,
72L, 72L, 73L, 73L, 82L, 82L, 82L, 103L, 103L, 103L, 82L, 81L,
82L, 82L, 82L, 82L, 81L, 81L, 82L, 103L, 103L, 104L, 104L, 112L,
105L, 112L, 104L, 103L, 103L, 104L, 105L, 104L, 104L, 104L, 104L,
105L, 103L, 104L, 105L, 113L, 3724L, 3905L, 4101L, 4115L, 4116L,
4114L, 4071L, 3905L, 3724L, 4111L, 4114L, 4116L, 4145L, 4201L,
4201L, 4164L, 4200L, 4164L, 4164L, 4115L, 4115L, 4116L, 4115L,
4116L, 4145L, 4115L, 4145L, 4145L, 4164L, 4201L, 4201L, 4164L
), threshdown = c(13339.77, 13338.52, 13337.27, 13338.27, 13338.02,
13338.27, 13338.27, 13337.27, 13339.77, 13340.02, 13339.52, 13340.52,
13340.02, 13340.05, 13340.52, 13340.27, 13340.52, 13340.77, 13341.27,
13341.52, 13340.52, 13340.02, 13340.77, 13341.02, 13340.52, 13341.02,
13342.77, 13342.02, 13340.77, 13341.77, 13342.27, 13342.52, 13344.02,
13344.02, 13344.27, 13345.77, 13345.52, 13346.02, 13343.77, 13343.27,
13343.77, 13344.52, 13344.27, 13343.52, 13342.77, 13343.27, 13343.77,
13345.77, 13345.27, 13346.27, 13346.52, 13347.02, 13346.77, 13347.02,
13346.52, 13345.52, 13346.02, 13346.52, 13346.77, 13346.27, 13346.52,
13346.27, 13346.27, 13346.77, 13345.77, 13346.52, 13346.77, 13347.52,
13348.52, 13348.77, 13349.27, 13350.77, 13351.27, 13350.52, 13349.02,
13348.77, 13348.52, 13350.27, 13350.52, 13351.27, 13352.02, 13353.77,
13353.52, 13353.02, 13353.27, 13353.02, 13352.77, 13350.77, 13351.02,
13351.27, 13351.02, 13351.27, 13351.52, 13351.05, 13351.52, 13352.02,
13352.52, 13353.77, 13353.52, 13352.77), nextdown = c(540L, 541L,
547L, 541L, 541L, 541L, 541L, 547L, 540L, 233L, 540L, 233L, 233L,
233L, 233L, 233L, 233L, 233L, 233L, 233L, 233L, 233L, 233L, 233L,
233L, 233L, 220L, 230L, 233L, 233L, 230L, 226L, 196L, 196L, 196L,
195L, 195L, 195L, 196L, 218L, 196L, 196L, 196L, 217L, 220L, 218L,
196L, 195L, 195L, 195L, 195L, 195L, 195L, 195L, 195L, 195L, 195L,
195L, 195L, 195L, 195L, 195L, 195L, 195L, 195L, 195L, 195L, 194L,
190L, 190L, 189L, 184L, 184L, 185L, 189L, 190L, 190L, 185L, 185L,
184L, 184L, 182L, 182L, 183L, 183L, 183L, 183L, 184L, 184L, 184L,
184L, 184L, 184L, 184L, 184L, 184L, 183L, 182L, 182L, 183L),
    dir = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, -1L, -1L, -1L, -1L,
    -1L, -1L, -1L, -1L, -1L, -1L, -1L, -1L, -1L, -1L, -1L, -1L,
    -1L, -1L, -1L, -1L, -1L, -1L, -1L, -1L, -1L, -1L, -1L, -1L,
    -1L, -1L, -1L, -1L), color = c("green", "green", "green",
    "green", "green", "green", "green", "green", "green", "green",
    "green", "green", "green", "green", "green", "green", "green",
    "green", "green", "green", "green", "green", "green", "green",
    "green", "green", "green", "green", "green", "green", "green",
    "green", "green", "green", "green", "green", "green", "green",
    "green", "green", "green", "green", "green", "green", "green",
    "green", "green", "green", "green", "green", "green", "green",
    "green", "green", "green", "green", "green", "green", "green",
    "green", "green", "green", "green", "green", "green", "green",
    "green", "green", "red", "red", "red", "red", "red", "red",
    "red", "red", "red", "red", "red", "red", "red", "red", "red",
    "red", "red", "red", "red", "red", "red", "red", "red", "red",
    "red", "red", "red", "red", "red", "red", "red", "red")), row.names = c(NA,
-100L), class = c("tbl_df", "tbl", "data.frame"), .internal.selfref = <pointer: 0x000001bc75c81ef0>)

Answer: An option could be that you duplicated the first row per group and that you make the first row of the latter group (dir = -1) make dir = 1, so that the first line connect to the start of the second line like this:
library(plotly)
library(reshape)
library(RColorBrewer)
library(dplyr)

big <- big %>%
  group_by(color) %>%
  slice(1L, row_number()) %>%
  mutate(dir = ifelse(row_number() == 1 & dir == -1, 1, dir)) %>%
  ungroup()

fig <- plot_ly(big[1:100,], y = ~price, x = ~time, type = 'scatter', mode = 'lines+markers', color = ~ as.factor(dir))%>%
  layout(legend=list(title=list(text='smoker')), title = "String 'smoker' values mean discrete colors",
         plot_bgcolor='#e5ecf6')
fig
#> Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
#> Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels

Created on 2022-08-17 by the reprex package (v2.0.1)
Comment: ah yes, manually connecting. do you think it possible to have a black line along a two-colored point series? I'll edit my question accordingly.

R - One line, two colors in plotly


Como percorrer um repositório Git?

Question: Quero testar algumas métricas de software e preciso percorrer um repositório git, mas preciso fazer isso utilizando os próprios comandos git, por exemplo, git log, git show...
Uma das métricas que quero saber é o número de linhas que tem em um projeto desconsiderando comentários, imports e etc. Para isso, preciso percorrer todas as classes do projeto.
Comment: Conforme [essa pergunta](https://stackoverflow.com/q/4822471/1452488), você consegue com `git ls-files | xargs cat | wc -l`, que é uma solução baseada nas ferramentas externas. Apenas com Git acho que não será possível.
Answer: Procure por softwares prontos que já vão te dar essas métricas:

Sonarqube Test Metrics
qTest Insights Test metrics

Outro ponto:
Procure por métricas que são utilizadas no dia de hoje:

Cycle time: How to Calculate Cycle Time
Code churn: A magical metric for software quality

Métricas como número de linhas, quantidade de commits, não são boas métricas, não vão te dizer muito sobre o código.
Comment: A ideia seria desenvolver um software de métricas, então não faz sentido procurar por software de métricas.
Comment: Seria interessante deixar a sua pergunta mais clara, edite-a e inclua essa informação, pois muda o cenário.
De qualquer maneira parte da resposta contém alguma métricas que podem te ajudar. E continua valendo o que eu disse na resposta, contar linhas não é uma boa métrica.

Como percorrer um repositório Git?


Vector Space of Polynomial Functions

Question: Suppose that $p_0, p_1, ..., p_m$ are polynomials in $P_m(F)$ such that $p_i(2)=0$ for each $i$. Prove that the set of vectors $p_0, ..., p_m$ is linearly dependent.
Note that $P_m(F)$ denotes the vector space of all polynomials of degree less than or equal to $m$.
Comment: Are the $m+1$ polynomials $0,0,0,\ldots,0$ linearly independent?
Answer:
Suppose that $p_0, p_1, ..., p_m$ are polynomials in $P_m(F)$ such that $p_i(2)=0$ for each $i$. Prove that the set of vectors $p_0, ..., p_m$ is linearly dependent.

If each $p_i(t)$ evaluates to $0$ at $t = 2$, why can you conclude that the $p_i$ must therefore be linearly dependent?:
For intuition: Try to construct linearly independent polynomials, say for $P_2(F)$, such that for each, $p_i(2) = 0$; and see why these polynomials cannot, in fact, be linearly independent.

Suppose there are $m+1$ linearly independent polynomials such that $p_i(2) = 0 \forall p_i$. Then $p_0 = 0$. Hence, e.g., 1 would necessarily be linearly independent of the $m+1$ $p_i$,  also in $P_m(F)$. That would give a basis of $P_m(F)$ that has $m+2$ linear independent vectors. Impossible!
Comment: You miss one $0$ to strictly fit the assumptions. Not that it matters much...
Comment: I think I corrected now...thanks, @julien
Answer: If $p_0,\dots,p_m$ were linearly independent and $p_i(2)=0$ for each $i$, then also $p_0,\dots,p_m,1$ would be linearly independent (see below for details). Hence you would have a base of $P_m$ with $m+2$ elements...
some more detail
Suppose:
$$
\lambda_0 p_0 + \dots + \lambda_m p_m + \lambda_{m+1} 1 = 0
$$
then evaluating each polinomial in $t=2$ we get
$$
0 + \dots + 0 + \lambda_{m+1} = 0
$$
hence $\lambda_{m+1}=0$.
So
$$
  \lambda_0 p_0 + \dots + \lambda_m p_m = 0
$$
which, by contradiction, we suppose that implies $\lambda_0 = 0, \dots, \lambda_m = 0$. Hence if $p_0,\dots,p_m$ are linearly independent also $p_0, \dots, p_m, 1$ would be linearly independent.
Comment: @julien: I don't understand your comment... I'm suggesting a proof by contradiction. To prove that $p_0,...,p_m,1$ are linearly independent you need to know that $p_i(2)=0$ for all $i$.
Comment: @julien: $p_0,...,p_m$ are supposed to satisfy the condition $p_i(2)=0$ see the details I have added.
Comment: Ah! Thanks for the clarification. Fun approach.

Vector Space of Polynomial Functions


If $f$ is integrable then $|f|$ is also integrable

Question: Show that if $f$ is integrable on $[a, b]$ then $\lvert f \rvert$ is also integrable. Hint: Show that
$$U (P , \lvert f \rvert) − L(P , \lvert f \rvert) ≤ U (P , f ) − L(P , f ).$$
I have:
$$U (P , \lvert f \rvert) \ge U (P , f )$$ and $$ L(P , \lvert f \rvert) \ge L(P,f)$$
Thus,
$$U (P , \lvert f \rvert) − L(P , \lvert f \rvert) ≤ U (P , f ) − L(P , f ).$$
Comment: Do you have any thoughts on this? Is this homework?
Comment: I think I proved the hint, but I do not really understand where to go from there
Comment: ¿What limit did you proved?.
Edit your question with the work you've done.
Comment: [related](http://math.stackexchange.com/a/84482/8271)
Answer: Consider a partition $$P=\{x_{0},x_{1},x_{2},\dots,x_{n}\} $$ of $[a, b] $ and for each $i=1,2,\dots,n$ let us use the notation $$M_{i}(f) =\sup\, \{f(x) \mid x\in[x_{i-1},x_{i}]\},\, m_{i}(f)=\inf\,\{f(x) \mid x\in[x_{i-1},x_{i}]\} $$ Then we have by definition $$U(P, f) =\sum_{i=1}^{n}M_{i}(f)(x_{i}-x_{i-1}),\,L(P,f)=\sum_{i=1}^{n}m_{i}(f)(x_{i}-x_{i-1})$$ and hence $$U(P, f) - L(P, f) =\sum_{i=1}^{n}(M_{i}(f)-m_{i}(f))(x_{i}-x_{i-1})$$ It is easy to prove that $$M_{i} (f) - m_{i} (f) =\sup\, \{|f(x) - f(y) | : x, y\in[x_{i-1},x_{i}]\} $$ Now by triangle inequality we know that $$||f(x) |-|f(y) ||\leq |f(x) - f(y) |$$ Therefore it follows that $$M_{i} (|f|) - m_{i} (|f|) \leq M_{i} (f) - m_{i}(f) $$ which leads to the desired inequality $$U(P, |f|) - L(P, |f|) \leq U(P, f) - L(P, f) $$ From this inequality and criterion for Riemann integrability it is almost obvious that if $f$ is Riemann integrable on $[a, b] $ then $|f|$ is also Riemann integrable on $[a, b] $.
Comment: Hello, how can I prove that $M_i(f)-m_i(f)=\sup...$? Thanks!
Comment: @TheCalc: well, first note that both $f(x), f(y) $ lie in the interval $[m_i(f) , M_i(f) ]$ and hence the difference between them does not exceed $M_i(f) - m_i(f) $. And thus $M_i(f) - m_i(f) $ is an upper bound for all numbers of the form $|f(x) - f(y) |$. To show that it is indeed the least upper bound we can take $\epsilon$ with $0<\epsilon <M_i(f) - m_i(f) $ and choose $x, y$ such that $M_i(f)-\epsilon /2<f(x)\leq M_i(f) $ and $m_i(f) \leq f(y) <m_i(f) +\epsilon /2$. Then $M_i(f) - m_i(f) - \epsilon<|f(x) - f(y) |<M_i(f) - m_i(f) $.
Comment: Thank you for your response! Why is $M-m$ is an upper bound for all numbers of the form $|f(x)-f(y)|$ and not just $f(x)-f(y)$?
Comment: And also, $M_i(f)-m_i(f)$ can be equal to zero, so $\epsilon \ge 0$ which is not good...
If for instance, $f$ is constant.
Comment: @TheCalc: if $c, d$ lie in interval $[a, b] $ can you prove that $|c-d|\leq b-a$? If not then draw these points on number line and try to prove again.
Comment: @TheCalc: if $M=m$ then $f$ is constant on that interval and the desired result holds.
Comment: Thank you, what desired result holds? The whole statement about $M_{|f|}-m_{|f|} \le M_f-m_f$?
Comment: @TheCalc: if $f$ is constant on that interval $[x_{i-1},x_i]$ then the result $M_i(f) - m_i(f) =\sup\, |f(x) - f(y) |$ holds because each side is $0$.
Answer: This answer shows that if $f$ and $g$ are Riemann integrable so is $h=\max\{f,g\}$. Use this with $g=-f$, then $h=|f|$.
Nota: In your post you "deduce" from $U (P , \lvert f \rvert) \geqslant U (P , f )$ and $ L(P , \lvert f \rvert) \geqslant L(P,f)$ that $U (P , \lvert f \rvert) − L(P , \lvert f \rvert) \leqslant U (P , f ) − L(P , f )$. This does not hold, in fact one can deduce no upper bound of $x-y$ from the hypothesis that $x\leqslant x'$ and $y\leqslant y'$. Instead one would need bounds such as $x\leqslant x'$ and $y\geqslant y'$, which indeed imply $x-y\leqslant x'-y'$.


Default values not working in multiple select options

Question: I have a form with  multiple select options.Other things are working fine. But when I revisit the form I have to select everything again. I have given:
'#default_value' = previously selected array()
But that is not working I guess. Is there any method that the user can add in the selected list without need to select everything again ?
Thank you .
Answer: check it out - http://drupal.org/node/73077


Angular2 SEO - How to make an angular 2 app crawlable

Question: I am building an Angular 2 app using the Angular-Meteor framework.
I would like to achieve fast and consistent indexing by google and other search engines, and allow Facebook sharer and other scrapers to generate previews of my JS-generated content.
Usually SPAs use the  PhantomJS to render the page server-side and send the static HTML to the client.
Of course I can spawn PhantomJS myself when I intercept an _escaped_fragment_ or when I see the google or scraper user agent, but I always experienced memory leaks and orphan Phantom instances when spawning PhantomJS directly on websites with a big traffic (I used NodeJS and this module ).
For Angular 1 apps, I used to solve this with angular modules like Angular-SEO, but it seems hard to convert such module to angular 2.
I did not find any appropriate Angular 2 module for this yet. Should I build it myself, or is there any other good way to achieve this as of today ?
Answer: The great thing about Angular2 is that when fired up, all content inside your root app-element goes away. This means that you can put whatever you want in there from the server which you want to be picked up by crawlers.
You can generate this content by using a server-rendered version of the content in your app, or have custom logic.
You can find some more information here: https://angularu.com/VideoSession/2015sf/angular-2-server-rendering
and here: https://github.com/angular/universal
Comment: great video, clever SEO, better than phantom approach
Comment: This answer is now deprecated with newer versions of Angular as it is a part of @angular/platform-server
Answer: I just created ng2-meta, an Angular2 module that can change meta tags based on the current route.

const routes: Routes = [
  {
    path: 'home',
    component: HomeComponent,
    data: {
      meta: {
        title: 'Home page',
        description: 'Description of the home page'
      }
    }
  },
  {
    path: 'dashboard',
    component: DashboardComponent,
    data: {
      meta: {
        title: 'Dashboard',
        description: 'Description of the dashboard page',
        'og:image': 'http://example.com/dashboard-image.png'
      }
    }
  }
];

You can update meta tags from components, services etc as well.

class ProductComponent {
  ...
  constructor(private metaService: MetaService) {}

  ngOnInit() {
    this.product = //HTTP GET for product in catalogue
    metaService.setTitle('Product page for '+this.product.name);
    metaService.setTag('og:image',this.product.imageURL);
  }
}

While this caters to Javascript-enabled crawlers (like Google), you can set fallback meta tags for non-Javascript crawlers like Facebook and Twitter.

    <meta name="title" content="Website Name">
    <meta name="og:title" content="Website Name">
    <meta name="og:image" content="http://example.com/fallback-image.png">
    ...

Support for server-side rendering is in progress.
Comment: This doesn't seem to work with Angular Universal, where the page gets generated server side. 'document.querySelector is not defined'
Comment: I use ng2meta plugin and it doesn't seem like webmaster tools / google crawls it. It still thinks I have duplicate meta tags e.g. For Description. Any ideas?
Answer: Serverside rendering is not a requirement for a decent google ranking ...
I had a forum with about 33.000 entries in its google sitemap files. This website was written using asp.net webforms, and had a decent stream of incoming requests from google. This website did have very bad mobile readability (something that is penalized by google, it actually mentioned this in my google "search console")
I rewrote everything with angular (deployed version is angular5). I am using the Title and Meta services to set my title and meta tags. All routes contain keywords extracted from the actual content. I also made sure that every element with a [routeLink] attribute was an A tag on which i also specified the href element (that is what a crawler looks for ...) And of course i paid a lot of attention to mobile readability.
Result: i actually get more incoming traffic than before, and in the search console i clearly see that my indexed pages went up: of the 30k+ pages, only about 10K were included in the index. Now i have almost 25k pages in the index.
I am not saying that serverside rendering is irrelevant. Using universal or other methods will result in faster download times, which will probably lead to a higher score. But google is definitely able to properly index an angular SPA.
edit: some proof: if you google "3ds max threadripper", you'll see that it actually outranks one of the biggest hardware sites on the internet.


What is this trumpet attachment called?

Question: Last night, I was watching a television special featuring American music. I noticed that a trumpet player in the band had something attached to her instrument. It appears that the valves of the trumpet are extended far below where they would normally end.

What is the name of this attachment and what is its function?
EDIT:
I was able to find a much clearer picture:

The black sleeve around her arm leads me to believe that it is merely an accessibility device.
Comment: It isn't a flugel.  Best theory seems to be that the girl's got something wrong with her hand or arm.  An extension, screwed in place of the bottom valve cap, seems an excellent way of arranging a prosthetic device.  You need two, to give torque.  Three would be unnecessary,
Comment: Who's the player? If you don't know, who's the band? (Might be able to find other images.)
Comment: There are trumpet attachments available to improve ergonomics, and valve weight systems that extend downward, but none to this extreme. It's safe to surmise that she's recovering from a broken arm or other such injury, and being very careful to not strain herself. In fact, why don't you find the source of the photo and email her (or her conductor)?
Comment: @EverettSteed: that would make a fine answer. Her sleeve suggests she suffers some kind of injury. No need to be a broken arm, though, it could be strain from holding a trumpet several hours a day every day.
Comment: I never heard of an attachment to the valves. The instrument looks like a plain-vanilla [Flugelhorn](https://en.wikipedia.org/wiki/Flugelhorn) with piston valves to me.
Comment: fascinating.  never thought it would be for accessibility (if she had one artificial limb) but it makes sense.  Doesn't seem like such an addition would make much difference to the timbre, perhaps adding some more robust lower tones as the resonant body has more volume.
Comment: The "resonant body" is predominantly the air column within the instrument's tubing.  It won't pass through these extensions to the valve casings.  I think we can safely rate the sonic effect at zero.
Comment: @LaurencePayne- yep.  If we think about how trumpet valves work, we realize that the only acoustic length the vertical tubes add is their diameter, not their length- they are just shunts between the different lengths of horizontal tubing.  It's obviously a handle, not an acoustic part of the instrument.
Answer: From the description it sounds as if it is a fluid cup on the bottom of the valves.  It would be there to prevent oil and saliva that would normally come out the bottom of the valves from dropping onto the floor.  Purpose is for sanitary reasons.
Comment: Further, there's no such liquid (salive/water) coming from the bottom of the valves. It'd be oil. And given the volume of the thing shown in the picture, that'd be a LOT of oil.
Comment: Note that the liquid that you remove from brass instruments with the water key is more water from the player's breath that condensed in contact with the tubing, rather than saliva. Sure, there's saliva in the mix as well, but it's mostly water. Or so I wish to believe ;)

What is this trumpet attachment called?


Constructing group extensions in GAP.

Question: I have the following general question: Given two finite groups $N$ and $H$, how can we find, using GAP, all the groups $G$ (up to an isomorphism, of course) such that
$$1 \rightarrow N \rightarrow G \rightarrow H \rightarrow 1$$ is a short exact sequence? For splitting sequences, I know how to solve the problem (computing semidirect products), but I have no idea how to construct non-splitting sequences.
Comment: There is code in the development version that will make it into GAP 4.11 (function `TwoCohomologyGeneric`) for doing exactly this (for elementary abelian $N$). At this point you would have to install the development version from github, it is not really possible to extract the code for an older release. If you have a single example let me know and I can run the code for you.
Comment: why is finite in parentheses? are they finite or not? if they are, say it very explicitly
Comment: [This](https://www.gap-system.org/Manuals/doc/ref/chap46.html#X877AAB887D4507E3) is the closest I could find in the GAP manual.
Comment: Unfortunately, the method for Pc groups is working only if $N$ is Abelian... and I want to construct examples in the general case.
Comment: I'm interested in a case when $N$ is not abelian...
Comment: If $N$ is not abelian, you can split it into elementary layers. Solvable ones will come from cohomology, non-solvable ones basically mean you have a larger nonsolvable factor group with a nice structure as subgroup of the automorphism group of the layer.
Comment: @Mircea Do you have a particular example of $N$ and $H$ in mind?
Comment: I have in mind the case: $N$ is solvable and $H$ is a p-group with $p\nmid |N|$.
Comment: @ahulpke So you could, say, use this to construct the extensions with kernel SmallGroup(32,17) and quotient group $\mathbb{Z}_8^2$ (two copies of the cyclic group of order 8)?
Comment: @zibadawatimmy  Yes. You would find a characteristic series for the normal subgroup and iteratively form extensions using cohomology.
Answer: Your comments indicate that you are interested in a case of $\gcd(|N|,|H|)=1$. In this situation (due to the Schur/Zassenhaus theorem) any extension is a semidirect product.
You can classify such extensions by computing the AutomorphismGroup of $N$ and computing (classes of) homomorphisms from $H$ to $\mbox{Aut}(N)$: E.g.
gap> N:=AbelianGroup([5,5,5]);
<pc group of size 125 with 3 generators>
gap> H:=SymmetricGroup(4);;
gap> au:=AutomorphismGroup(N);
<group with 4 generators>
gap> homs:=AllHomomorphismClasses(H,au);
[ [ (1,3,2), (3,4) ] -> [ [ f1, f2, f3 ] -> [ f1, f2, f3 ],
      [ f1, f2, f3 ] -> [ f1, f2, f3 ] ], [...]o
gap> ext:=List(homs,x->SemidirectProduct(H,x,N));
[ <pc group of size 3000 with 7 generators>,
  <pc group of size 3000 with 7 generators>,
  <pc group of size 3000 with 7 generators>,
  <pc group of size 3000 with 7 generators>,
  <pc group of size 3000 with 7 generators>,
  <pc group of size 3000 with 7 generators>,
  <pc group of size 3000 with 7 generators>,
  <pc group of size 3000 with 7 generators> ]
gap> List(ext,x->Length(ConjugacyClasses(x))); # show they are non-isomorphic
[ 625, 253, 325, 265, 38, 165, 26, 105 ]

Constructing group extensions in GAP.


Lebesgue measurable subsets of [0,1]

Question: If $A$ is a Lebesgue measurable subset of $[0,1]$ such that $\lambda(A)>0$. Show that there are Lebesgue measurable subsets $A_{s},0\leq s \leq \lambda (A)$, so that
(a) $A_{r}\subseteq A_{s}$ if $r\leq s$,
(b) $\lambda (A_{s})=s$ for any $0 \leq s \leq \lambda (A)$
Here is what I have at the moment...
I considered $A_{s}=A \cap [0,s]$, then part (a) is quite easy to verify.
But I only have (b) if $[0,s]\subseteq A$. My construction of the set $A_{s}$ doesn't work in general. The set $A$ can be like for example $A=[0.5,1]$, then for any $s \leq \lambda(A)=0.5$, then I have $\lambda (A_{s})=0$.
I don't quite understand the $s$ in the subscript of $A$. Have I misunderstood the problem? Or I should construct another $A_{s}$?
Thanks
Comment: Seeing as your $A_s$ doesn't work, I think you should construct another $A_s.$
Comment: Nothing about your construction uses the measurability of $A$. I think you should think more about what it means for $A$ to be measurable
Comment: You're indexing the sets by real numbers, so we'll have $2^{\aleph_0}$ sets. Intuitively it seems to me that since $0\leq s/\lambda(A)\leq 1$, we're trying to chop $100s/\lambda(A)$ percent of $A$' measure, like a progress bar. No idea of how to do that so far, though.
Comment: The difficulty is that we don't know how is the measure "distributed" around $A$ (Lebesgue measurable sets can be quite crappy)
Comment: I used the fact that $A$ is measurable in my construction of $A_{s}$ because it is required to be measurable. Since $A_{s}=A \cap [0,s]$ and $A$ is measurable and $[0,s]$ is measurable and intersection of measurable sets is measurable, $A_{s}$ is measurable.
Answer: The function $f:[0,1]\to [0,\lambda(A)]$ defined by $f(x) = \lambda([0,x]\cap A)$ is continuous and nondecreasing. We have $f(0) = 0, f(1) = \lambda (A).$ By the intermediate value theorem, $f$ takes on every value in $[0,\lambda(A)].$ Thus for each $s\in [0,\lambda(a)],$ the set $f^{-1}(\{s\})$ is nonempty. And by continuity, $f^{-1}(\{s\})$ is compact. For each $s\in [0,\lambda(a)],$ we can define $x_s= \inf f^{-1}(\{s\}).$ (That way we avoid the axiom of choice.) Then $A_s= [0,x_s]\cap A$ solves your problem.
Comment: Yes. $f$ is nondecreasing implies (a) but how about (b)? How does this help for the requirement in (b)?
Comment: @LanaDR By surjectivity, for all $s \in [0, \lambda(A)]$ you can choose $x \in [0,1]$ so that $\lambda([0,x] \cap A)=s$.
Comment: @leibnewtz I see. I guess I misinterpret the question. Correct me if I am wrong, so you mean like (b) is the requirement that we got to have the "onto" right?
Comment: @LanaDR I changed my hint to a more complete answer.
Comment: @zhw. By the way, using the fact that the infimum of $f^{-1}(s)$ exists assumes the axiom of choice, I'm pretty sure. There's hardly ever a way to avoid it
Comment: @leibnewtz Not that I can see. The reals with the completeness property don't need AOC for its construction.

Lebesgue measurable subsets of [0,1]


Rudin exercise 2.18: perfect set with only irrational numbers.

Question: I am trying to solve exercise number 2.18 in Rudin. The question is the following:
"Is there a nonempty perfect set in R1 that contains no rational numbers"?
My solution is basically to construct a set E that contains all irrational (to be more specific: non-rational) numbers between sqrt(2) and sqrt(3), both included. And then the proof that this is perfect proceeds similarly to question 2.17 (since every irrational number can be written as a series of infinite decimals with no repeats).
Am I missing something? I don't see why I should construct a set similar to the cantor set. Thank you for your help.
Comment: Yes,  to be  perfect requires closed.
Comment: The set of all irrational numbers is not closed. Any rational number has a sequence of irrationals converging to that rational. So if you just remove all the rationals, what you will have can't be perfect.
Comment: In 2.17 how did you prove the set of numbers containing only 4 and 7 in its decimal expansion was closed?  Every other point *must* have a neighborhood containing no such point.  But that isn't so with the set of rationals.  In contrast Every neighborhood of a rational number *must* contain irrational points.  That's the *exact* opposite.
Comment: Fwiw I "cheated" when I first did the question.  I took the set E in 2.17 and shifted it by an irrational number containing only 0s and 1s.  Thus the new set contains numbers with only 4s,7s,5, and 8s, be never in a repeating periodic cycle so no rationals.  But, that really avoids learning anything.
Comment: Thank you all. My confusion is that I forgot there are rational numbers within the interval on the real axis, and yes obviously every neighborhood of such rational numbers would have to contain an irrational number.
Comment: The irrationals are homoemorphic to $\mathbb{N}^\mathbb{N}$ so contains lots of copies of $\{0,1\}^\mathbb{N}$, i.e. Cantor sets.
Answer: It's not really Rudin's style, but there are lots of general topological arguments based on the topological structure of the irrationals and the Cantor set, to see that such a set exists.
One way is to prove that the Cantor set is unique topologically: if $X$ is a compact, totally disconnected (i.e. no connected subset has more than one point), metric space without isolated points, then $X$ is homeomorphic to the standard "middle third" Cantor set $C \subset [0,1]$. Such an $X$ is also called "a Cantor set". They're clearly perfect if embedded in $\mathbb{R}$ (being compact $X$ will be a closed subset and it has no isolated points).
This is a nice topological argument (not using decimal expansions etc.) to see that $\{0,1\}^\mathbb{N} \simeq C$, and also $\prod_n F_n \simeq C$, where all $F_n$ are finite discrete spaces.
It also implies that $C \times C \simeq C$: if $X$ is a Cantor set, so is $X \times X$: still compact metric; still totally disconnected (if $A \subseteq X \times X$ is connected, so are $\pi_1[A]$ and $\pi_2[A]$, so these are singletons and hence so is $A$) and still no isolated points, (if $\{(x,y)\}$ were open, so would $\pi_1[\{(x,y)\}] = \{x\}$ be, which is false, etc.).
So the characterisation says that $C \times C \simeq C$.
We can also reach the same conclusion if you already know that $C \simeq \{0,1\}^\mathbb{N}$ without the characterisation (Using the ternary expansion argument) because it' s clear that $\{0,1\}^I \times \{0,1\}^J \simeq \{0,1\}^{I \cup J}$ (disjoint union), and $\{0,1\}^I$ is just homeomorpic to $\{0,1\}^\mathbb{N}$ whenever $I$ is countably infinite (powers only depend on the cardinality of the index set).
So once you have convinced yourself that $C \times C \simeq C$, it's easy: Clearly $\{x\} \times C \simeq C$ (for $x \in C$ as a subspace of $C \times C$), so the product shows us that a Cantor set is an uncountable disjoint union of homeomorphic copies of the Cantor set. As subsets of $\mathbb{R}$, only countably many of these disjoint copies can contain any rational number. So uncountably many consist of irartional numbers only. And such a Cantor set is what's wanted.


Horizontal scroll bar scrolling three items per scroll

Question: How can i have a horizontal scroll bar below my columns where i can scroll three columns/per scroll left/right. I have such six columns in a page horinzontally...

       Fixed Header

How can i create a horizontal scroll bar below my columns to scroll left/right?.
Below is my fiddle.
http://www.bootply.com/YzGHOJlaWM
Comment: So you want to scroll (both by controlling scrollbar & mousewheel) horizontally with fixed intervals (3 cols per scroll) right? I found a great script for that a while ago, i think it's on my external hard drive somewhere, I'll put up an answer in an hour or so if I (hopefully) find it.
Answer: on your div class which contains the three divs, apply the following css:

You may need to make the width of the container larger than the window so that the overflow is registered as overflow.


Why do these parenthesis move when trying to find a vertex form?

Question: Can someone explain to me why when expanding this vertex form equation does the $ah^2$ term get included with the $+k$ part?
As far as I can see it's a product of expanding the $a(x-h)^2$ part.

I can only presume it's to keep the form $ax^2+bx+c$.
tvm
Comment: Your presumption is correct. The next step is probably to derive formulas for h and k in terms of a, b and c by comparing coefficients.
Answer: You're correct, $(ah^2+k)$ is just a constant, so we slap it into the position of $c$!