I have the following file with Markdown markup:
* [B](B)
* b
* c
* [C](C)
* [A](a)
* a
I try to sort it and get the following result:
* [A](a)
* a
* [B](B)
* b
* c
* [C](C)
It is necessary to sort only the main levels, and sub-levels must follow the main levels, i.e., stay at the levels where they were. The first thing that comes to mind is of course :sort; but unfortunately this will also sort the sub-levels. We will get:
* a
* b
* c
* [A](a)
* [B](B)
* [C](C)
Are there any tricks or plugins for this kind of sorting? Thx!
The usual approach for this class of problems is to inline each block, then sort them, and then "de-inline" them back to their original state.
First step: inline each block.
We do this by replacing each EOL followed by SPACE-SPACE-STAR with some fancy symbol unlikely to be found in our document:
:%s/\n\( \*\)/§\1
Which gives us the following:
* [B](B)§ * b§ * c
* [C](C)
* [A](a)§ * a
Second step: sort the buffer.
We simply use :help :sort:
:sort
to obtain this:
* [A](a)§ * a
* [B](B)§ * b§ * c
* [C](C)
Third step: revert each "block" to its initial state.
We do this by reverting the substitution above with another, much simpler, one:
:%s/§/\r
which gives us the desired outcome:
* [A](a)
* a
* [B](B)
* b
* c
* [C](C)
A couple of notes:
The exact pattern to use in the first substitution depends on the exact structure of your document. That part is, IMO, too highly contextual to be generalisable.
§ is just an example, use whatever symbol you want.
Related
Can you please tell me exactly where to place the OpenMp THREADPRIVATE directive for the common block? Immediately after the description of this block, immediately after the description of this block and all other variables of any kind, or only after all DATA blocks? Example:
SUBROUTINE SCHNEVPDH (RZ,FLAT,FLON,R,T,L,BN,BE,BV)
PARAMETER (IBO=0,JBO=1,KDIM=8,LDIM=4)
DIMENSION FN(0:KDIM,0:KDIM), CONSTP(0:KDIM,0:KDIM)
DIMENSION CML(KDIM), SML(KDIM)
DIMENSION DELT(0:LDIM)
DIMENSION BINT(0:KDIM,0:KDIM,1-IBO-JBO:LDIM),
* BEXT(0:KDIM,0:KDIM,1-IBO-JBO:LDIM)
COMMON /CONST/UMR,PI
* /AMTB/BINT,BEXT,RE,TZERO,IFIT,IB,KINT,LINT,KEXT,
* LEXT,KMAX,FN
CHARACTER*1 IE,RESP
DATA ((CONSTP(N,M), M=0,N), N=0,KDIM)
* /4*1.,1.73205,0.866025,1.,2.44949,1.93649,0.7905691,1.,
* 3.16228,3.35410,2.09165,0.739510,1.,3.87298,5.12348,
* 4.18330,2.21853,0.701561,1.,4.58258,2*7.24569,4.96078,
* 2.32681,0.671693,1.,5.29150,9.72111,11.4564,9.49918,
* 5.69951,2.42182,0.647260,1.,6.,12.5499,16.9926,16.4531,
* 11.8645,6.40755,2.50683,0.626707/
!$OMP THREADPRIVATE(/CONST/)
!$OMP THREADPRIVATE(/AMTB/)
IBF = 2
T1=1.
T2=12.
CALL TBFIT (T1,T2,IBF,THINT,TZERO)
Is this directive in the right place? The same question applies to SAVE type variables.
I am trying to divide two complex numbers and not getting the desired result. How does division work for Python Complex numbers ?
Input values are: (2+3j) and (2+3j)
I have tried the below logic and this does not seem to work.
numerator_real = (real * conjugate.real) - (imag * conjugate.imag); // real
numerator_imag = (real * conjugate.imag) + (imag * conjugate.real); // imag
denom = x.real * x.real + x.imag * x.imag;
complex(numerator_real/denom, numerator_imag/denom)
Expected/Desired Result is: 1+0j
My output is 1.3+0j
I am trying to make a scheduled task where cron job executes after every 15 minutes, but I am confused about seconds.
I have made the following cron: ("* 0/15 * * * *") . Is it same as
("0 0/15 * * * *") [Note the second part here]. I mean in online I have seen examples where seconds is replaced by 0, but other fields with *. So my question is, if I replace seconds field with *, then is it same as with 0 ?
I'm trying to make a small utility that should automate some maintenance tasks of the uTerrent's pool of torrents. To veryfy the hashes of partially downloded shares, I have to retrieve the parts of the pieces, that are not completely contained by the downloaded files, from the ~uTorrentPartFile_XXX.dat file where uTorrent keeps them. This raises two questions:
Given a certain .torrent file, how do I compute the name of the corresponding ~uTorrentPartFile_XXX.dat file (namely, the hexadecimal string that uTorrent uses instead of my XXX)
Where can I find information about the inner structure of the file that would allow me to retrieve the required data from it? Google's failed to help.
The BiglyBT team has reverse engineered the ~uTorrentPartFile_XXXX.dat format when they created a migration plugin.
https://www.biglybt.com/download/utMigrate
https://github.com/BiglySoftware/BiglyBT-plugin-migratetorrentapp
From: https://github.com/BiglySoftware/BiglyBT-plugin-migratetorrentapp/blob/master/src/com/biglybt/plugins/migratetorrentapp/utorrent/PartFile.java
/**
* uTorrent partfile
* Basically, torrent data is split into 64k parts. Header has 4 byte index for
* each part, pointing to data if index is > 0.
* After the header is the 64k data chunks, first data chunk is 1, second is 2, etc.
* Last data chunk may be smaller than 64k.
*
* ~uTorrentPartFile_*<hexsize>*.dat
* <Header>, <data>
*
* hexsize
* torrent data length in bytes in hex with no leading 0
*
* Header
* <DataIndex>[<Num64kParts>]
* Raw header length = <Num64kParts> * 4
*
* Num64kParts
* How many parts is required if you split torrent data length into 64k sections.
* ie. Math.ceil(torrent data length in bytes / 64k)
*
* DataIndex
* 4 byte little endian integer. Values:
* 0
* No data for this 64k part
* 1..<num64Parts>
* 1-based positional index in <data>
* Location in part file can be calculated with
* (Header Size) + ((value - 1) * 64k)
*
* data
* <DataPart>[up to <num64kParts>]
*
* DataPart
* 64k byte array containing torrent data.
* Bytes in <DataPart> that are stored elsewhere in real files will be 0x00.
* ie. non-skipped files sharing the 64k part will be 0x00.
* Last <DataPart> may be less than 64k, which means the rest of the 64k would
* be 0x00 (and part of a non-skipped file)
*
*/
Bonus
There is also some useful information about the content in resume.dat and settings.dat in the code comments here:
https://github.com/BiglySoftware/BiglyBT-plugin-migratetorrentapp/blob/master/src/com/biglybt/plugins/migratetorrentapp/utorrent/ResumeConstants.java
https://github.com/BiglySoftware/BiglyBT-plugin-migratetorrentapp/blob/master/src/com/biglybt/plugins/migratetorrentapp/utorrent/SettingsConstants.java
Just interested in the shortened version of the following for the minutes interval:
5,15,25,35,45,55
8,18,28,38,48,58
I know they essentially the same, just a different ending digit.
Thanks.
The definition in the initial question is as short as it can be made.
This should do the trick:
5,15,25,35,45,55 * * * * yourcommand
8,18,28,38,48,58 * * * * yourcommand
Just put 8,18,28,38,48,58 etc in the 'minutes' field.
Ie:
8,18,28,38,48,58 * * * * /path/to/command