Monday, June 28, 2010

two nice theorems in plane geometry

There are two very nice theorems I've learned not so far. The theorems were discovered by Frank Morley and John Conway.

1. Morley's trisection theorem
in any triangle, the three points of intersection of the adjacent angle trisectors form an equilateral triangle, called the Morley triangle.

2. Conway's circle
if you continue the sides of a triangle beyond every vertex at the distances equaling to the length of the opposite side, the resulting six points lie on a circle, which is called Conway’s circle.

Thursday, June 3, 2010

sed for a set of lines

this script helps to make a sed operation (like search and replace) for only very certain lines in a file. let's say we have a data file (project.dat) and an index file (project.idx) with the line numbers, which we are interested to be changed. for the replacing all 'C' to 'L' we can do the following


#!/bin/sh

#make script for sed
sed 's|$|s/C/L/|' project.idx > project.scr
#or with awk
#awk '{print $1 "s/C/L/"}' project.idx > project.scr

#run sed with -f
sed -f project.scr project.dat > project.new.dat

#remove the script
rm -f project.scr

exit 0


source: http://www.unix.com/