Better HN
topnewbestaskshowjobs
Log inSign up

lvvlvv

10 karma · joined Mar 16, 2010 (16y ago) · 10 submissions

Submissions

comment 15y ago · link · parent

Simplified C++ inspired by AWK: http://github.com/lvv/scc

comment 15y ago · link · parent

  # --- print second column 
  ls -al | awk '{print $2}'
  ls -al | pru 'split(" ")[1]'
  ls -al | scc -n 'F(1)'

  # --- count and average of all integers on second position
  ls -al | awk '{ s += $2; } END {print "average" ,int(s/NR);print "count ",int(NR)}'
  ls -al | pru 'split(" ")[1]' '"average #{mean(&:to_i)}\ncount #{size}"'
  ls -al | scc 'int c=0; WRL c+=F(1); FMT("average %s\ncount %s") %(c/NR) %NR'

  # --- count lines
  ls -al | wc -l  
  ls -al | pru -r 'size'
  ls -al | scc 'WRL;NR+1'

  # -- replace a 5 with five
  ls -al | sed 's/5/five/'
  ls -al | pru 'gsub(/5/,"five")'
  ls -al | scc -n 'RR(line,R("5"),"five")'

  # every second line
  ls -al | pru 'i % 2 == 0'
  ls -al | scc -n 'NR % 2 ? line : ""'

  # sum up df's used-space column
  df | awk '{n+=$3;};  END{print n}'
  df | pru  ?????
  df | scc 'int n=0; WRL n+=F(2); n'

comment 15y ago · link · parent

Similar project for C++: http://github.com/lvv/scc

comment 15y ago · link · parent

Yet another gcc wrapper: http://github.com/lvv/scc

comment 15y ago · link · parent

I like them too. Cheap and simple.

comment 15y ago · link · parent

I am the author. You are right. I've updated the page.

comment 15y ago · link · parent

> Note that the worst case of complexity for this algorithm is much, much worse than the worst case complexity for Boyer Moore.

Can you explain your thought process for why worst case complexity is worse than other? Did you do any measurements? I believe you are incorrect. I am author of this page. I've just did quick test for SS = "aaa ...aaaBaaa...aaa", with SS_size=240. My algorithm is faster than 3 BMs out of 4 tested.

> Do not use this algorithm carelessly. For example, if you use it in a thoughtless way in your web server, you may open yourself to a DoS attack.

Same can be said about all BM, naive and BSD's memmem/strstr. Possibility of DOS for substring search algorithm was known for a long time - but it never materialized. The cure is trivial - limit substring size.

> That immediately made me think he might have devised it for genomics research.

No, it wasn't. It was devised when I was preparing for Google interview (which I failed). And of cause algorithms which pre-index haystack will always be faster. I myself do not consider haystack pre-indexing algorithms a "text search" algorithms (maybe incorrectly).

> gross exaggeration

If you count pre-indexing algorithms and edge cases - then you are correct. For most common case - can you show me something faster (from a student or even yourself)?

comment 16y ago · link · parent

You can make static-PNG charts with http://matplotlib.sourceforge.net or http://volnitsky.com/project/mplw

comment 16y ago · link · parent

Another happy customer of prgmr. I am 4yr with them. You kind of forget about them because there was not a single issues or outage during all this time.

comment 16y ago · link · parent

"you ignored us, but the FTC said we were right, nah nah nah"

That how I read their open letter. And my interpretation of "you should have worked with us" is as "you should have hired us as consultants"