YouTube-Dl reject multiple titles - youtube-dl

Super super quick question, A or B answer.
I have YouTube-dl setup on my Linux machine, and have a huge list of URLS to download so it would take me weeks to find out the answer to this question.
To reject multiple titles which of the following do I do?
A
--reject-title "title1" "title2" "title3"
OR
B
--reject-title "title1" --reject-title "title2" --reject-title "title3"

Neither.
--reject-title x y z rejects title x and downloads URLs y and z.
--reject-title x --reject-title y --reject-title z rejects title x, no, wait, y, no, wait z (in effect the same as --reject-title z).
You want a regular expression --reject-title "x|y|z".

Related

Inside an enumerate enviroment have 2 columns, one of equations and one for text in latex

I have this problem:
\begin{center}
\begin{minipage}{2in}
\begin{enumerate}[{1)}]
\item $p \lor \neg q$ Agregacion
\item $q \ent p$ Equivalenica
\end{enumerate}
\end{minipage}
\end{center}
I want that the text in every item (not the math part) aligned with the text from above .
Like a list, where I can said what rule I applied with text.
Like if every item have "2 columns" the left one for the equation and the right one for a kind of explanation.
If I understood correctly, you would like to have an enumerate list with two columns: math expressions and texts.
Since you already have the list, I would customise it via enumitem and then enclose equations inside makebox to make sure equations span the same space (basically the same approach as samcarter_is_at_topanswers.xyz's but with slightly expanded example). The most involved part is a set of list parameters; it keeps text within a column should it span multiple lines.
This approach will fail if you have a more complex equations, though
\documentclass{article}
\usepackage{amsmath}
\usepackage{enumitem}
\newlength\firstcollen % Controls first column length
\AtBeginDocument{\setlength\firstcollen{0.3\textwidth}}
\usepackage{kantlipsum} % Just for dummy text
\newcommand\itemmath[1]{\item%
\parbox[t]{\firstcollen}{\ensuremath{#1}}%
\ignorespaces}
\begin{document}
\begin{enumerate}[
label=\arabic{enumi}),
labelwidth=2.5em,
labelsep=0.5em,
labelwidth=2em,
leftmargin=\dimexpr+\firstcollen+2.5em,
itemindent=-\firstcollen,
% listparindent=\parindent, parsep=0pt, % Simulates paragraphs
listparindent=0pt, parsep=3pt, % No indentation, small separation
align=left,
]
\itemmath{y = f(x)}Short equation
\itemmath{r^2 = \cos^2 x + \sin^2 x} A trigonometric identity
\itemmath{\int_{a}^{b}\frac{1}{2}f(x)dx} \kant*[1][1]
\itemmath{y = f(x)} Short equation
\itemmath{r^2 = \cos^2 x + \sin^2 x} \kant[3][1]\kant[3][2]\kant[3][3]
\itemmath{b = \int_{c}^{d}\frac{3}{4}g(x)dx} Short text
\itemmath{\int_{a}^{b}\frac{1}{2}f(x)dx} \kant[1][1-5]\kant[2]
\end{enumerate}
\end{document}
You could use \makebox to ensure that all your equations have the same width:
\documentclass{article}
\usepackage{mathtools}
\usepackage{enumerate}
\begin{document}
\begin{center}
\begin{minipage}{2in}
\begin{enumerate}[{1)}]
\item \makebox[2cm][l]{$p \lor \neg q$} Agregacion
\item \makebox[2cm][l]{$q p$} Equivalenica
\end{enumerate}
\end{minipage}
\end{center}
\end{document}

Combining similar part of a string using Google Sheets functions

Please help me solve this problem. I'm trying to search all similar part of a string combine them then add all their numeric value at the beginning part of the string.
Input: cell A1
2 x Onsemi 3000K E27; 7 x Onsemi 3000K E27; 9 x Phoenix Eco 7W 4000K B22; 1 x Phoenix Eco 7W 4000K B22
Output: cell B1
9 x Onsemi 3000K E27; 10 x Phoenix Eco 7W 4000K B22
Tried using google match function but struggling on how to combine them then add the quantity.
Your help is highly appreciated.
=ARRAYFORMULA(TEXTJOIN("; ", 1, TRANSPOSE(QUERY(TRANSPOSE(QUERY({
REGEXEXTRACT(TRANSPOSE(SPLIT(A1, ";")), "(\d+)")*1,
REGEXEXTRACT(TRANSPOSE(SPLIT(A1, ";")), "\d+ (.*)")},
"select sum(Col1),Col2
group by Col2
label sum(Col1)''", 0)),,999^99))))

MHD Shock Waves

I need to solve these six equations (https://en.wikipedia.org/wiki/Shocks_and_discontinuities_(magnetohydrodynamics)) for MHD shock waves condition using scipy.fsolve. There are 6 unknown variables whose values need to be stored in the array z. While I am getting correct answers for some cases, in most cases the values are wrong. They vary according to the initial guess, what would be the correct initial guess so that it works for all cases.
Note- z[0] and z[1] denote pressure and density and can't be negative. So a correct answer will give positive values.
from scipy.optimize import fsolve, root
from scipy.constants import mu_0 as w
print("Assume the shock propogates in the x direction")
p1=float(input("Upstream pressure-"))
rho1=float(input("Upstream density-"))
vx1=float(input("Upstream velocity along x axis-"))
vy1=float(input("Upstream velocity along y axis-"))
bx1=float(input("Upstream magnetic field along x axis-"))
by1=float(input("Upstream magnetic field along y axis-"))
def eqn(x): #jump conditions
f1=(x[1]*x[2])-(rho1*vx1)
f2=x[0]+(x[1]*x[2]*x[2])+(x[5]*x[5]*0.5/w)-p1-(rho1*vx1*vx1)-by1*by1*0.5/w
f3=(x[1]*x[2]*x[3]-x[4]*x[5]/w)-rho1*vx1*vy1+bx1*by1/w
f4= x[4]-bx1
f5=x[2]*x[5]-x[4]*x[3]-vx1*by1+vy1*bx1
f6=x[1]*x[2]*(0.5*(x[2]**2+x[3]**2) +2.5*x[0]/x[1]) +x[2]*(x[5]**2)/w -x[4]*x[5]*x[3]/w - rho1*vx1*(0.5*(vx1**2+vy1**2) +2.5*p1/rho1) -(vx1*by1**2)/w + bx1*by1*vy1/w
return(f1,f2,f3,f4,f5,f6)
y=[2*p1,4*rho1,0.5,0.5,bx1*2,by1*2] #initial guess value
z=fsolve(eqn,y)
print '\n','Upstream Pressure- ',p1,'\t'*3,'Downstream Pressure- ',z[0]
print 'Upstream Density- ',rho1,'\t'*4,'Downstream Density- ',z[1]
print 'Upstream velocity along x axis- ',vx1,'\t'*2,'Downstream velocity along x axis- ',z[2]
print 'Upstream velocity along y axis- ',vy1,'\t'*2,'Downstream velocity along y axis- ',z[3]
print 'Upstream magnetic field along x axis- ',bx1,'\t','Downstream magnetic field along x axis- ',z[4]
print 'Upstream magnetic field along y axis- ',by1,'\t','Downstream magnetic field along y axis- ',z[5]

Filling in data frame column using regular expressions (?)

Ok, so I have a data frame of web forum comments. Each row has a cell containing an ID which is part of the link to that comment's parent comment. The rows contain the full permalink to the comment, of which the ID is the varying part.
I'd like to add a column that shows the user name attached to that parent comment. I'm assuming I'll need to use some regular expression function, which I find mystifying at this point.
In workflow terms, I need to find the row whose URL contains the parent comment ID, grab the user name from that row. Here's a toy example:
toy <- rbind(c("yes?", "john", "www.website.com/4908", "3214", NA), c("don't think so", "mary", "www.website.com/3958", "4908", NA))
toy <- as.data.frame(toy)
colnames(toy) <- c("comment", "user", "URL", "parent", "parent_user")
comment user URL parent parent_user
1 yes? john www.website.com/4908 3214 <NA>
2 don't think so mary www.website.com/3958 4908 <NA>
which needs to become:
comment user URL parent parent_user
1 yes? john www.website.com/4908 3214 <NA>
2 don't think so mary www.website.com/3958 4908 john
Some values in this column will be NA, since they're top level comments. So something like,
dataframe$parent_user <- dataframe['the row where parent
ID i is found in the URL column', 'the user name column in that row']
Thanks!!
Another option, using the basename function from base R, which "removes all of the path up to and including the last path separator (if any)"
toy$user[match(toy$parent, basename(as.character(toy$URL)))]
#1] <NA> john
#Levels: john mary
Here is a vectorized option with stri_extract and match
library(stringi)
toy$parent_user <- toy$user[match(toy$parent,stri_extract(toy$URL,
regex=paste(toy$parent, collapse="|")))]
toy
# comment user URL parent parent_user
#1 yes? john www.website.com/4908 3214 <NA>
#2 don't think so mary www.website.com/3958 4908 john
Or as #jazzurro mentioned, a faster option would be using stri_extract with data.table and fmatch
library(data.table)
library(fastmatch)
setDT(toy)[, parent_user := user[fmatch(parent,
stri_extract_last_regex(str=URL, pattern = "\\d+"))]]
Or a base R option would be
with(toy, user[match(parent, sub("\\D+", "", URL))])
#[1] <NA> john
#Levels: john mary
nchar('with(toy, user[match(parent, sub("\\D+", "", URL))])')
#[1] 51
nchar('toy$user[match(toy$parent, basename(as.character(toy$URL)))]')
#[1] 60
Perhaps not the prettiest way to do it, but an option:
toy$parent_user <- sapply(toy$parent,
function(x){p <- toy[x == sub('[^0-9]*', '', toy$URL), 'user'];
ifelse(length(p) > 0, as.character(p), NA)})
toy
# comment user URL parent parent_user
# 1 yes? john www.website.com/4908 3214 <NA>
# 2 don't think so mary www.website.com/3958 4908 john
The second line is really just to deal with cases lacking matches.

Scatterplot in Matplotlib with its natural line

While joining the points given by scatterplot in matplotlib, I only want to get the natural fit, and not x-y , which becomes a zig-zag as shown below.
How can I do this in matpotlib ?
PS: I don't want fitting polynomial/regression line, just the regular natural line
from pylab import *
import matplotlib.pyplot as plt
//Generate some x-y data for yourself...
x=[key for key in my_dict.keys()]
y=[imp for imp in my_dict.values()]
xlim([min(x),max(x)])
ylim([min(y),max(y)])
plt.scatter(x,y)
I get :
On doing basic plot along with this, I get connected, but overlapping lines
plt.plot(x, y, '-o')
plt.show()
What I would like to have:
Related q/a but doesn't exactly fit my case
Fallback Alternatives - Fit a n-th degrees polynomial as here -
Multivariate (polynomial) best fit curve in python?
Edit :- I tried the code below as suggested
[x, y] = zip(*sorted(zip(x, y), key=lambda x: x[0])) ###
plt.plot(x, y, '-o')
here's what I now get, butI am looking for something more smoother.
In order for plt.plot(x, y, '-o') to work, you will need to sort your data in x so that the line doesn't appear disjointed. You can do that with something like this:
[x, y] = zip(*sorted(zip(x, y), key=lambda x: x[0]))
That will sort both data, with x as the key.