lines

Easiest way to “draw” simple lines over an image with jQuery and save to Rails DB?

隐身守侯 提交于 2019-12-03 05:43:45
问题 I'd like to draw lines on an image. Basically allow the user to draw a path for mountain trails they like. 1) Does anyone know a good simple library for drawing basic lines? 2) After a user draws a bunch of lines on an image, what would be the best way to save the data to the database? 回答1: Drawing lines Paper.js . Look at the Path Simplification example. Raphaël - Raphael SketchPad You can easily overlay the elements on top of an image so the user draws on the image. Also, just for fun, but

Deleting the first two lines of a file using BASH or awk or sed or whatever

倖福魔咒の 提交于 2019-12-03 04:44:34
问题 I'm trying to delete the first two lines of a file by just not printing it to another file. I'm not looking for something fancy. Here's my (failed) attempt at awk: awk '{ (NR > 2) {print} }' myfile That throws out the following error: awk: { NR > 2 {print} } awk: ^ syntax error Example: contents of 'myfile': blah blahsdfsj 1 2 3 4 What I want the result to be: 1 2 3 4 回答1: Use tail: tail -n+3 file from the man page: -n, --lines=K output the last K lines, instead of the last 10; or use -n +K

Easiest way to “draw” simple lines over an image with jQuery and save to Rails DB?

无人久伴 提交于 2019-12-02 18:07:14
I'd like to draw lines on an image. Basically allow the user to draw a path for mountain trails they like. 1) Does anyone know a good simple library for drawing basic lines? 2) After a user draws a bunch of lines on an image, what would be the best way to save the data to the database? Drawing lines Paper.js . Look at the Path Simplification example. Raphaël - Raphael SketchPad You can easily overlay the elements on top of an image so the user draws on the image. Also, just for fun, but have you seen SVG-edit ( demo )? Saving the line data The SketchPad script above provided drawn data in JSON

Deleting the first two lines of a file using BASH or awk or sed or whatever

坚强是说给别人听的谎言 提交于 2019-12-02 17:58:15
I'm trying to delete the first two lines of a file by just not printing it to another file. I'm not looking for something fancy. Here's my (failed) attempt at awk: awk '{ (NR > 2) {print} }' myfile That throws out the following error: awk: { NR > 2 {print} } awk: ^ syntax error Example: contents of 'myfile': blah blahsdfsj 1 2 3 4 What I want the result to be: 1 2 3 4 Use tail: tail -n+3 file from the man page: -n, --lines=K output the last K lines, instead of the last 10; or use -n +K to output lines starting with the Kth How about: tail +3 file OR awk 'NR>2' file OR sed '1,2d' file You're

Plot and fill area enclosed by n lines using Octave\Matlab

浪子不回头ぞ 提交于 2019-12-02 07:11:40
问题 Lets suppose I have n curves, which together enclose some region. How to plot the curves and fill in the region they enclose using Octave/Matlab? Below is example for 3 curves (enclosed area is in black): 回答1: You can use the function fill . See the matlab documentation there: http://www.mathworks.fr/help/techdoc/ref/fill.html 回答2: I used the fill and flipr functions in matlab to shade the area between two curves: fill( [x fliplr(x)], [upper fliplr(lower)], 'c', 'EdgeColor','none'), where x =

find lines from one file in another

倖福魔咒の 提交于 2019-12-02 05:32:36
问题 So I have a file1.txt with a list of names, and a file2.txt with another list of names and I need a list with the names that are in both files. I tried grep-f file1.txt file2.txt > newlist.txt but for some reason it isn't working, and the newlist.txt has names that are not in file1. Does anyone know why this is happening and what i could do to get only the names that are on both lists? thank you. 回答1: If file1.txt and file2.txt are sorted, you could use 'comm' comm -12 file1.txt file2.txt >

Adding square brackets to character class in Java regex

做~自己de王妃 提交于 2019-12-02 04:55:56
问题 I would like to read a content String from file lne by line, and in each line remove all caharcters that are not one of the following [ { } ] I wanted to used a method: line = line.replaceAll("[^[({})]]",""); but the problem is that char [ and ] means in regex syntax something else. How to deal with it? Best regards 回答1: In Java, the regex character classes can have unions and intersections, thus, [ and ] must be escaped inside if you want them to be treated as literal symbols. And since \

find lines from one file in another

独自空忆成欢 提交于 2019-12-02 02:19:21
So I have a file1.txt with a list of names, and a file2.txt with another list of names and I need a list with the names that are in both files. I tried grep-f file1.txt file2.txt > newlist.txt but for some reason it isn't working, and the newlist.txt has names that are not in file1. Does anyone know why this is happening and what i could do to get only the names that are on both lists? thank you. If file1.txt and file2.txt are sorted, you could use 'comm' comm -12 file1.txt file2.txt > newlist.txt If each the names in each list are unique, then you can find their intersection as follows: sort

Adding square brackets to character class in Java regex

不羁的心 提交于 2019-12-01 23:04:51
I would like to read a content String from file lne by line, and in each line remove all caharcters that are not one of the following [ { } ] I wanted to used a method: line = line.replaceAll("[^[({})]]",""); but the problem is that char [ and ] means in regex syntax something else. How to deal with it? Best regards In Java, the regex character classes can have unions and intersections, thus, [ and ] must be escaped inside if you want them to be treated as literal symbols. And since \ can be used to define escape sequences, it should be doubled to denote a literal regex-escaping \ . Use line =

How to filter only the longest line after Hough Transform

淺唱寂寞╮ 提交于 2019-12-01 22:58:57
问题 I'm currently using the Hough Transform to get the straight lines. But there are a lot of lines detected. Can I know how to filter and only get the longest line from the output? HoughLinesP(dst, lines, 1, CV_PI/180, 50, 20, 10 ); //left lane for( size_t i = 0; i < lines.size(); i++ ) { Vec4i l = lines[i]; double theta1,theta2, hyp, result; theta1 = (l[3]-l[1]); theta2 = (l[2]-l[0]); hyp = hypot(theta1,theta2); line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(255,0,0), 3, CV_AA); }