How to remove the last line in xterm.js - xtermjs

I'm trying to remove the last line of a xtermjs terminal. In the docs I have only found the clear and reset methods, but I just want to remove the last line.

I solved this based on the answers of this question
\33[2K erases the entire line your cursor is currently on
\033[A moves your cursor up one line, but in the same column i.e. not
to the start of the line
\r brings your cursor to the beginning of the line (r is for rewind)
but does not erase anything
I ended up using this to erase the last line:
terminal.write('\x1b[2K\r')
\x1b is the hexadecimal of \033, because I was getting this error when using the octal version.
Octal literal in strict mode

Related

Grep lines for multiple words and the line ending, and then replace line ending if matched

I need to grep a long text file for lines that contains multiple possible words and also end in "=1", and then replace the line with the same text except change the "=1" to "=0".
I'm using BBEdit.
So far I have this to find lines that contains the desired match that also ends with 1:
^(.*test|.*disabled|.*inactive|.*server).*(=1)
I'm unable to do the replacement successfully though.
Here are some example lines of text from the file:
OU>2020,OU>Disabled Accounts,DC>net,DC>example,DC>com=1
OU>Distribution Groups,DC>net,DC>example,DC>com=1
OU>Exchange Servers,DC>net,DC>example,DC>com=1
CN>Users,DC>net,DC>example,DC>com=1
OU>Test Servers,OU>Servers,OU>ABC,DC>net,DC>example,DC>com=1
As an example, the first line above would have its =1 changed to =0 like:
OU>2020,OU>Disabled Accounts,DC>net,DC>example,DC>com=0
Other matches would follow that pattern.
After playing around with it more, this seems to work:
Find:
(^.*(test|disable|inactive|server).*)(=1)$
Replace:
\1=0

Pipe character ignored in SPSS syntax

I am trying to use the pipe character "|" in SPSS syntax with strange results:
In the syntax it appears like this:
But when I copy this line from the syntax window to here, this is what I get:
SELECT IF(SEX = 1 SEX = 2).
The pipe just disappears!
If I run this line, this is the output:
SELECT IF(SEX = 1 SEX = 2).
Error # 4007 in column 20. Text: SEX
The expression is incomplete. Check for missing operands, invalid operators,
unmatched parentheses or excessive string length.
Execution of this command stops.
So the pipe is invisible to the program too!
When I save this syntax and reopen it, the pipe is gone...
The only way I found to get SPSS to work with the pipe is when I edited the syntax (adding the pipe) and saved it in an alternative editor (notepad++ in this case). Now, without opening the syntax, I ran it from another syntax using insert command, and it worked.
EDIT: some background info:
I have spss version 23 (+service pack 3) 64 bit.
The same things happens if I use my locale (encoding: windows-1255) or Unicode (Encoding: UTF-8). Suspecting my Hebrew keyboard I tried copying syntax from the web with same results.
Can anyone shed any light on this subject?
Turns out (according to SPSS support) that's a version specific (ver. 21) bug and was fixed in later versions.

NotePad++ Changing Few Number Entries

Here is a simple lists where I like to change the numbers: the entries are as below and it got over 300 entries like it
tom112
smith113
harry114
linda115
cindy106
samantha147
It need to be changed to
tom212
smith213
harry214
...and so on.
Please assist using notepad++ regular expression.
Thanks.
Assuming it's just a matter of replacing a name followed by a number starting with 1 with the same number but starting with 2 instead:
Ctrl + H for search & replace.
Check Regular expression under Search Mode.
Next to Find what type or copy in ([a-zA-Z]+)1([0-9]+).
Next to Replace with type or copy in \12\2.
Click Replace All and that should do it.
Add any other characters that might appear in the name before the number inside the first set of brackets with a-zA-Z.

Lua Removing first couple characters without add a space

I'm new to Lua and I'm sure this is a silly problem.
I was trying to remove first 3 characters from a string with string.gsub
Here is the code:
string.gsub(m, "/jk", "", 1)
Now "/jk" are the first 3 chars the string, now, string.gsub adds a space instead of removing them. My question is, how to remove them without adding the space?
string.gsub doesn't add a space unless you ask it to, and in your pasted code you aren't asking it to. Are you sure there wasn't already a space after the /jk in the string?
Also, if you're just trying to remove the first 3 characters, you should use string.sub(m, 4).

How to count lines of code (LOC) using IntelliJ IDEA?

title says everything plus:
- development language Lua
- code revision control system - Perforce (integrated with IntelliJ IDE)
Posting for posterity - This was the top Google entry when searching "intellij count lines of code" (without quotes)
.
If you're like me and didn't want to install anything else, you can hack it via the native, global search:
Ctrl + Shift + F (to open global search)
Use regex mode (check "regex" checkbox)
In the searchbox, enter only a caret "^" (without the quotes)
You may want to limit the search to a specific directory, via the "directory" tab
Hit the "Open in Find Window" button on the bottom-right
If it asks whether you want to continue, press "Continue"
.
Notes:
In regex, the caret (^) denotes the start of a line, except when inside square brackets, in which case it denotes negation
If you wanted to count non-empty lines, you could instead use "^.*\S" (without quotes), which signifies "The start of a line (^), followed by any number of characters (except newline) (.*), followed by a non-whitespace character (\S)"
You can either turn on the display of lines of code for a single file by right clicking in the left gutter and highlighting "display lines of code". Or you can do it for your entire project by downloading the Statistic plug-in. It's very nice indeed, because it shows LOC and other metrics for your entire project.

Resources