lines

Ruby equivalent to "grep -C 5" to get context of lines around the match?

I've searched for this a bit but I must be using the wrong terms - does ruby have a way to grep for a string/regex and also return the surrounding 5 lines (above and below)? I know I could just call "grep -C 5 ..."or even write my own method, but it seems like something ruby would have and I'm just not using the right search terms. ...

In LaTeX, is there a way to get long lines along the margins?

I'm working on a report, and some elements are outside the margins (but some are just barely outside the margins). I was wondering: Is there a way to make two vertical lines, one on each side, along the margins so that one can easily see if it goes outside them? (Googling it, I only found information about margin notes.) A figure is be...

Python turtle module confusion

Hi, I'm trying to to add more lines to the triangle, so instead of 3 leading off there will be 5 depending on the parameter given but I really have no idea what to do at this stage and any help would be very welcome. Thanks in advance!:) def draw_sierpinski_triangle(tracer_on, colour, initial_modulus, line_width, initial_heading,initial...

How do I make lines scale when using GLOrtho?

I'm using GLOrtho to set up a 2D view that I can render textures onto. It works really well, up until I try to zoom in on the image. If I pass half the width and half the height of the viewport to GLOrtho, I end up with all my textures displayed twice as big as normal, which is exactly what I expect. But then I try to draw a box aroun...

How to draw connecting lines between two controls on a grid WPF

Hi, I am creating controls (say button) on a grid. I want to create a connecting line between controls. Say you you do mousedown on one button and release mouse over another button. This should draw a line between these two buttons. Can some one help me or give me some ideas on how to do this? Thanks in advance! ...

drawing hierarchical tree with orthogonal lines ( HV-Drawing – Binary Tree)

Hi I need to work on drawing a hierarchical tree structure (HV-Drawing – Binary Tree) with orthogonal lines(straight rectangular connecting lines) between root and children ( like the following: http://lab.kapit.fr/display/visualizationlayouts/Hierarchical+Tree+layout ). I want to know if there are any open source examples of the algorit...

WPF, ShowGridLines equivalent for wrap panel

I need to display a 1 pixel wide border around all wrap panel cells, kinda like excel grid. Unfortunately the wrap panel does not implement the grid ShowGridLines property. I can't put a border inside every cell because adjacent cells will have a 2 pixel border instead of 1 pixel. Since the wrap panel arranges it's layout dynamically and...

Find duplicates lines based on some delimited fileds on line

Hello, I have a file with lines having some fields delimited by "|". I have to extract the lines that are identical based on some of the fileds (i.e. find lines which contain the same values for fields 1,2,3 12,and 13) Other fields contents have no importance for searching but the whole extracted lines have to be complete. Can anyone ...

Inner angle between two lines

Hi folks, I have two lines: Line1 and Line2. Each line is defined by two points (P1L1(x1, y1), P2L1(x2, y2) and P1L1(x1, y1), P2L3(x2, y3)). I want to know the inner angle defined by these two lines. For do it I calculate the angle of each line with the abscissa: double theta1 = atan(m1) * (180.0 / PI); double theta2 = atan(m2) * (18...

How to draw lines manually in reporting services scatter chart

How to draw lines manually in reporting services scatter chart? Please help me to draw line in scatter chart.If you could help me that would be the greatest help for me ...

Count number of lines in CSV with Javascript

I'm trying to think of a way to count the number of lines in a .csv file using Javascript, any useful tips or resources someone can direct me to? ...

How to merge lines in an SQL query?

MY table looks like this id | string | foreign_id --------------------------- 1 | house | 5 2 | garden | 6 3 | window | 5 ... I have an array of strings and i want to get all foreign ids which match all elements in the array. So i have an array like this [house, window] then i want to get 5. The array of strings can have up to 10 ...

Check SLOC and flag methods over 300 lines long.

Is there a way I can automatically scan my source code for methods that are over (eg) 300 lines long so that they can be flagged for review (with an aim to refactoring to smaller methods) I expect any such tool may be language independant, but ideally I'd like to run this over c# code. ...

removing blank lines from XHTML

Hi, I have XHTML that has empty (blank) lines: some_tag empty line empty line empty line some_tag I wonder how to get rid of them using PHP str_replace. The result should be some_tag some_tag. What are these blank lines anyways? ...

Indenting all lines inside textarea..

Is it possible to text indent each line in a textarea? I'm using a handwritten font and the first letter on each line is getting cut off slightly. I've already used padding and margin, but this does not work. Many thanks. Erik ...

XSL QUESTION: alternative method to count the number of lines or newline characters of an xml attribute

I've scoured the internet to discover this method of finding the number of lines in an xml element.: <xsl:if test="string-length(@Example) - string-length(translate(@Example, '&#xa;', '')) &lt; 10"> In the example above, @Example is the element for which the number of lines is counted. I didn't like this code, however, because it aut...

Writing only part of a line to a file.

I want to clean up my output and only write part of the line that I need to a new file and not the whole entire line. This is the relevent coding section: counter = 1 for line in completedataset: print counter counter +=1 for t in matchedLines: if t in line[:line.find(',')]: smallerdataset.write(line) ...

Deleting lines in python after i write them

Ok here is my existing code: ////////////// = [] for line in datafile: splitline = line.split() for item in splitline: if not item.endswith("JAX"): if item.startswith("STF") or item.startswith("BRACKER"): //////////.append( item ) for line in ////////// print ///////////// ///////////...

Determine if a file has more than X lines?

Hi there, as I was not able to find a function which retrieves the amount of lines a file has, do I need to use $handle = fopen("file.txt"); For($Line=1; $Line<=10; $Line=$Line+1){ fgets($handle); } If feof($handle){ echo "File has 10 lines or more."; }Else{ echo "File has less than 10 lines."; } fclose($handle) or something si...

How to prevent CVS from converting line endings?

Like many other people we're having line ending issues with CVS. However, unlike most our problem is the opposite. Is there a way to force CVS to not convert lines from /n to CR/LF. I would like the line endings to remain in the Unix format even if I checkout to a Windows machine. Is that even possible? The problem: the conversion of t...