## find, replace and swap position of the line

I have config.yml file which has the lines like below.

``````- uri: "https://localhost1/status"
name: "INST1"

- uri: "https://loclahost2/status"
name: "INST2"

- uri: "https://localhost3/status"
name: "INST3"
``````

I need to change these config entry’s like below..

``````- Displayname: "INST1"
uri: "https://localhost1/status"

- Displayname: "INST2"
uri: "https://loclahost2/status"

- Displayname: "INST3"
uri: "https://localhost3/status"
``````

## real analysis – Properties of tangent line at a point of a differentiable curve \$y=f(x)\$ on \$[0,1]\$

Let a function $$mathrm{P}:(0,1)rightarrow mathbb{R}$$ be differentiable in (0,1) and continuous at 0 and $$1 .$$ Define a map $$mathrm{H}: mathbb{R}rightarrow mathbb{R}$$ by $$mathrm{H}(x)=mathrm{P}(0)+(mathrm{P}(1)-mathrm{P}(0))x .$$ Show that for every $$mathrm{r}>1$$ there exist a point $$mathrm{c}$$ in (0,1) such that the tangent line to $$mathrm{y}=mathrm{P}(x)$$ at point $$(mathrm{c}, mathrm{P}(mathrm{c}))$$
passes through the point $$(r, H(r))$$

How to say that for any $$r>1$$ there is a line $$y=P'(c)x+(P(c)-cP'(c))$$for some $$cin (0,1)$$ satisfies $$(r,H(r))$$

## bash – Command line argument to “find” and “grep” data inside “xattr -l” atrributes?

I have a file that an application has set extended attributes for.

``````\$ xattr -l /Volumes/Educating Rita (1983)/Educating Rita (1983).1.eng.srt
net.filebot.filename: 3_English.srt
``````

I have tried a few different ways to get the value of `@type` inside the attribute but haven’t found a way to search multiple files and grep for and return that value.

``````xattr -l /Volumes/PlexMedia/PlexServer_1/Movies/Educating Rita (1983)/Educating Rita (1983).1.eng.srt | grep @type
``````

I want to find every .srt file and `grep` for the value of `@type`. In this files’ case it would return “Movie”.

``````\$ find . -iname "*.srt" | while read -r file; do `xattr -l "\$file" | grep  "Type" >> /Users/john/Desktop/filebotmeta1.txt` ; done
``````

this gives me a text document with this:

``````net.filebot.metadata: {"@type":"Movie","year":1983,"imdbId":85478,"tmdbId":38291,"language":"en","id":38291,"name":"Educating Rita","aliasNames":()}
``````

But I just want to return the value for `@type` not the entire contents of the attribute.

I have looked into `ls -l@` but it only shows the attribute and not its contents

I looked into `mdls` but it does’t show the metadata for the attribute only for the file itself.

I am not sure `getxattr` or `listxattr` apply to the command line. They seem to be for internal use only.

I imagine this involves outputting to a .tmp file and then grepping the contents of the file? Or, is there a one line argument I can use to print results in Terminal?

The contents look like `json` format.

## applied mathematics – Need “weights” that add to 1 and form a line: y = 0.2x + b and y1+y2+y3+y4+y5+y6 = 1

How can I generate “weights” for a weighted average that are straight line (not Exponential). For example, I have 6 months of data and I want to “weight” the most recent months higher than 6 month ago.

Wouldn’t I be solving for this (assuming I want a slope of 0.2)??

y = 0.2x + b

y1+y2+y3+y4+y5+y6 = 1

I appreciate any insight on this.

## Is there an R function or a simple line of code to divide a column?

I’m having difficulty dividing a column by 100

The code i’ve tried is;
NW_FRB_H15\$`Return_T-bill`/100

dividing the federal reserve bonds treasury bill column by 100.

All that pops up is errors

## c# – String line limiter

My experience is more general architecture and software design not code snippets like this. See any improvement to my code?

``````var message = @"This is a test message
012345678901234567890123";

var output = Split(message, 20);
``````

output

``````"This is a test",
"message",
"01234567890123456789",
"0123"
``````

Max length of a line is 20 chars and it does not split words if not needed

code:

``````private IEnumerable<string> Split(string text, int maxLength)
{
var n = 'n';
var whiteSpaces = new HashSet<char> { ' ', 't', n };
text = text.Replace(Environment.NewLine, n.ToString());
if (!text.EndsWith(n)) text += n;

var whiteSpaceIndices = text
.Select((c, i) => (i, c))
.Where(t => whiteSpaces.Contains(t.c))
.ToList();

var index = 0;
var line = string.Empty;

char? last = null;

foreach (var white in whiteSpaceIndices)
{

do
{
var wordLength = white.i - index;
var wordTrimmed = text.Substring(index, Math.Min(maxLength, wordLength));
var wordWasTrimmed = wordLength > maxLength;
var trimmedTotalLength = wordTrimmed.Length + (wordWasTrimmed ? 0 : 1);

if (line.Length + trimmedTotalLength > maxLength || last == n)
{
if (line != string.Empty)
yield return line;

last = null;
line = string.Empty;
}

line += last;
line += wordTrimmed;
index += trimmedTotalLength;

} while (index < white.i);

last = white.c;
}

if (line != string.Empty)
yield return line;
}
``````

https://dotnetfiddle.net/gpT5UY

## terminal – Command Line iMessages Text Bank

I’m trying to find a good script for a text bank – basically so that I can plug in a script (i.e. Hello {name}, how are you today?) and a list of names and phones (Bob 3922949193, Joe 1939294924, Dan 4829438293) and have the command line automatically text a list of people for me. I found a script to text individual people, but it can’t send texts to multiple people separately, nor can it automatically plug in variables (names) into the script.

Is there any way to do this? Thanks!

## database – Magento v1.9 cmd line sql query to find certain scenarios backorder out of stock

I have a real odd issue
Magento v1.9.4.5

I have a ton like thousands of products that are set to back order allowed

However they also say out of stock

I need help I not sql expert

I need a sql query that i can run via cmd line ssh sql that will list all products which backorder are enabled

Then another to list those which backorder enabled and are out of stock

Then Lastly to prove fix one that list backorder enabled and are in stock :]

Thanks

## electrum get transaction amount command line

``````gettransaction('TXID')
deserialize('Serialized Hex')``````

Example output for second command:

``````{
"inputs": (
{
"coinbase": false,
"nsequence": 4294967293,
"prevout_hash": "c12ed68e512aa68dbf88878902efba20446024b645f5254f4b9411db2c6e684c",
"prevout_n": 0,
"scriptSig": "",
}
),
"locktime": 1807798,
"outputs": (
{
"scriptpubkey": "a914040d887b939576a6718c2da094999075f59d54fc87",
"value_sats": 1000000
},
{
"scriptpubkey": "0014bfa78def114fc3a0a7100098d984b9f9fdf51da7",
"value_sats": 1699000
}
),
"version": 2
}``````

## installing – Why is drush dl removed and how to use composer properly to download modules via the command line now?

Drush dl was removed because it served no more purpose (it was supplanted by composer)

The way to add dependencies to composer is with ‘composer require ’

So to require a specific module like group would be ‘composer require drupal/group’

To add version constraints you specify then after to name with a ‘:’ in between. The Drupal projects pages and getcomposer.org tell you more about how to limit versions. By aware, limiting versions is usually not what you want to do. Usually you just want the version that works with your setup and composer will figure out what version that is.