lines

How to find N longest lines in a text file and print them to stdout?

。_饼干妹妹 提交于 2019-12-07 06:11:07
问题 The first line contains the value of the number 'N' followed by multiple lines. I could solve it in order of n^2 algorithm. Can someone suggest a better one? 回答1: You can use a minimum-heap and do it in O(n*(log(N))): heap = new Min-Heap(N) foreach line in text: if length(line) > heap.min(): heap.pop() heap.insert(line) foreach line in heap: print to stdout: line. it could also be done in O(n) using Select(N) (which selects the Nth number) followed by partition around the Nth number (which

How to read multi-line input in a Bash script? [closed]

别来无恙 提交于 2019-12-07 00:54:00
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I want store in a file and in a variable multiples lines from a "paste" via shellscript. How can I acomplish that? Example: echo "Paste the certificate key:" 1fv765J85HBPbPym059qseLx2n5MH4NPKFhgtuFCeU2ep6B19chh4RY7ZmpXIvXrS7348y0NdwiYT61

Show Indent Guide Lines In Xcode

拈花ヽ惹草 提交于 2019-12-07 00:21:26
问题 Coming from a background using Visual Studio and Notepad++ I'm used to the indent guides which help to visually enhance sections of code where the curly braces are used, Xcode (No indent guides) Visual Studio (Nice tidy indent guides) As you can see from the images above sometimes there are sections of code where multiple levels of curly braces are open and it gets messy without any indent guides. Are there any options or plugins that will allow xcode to display the indent guides in between

C# how to write multiple lines in a text file?

左心房为你撑大大i 提交于 2019-12-06 22:26:26
I am trying to press a button that takes the text from textbox4 and textbox5 to write it to a text file. BUT when I press it again to add new info to the text file it just replaces the old text in with the new. How do I get it to write another line below the first one each time I press the button? This is the code I have so far private void button5_Click(object sender, EventArgs e) { try { xuidspath = @"c:\xuids.txt"; ListViewItem lvi = new ListViewItem(); lvi.Text = textBox4.Text; lvi.SubItems.Add(textBox5.Text); listXuid.Items.Add(lvi); TextWriter xuids = new StreamWriter(xuidspath); xuids

How to have line breaks in XML attributes?

China☆狼群 提交于 2019-12-06 19:42:53
问题 I have a attribute called: description and I want to have the following in it with new lines: This is the content description section. Download instruction: This is the contents on how to download contents. Hotline support: This is the hotline for contents. How do I create a new line for it in xml? 回答1: Basically you want to insert CRLF: CR code: LF code: <myelement description="line1 line2 line3"/> 回答2: If you need it in XML attribute , you'll have to use character entities: <element

Displaying lines from text file in a batch file

倾然丶 夕夏残阳落幕 提交于 2019-12-06 15:40:19
问题 I'm tryin' to find a script that will let me display "linenumber# and linenumber# as well as lines#-#" from a text file in a batch file? I found this script here on this site.. @echo off setlocal enabledelayedexpansion if [%1] == [] goto usage if [%2] == [] goto usage SET /a counter=0 for /f "usebackq delims=" %%a in (%2) do ( if "!counter!"=="%1" goto exit echo %%a set /a counter+=1 ) goto exit :usage echo Usage: head.bat COUNT FILENAME :exit And it works great :) But it grabs the number of

Richtextbox lines count

微笑、不失礼 提交于 2019-12-06 12:02:44
I'm developing a text editor in C#, and I'm trying to make a line count. private void updateNumberLabel() { Point pos = new Point(0, 0); int firstIndex = Document.GetCharIndexFromPosition(pos); int firstLine = Document.GetLineFromCharIndex(firstIndex); pos.X = ClientRectangle.Width; pos.Y = ClientRectangle.Height; int lastIndex = Document.GetCharIndexFromPosition(pos); int lastLine = Document.GetLineFromCharIndex(lastIndex); int actualLine = Document.GetLineFromCharIndex(actualPos); pos = Document.GetPositionFromCharIndex(lastIndex); if (lastLine != actualLine) { numberLabel.Text = ""; for

android - How do I draw a wireframe over object in opengl 2.0?

自古美人都是妖i 提交于 2019-12-06 10:24:22
I have a tetrahedron object created in openGL ES 2.0. What I'm trying to achieve is to show the actual wireframe of the polygon over its base color. Is there a method for achieving this effect? Also, my tetrahedron is pink. How can I change its color? In addition to what Jave said. Instead of enlarging the whole object (whose optimal amount always depends on the object and the current view) to prevent z-fighting artefacts, you can also use the polygon offset (using glPolygonOffset ), whose major application are indeed wireframe overlays. It basically works by slightly adjusting the depth

How to delete duplicate lines in a file…AWK, SED, UNIQ not working on my file

断了今生、忘了曾经 提交于 2019-12-06 09:23:55
I find many ways to do this, AWK , SED , UNIQ , but none of them are working on my file. I want to delete duplicate lines. Here is an example of part of my file: KTBX KFSO KCLK KTBX KFSO KCLK PAJZ PAJZ NOTE: I had to manually add line feeds when I cut and pasted from the file...for some reason it was putting all the variables on one line. Makes me think that my 44,000 line text file actually has only "1" line? Is there a way to modify it so I can delete dups? philshem You can see all non-printed characters with this command: od -c oldfile If all your records are on one line, you can use sed to

Remove line from file if containing word from another .txt file in python/bash

谁说胖子不能爱 提交于 2019-12-06 08:02:18
I'm learning python, and then i have the following difficulties. The file i want to be cleaned is an .csv file. The file that contains the words that have to be removed from the .csv file is an .txt The .txt file is a list of domain names: domain.com domain2.com domain3.com The .csv file is a config file just like this: domain.com;8;Started;C:\inetpub\wwwroot\d\domain.com;"http *:80:www.domain.com" if the .txt file contains "domain.com" i want the complete line above to be removed. I would be realy gratefully if some python ninja could fix this.(or in bash?) Well, since OP is learning python .