Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

misc

  • Loading branch information...
commit ed2c36405a1aeab50360f1520683cb1f2dcac588 1 parent 967df0c
arrix authored November 23, 2010
4  .gitignore
... ...
@@ -1 +1,5 @@
1 1
 .DS_Store
  2
+log/*.log
  3
+dist/*
  4
+*.tmproj
  5
+
11  notes.txt
@@ -26,6 +26,11 @@ readability.getInnerText is very frequently used function. My optimization for i
26 26
 
27 27
 # cleanStyles
28 28
 cleanStyles is recursive, it counts for most running time of prepArticle
  29
+
  30
+# security
  31
+arbitrary js
  32
+frames
  33
+
29 34
 # performance
30 35
 grep TOTAL clean.log|cut -d ' ' -f5|sort -n
31 36
 
@@ -39,6 +44,12 @@ def hist(array)
39 44
   
40 45
 end
41 46
 
  47
+
  48
+def avg(s, regex) 
  49
+    a = s.scan(regex).flatten.map(&:to_f)
  50
+    a.reduce{|x,y| x+y}/a.size
  51
+end
  52
+
42 53
 # sum profiler output
43 54
 s = <<EOT
44 55
 19 Nov 12:56:08 -       0.233 seconds [killBreaks] 
2  package.sh
... ...
@@ -0,0 +1,2 @@
  1
+NAME=node-readability
  2
+tar -zcf ./dist/readability.tgz -C .. --exclude=".*" --exclude="test*" $NAME/lib $NAME/LICENSE.txt $NAME/README.md $NAME/package.json
1  test.txt
@@ -10,6 +10,7 @@ problems:
10 10
 slow
11 11
 http://127.0.0.1:3000/?url=http://www.gazeta.ru/news/lastnews/
12 12
 http://127.0.0.1:3000/?url=http://www.sqlite.org/fts3.html
  13
+http://127.0.0.1:3000/?url=http://news.google.com.hk/nwshp?hl=zh-tw&tab=in
13 14
 
14 15
 returned html cannot be parsed by browser
15 16
 http://blog.zacharyvoase.com/2010/11/11/sockets-and-nodes-i/
15  test/grab-pages.rb
@@ -41,12 +41,15 @@ def parse_rss(feed)
41 41
     def run
42 42
       dir = File.expand_path('../pages', __FILE__)
43 43
       FileUtils.mkdir(dir) unless File.exists? dir
44  
-
45  
-      parse_rss(fetch_digg_feed) do |url, title|
46  
-        filename = title.gsub(/\W/, '_') + '.html'
47  
-        filepath = File.join(dir, filename)
48  
-        puts "fetching #{url} as #{filepath}"
49  
-        puts `curl #{url} > #{filepath} &`
  44
+      
  45
+      [fetch_digg_feed, fetch_hackernews_feed, fetch_delicious_feed].each do |feed|
  46
+        parse_rss(feed) do |url, title|
  47
+          filename = title.gsub(/\W/, '_') + '.html'
  48
+          filepath = File.join(dir, filename)
  49
+          puts "fetching #{url} as #{filepath}"
  50
+          puts `curl --connect-timeout=5 #{url} > #{filepath} &`
  51
+          sleep 1
  52
+        end
50 53
       end
51 54
     end
52 55
     
24  test/jsdom-bug.js
@@ -17,3 +17,27 @@ node.parentNode.removeChild(node);
17 17
 console.log(''+all[i]); //still P#p1. the live NodeList wasn't updated properly
18 18
 all.length; //trigger a refresh. the length getter calls update()
19 19
 console.log(''+all[i]); //P#p2 OK
  20
+
  21
+
  22
+// innerHTML = '' doesn't removed all children
  23
+// https://github.com/tmpvar/jsdom/issues/#issue/80
  24
+(function() {
  25
+  var jsdom = require('jsdom');
  26
+  var html = '<html><body><p id="p1"></p><p id="p2"></p></body></html>';
  27
+  var doc = jsdom.jsdom(html);
  28
+  var win = doc.createWindow();
  29
+  var b = doc.body;
  30
+  b.innerHTML = '';
  31
+  console.log(b.innerHTML); //<p id="p2"></p>
  32
+
  33
+  var arr = [0, 1, 2, 3, 4, 5];
  34
+  arr.forEach(function(v, i) {
  35
+  	console.log('[', i, '] ==', v);
  36
+  	arr.splice(i, 1);
  37
+  });
  38
+  // output
  39
+  // [ 0 ] == 0
  40
+  // [ 1 ] == 2
  41
+  // [ 2 ] == 4
  42
+
  43
+})();

0 notes on commit ed2c364

Please sign in to comment.
Something went wrong with that request. Please try again.