Sublime 3 scroll_past_end set number of lines it will scroll past - sublimetext3

Is there a way to set the maximum number of lines it will scroll past? For example I want the last line to remain roughly at the middle of the editor window. Thanks!
for example, with 'scroll_past_end': false,
560 lorem ipsum
561 lorem ipsum
562 lorem ipsum
563 lorem ipsum
564 lorem ipsum
565 lorem ipsum
566 lorem ipsum
567 lorem ipsum
568 lorem ipsum
569 lorem ipsum
570 lorem ipsum
with 'scroll_past_end': true,
570 lorem ipsum
this is what I want
566 lorem ipsum
567 lorem ipsum
568 lorem ipsum
569 lorem ipsum
570 lorem ipsum

Your question is tagged sublimetext3; in ST3, it's not possible to change this behaviour (other than to turn it off entirely).
In Sublime Text 4, the scroll_past_end setting is enhanced to allow you to specify how much of a scroll should happen. It's based a percentage of the visible content and not a number of lines, but you could set it to for example 0.8 or 0.9 to allow for a few lines of context at the top rather than just one.
// Set to false to disable scrolling past the end of the buffer.
// On Mac, this value is overridden in the platform specific settings, so
// you'll need to place this line in your user settings to override it.
//
// This setting may also be set to a number between 0.0 and 1.0 to specify
// how much scrolling past the end of the buffer should be allowed. 0.5
// scrolls halfway and 0.0 is the same as false.
"scroll_past_end": true,

Related

Is there a significant speed improvement when using transformers tokenizer over batch compared to per item?

is calling tokenizer on a batch significantly faster than on calling it on each item in a batch? e.g.
encodings = tokenizer(sentences)
# vs
encodings = [tokenizer(x) for x in sentences]
i ended up just timing both in case it's interesting for someone else
%%timeit
for _ in range(10**4): tokenizer("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
785 ms ± 24.5 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
%%timeit
tokenizer(["Lorem ipsum dolor sit amet, consectetur adipiscing elit."]*10**4)
266 ms ± 6.52 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

How to split a text file into a fixed width file in tcsh?

I need to read a text file and make it fit X amount of columns.
For example, if my text.txt contains:
ABCDEFGHIJK
the resulting file for a width of 4 should be:
ABCD
EFGH
IJK
Like this?
$ echo ABCDEFGHIJK | sed -r 's/(....)/\1\n/g'
ABCD
EFGH
IJK

Using Spark to merge two or more files content and manipulate the content

Can I use Spark to do the following?
I have three files to merge and change the contents:
First File called column_header.tsv with this content:
first_name last_name address zip_code browser_type
Second file called data_file.tsv with this content:
John Doe 111 New Drive, Ca 11111 34
Mary Doe 133 Creator Blvd, NY 44499 40
Mike Coder 13 Jumping Street UT 66499 28
Third file called browser_type.tsv with content:
34 Chrome
40 Safari
28 FireFox
The final_output.tsv file after Spark processing the above should have this contents:
first_name last_name address zip_code browser_type
John Doe 111 New Drive, Ca 11111 Chrome
Mary Doe 133 Creator Blvd, NY 44499 Safari
Mike Coder 13 Jumping Street UT 66499 FireFox
Is this do able using Spark? Also I will consider Sed or Awk if it is possible use the tools. I know the above is possible with Python but I will prefer using Spark to do the data manipulation and changes. Any suggestions? Thanks in advance.
Here it is in awk, just in case. Notice the file order:
$ awk 'NR==FNR{ a[$1]=$2;next }{ $NF=($NF in a?a[$NF]:$NF) }1' file3 file1 file2
Output:
first_name last_name address zip_code browser_type
John Doe 111 New Drive, Ca 11111 Chrome
Mary Doe 133 Creator Blvd, NY 44499 Safari
Mike Coder 13 Jumping Street UT 66499 FireFox
Explained:
NR==FNR { # process browser_type file
a[$1]=$2 # remember remember the second of ...
next } # skip to the next record
{ # process the other files
$NF=( $NF in a ? a[$NF] : $NF) } # replace last field with browser from a
1 # implicit print
It is possible. Read header:
with open("column_header.tsv") as fr:
columns = fr.readline().split()
Read data_file.tsv:
users = spark.read.option("delimiter", "\t").csv("data_file.tsv").toDF(*columns)
Read called browser_type.tsv:
browsers = spark.read.csv("called browser_type.tsv") \
.toDF("browser_type", "browser_name")
Join:
users.join(browser, "browser_type", "left").write.csv(path)

Combine similar rows in a file using AWK

again!
Can somebody help me with next question:
I need to combine similar rows in a file using awk. Example
File has next rows:
Mike dollar 15
Fred euro 10
Mike euro 4
Fred euro 4
Output should look like:
Mike:
dollar 15
euro 4
Fred:
euro 14
How do I combine similar patterns in different rows into one row?
Thanks a lot for ideas!
awk to the rescue!
$ awk '{a[$1,$2]+=$3; k1s[$1]; k2s[$2]}
END{for(k1 in k1s)
{print k1":";
for(k2 in k2s) if(a[k1,k2]) print k2, a[k1,k2]; print ""}}' file
Mike:
euro 4
dollar 15
Fred:
euro 14

Linux (command) | rename | trim leading chracters after x vs. keep only numbers

I want to delete some parts from file names such that
101 - title [1994].mp4
102 - title [1994].mp4
103 - title [1994].mp4
104 - title [1994].mp4
105 - title [1994].mp4
becomes
101.mp4
102.mp4
103.mp4
104.mp4
There are two or more ways to handle this, either by:
keeping numbers and remove non-numbered characters
trim leading characters after (3)-characters
How would I use the linux command rename to only keep the first (3) characters and trim the rest, while keeping the extension ofcourse.
I would like to avoid the mv command, what are the ways to do this with rename?
This is the expression you want s/(\d{3}).*$/$1.mp4/. Take a look at the output:
rename -n 's/(\d{3}).*$/$1.mp4/' *mp4
101 - title [1994].mp4 renamed as 101.mp4
102 - title [1994].mp4 renamed as 102.mp4
103 - title [1994].mp4 renamed as 103.mp4
104 - title [1994].mp4 renamed as 104.mp4
105 - title [1994].mp4 renamed as 105.mp4

Resources