This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Benchmark = require('benchmark'); | |
| Benchmark.prototype.setup = function() { | |
| a = ["test"]; | |
| for (var i = 0; i < 10000; i++) { | |
| a.push("some other stuff"); | |
| } | |
| s = a.join(); | |
| re1 = new RegExp("^test"); | |
| re2 = new RegExp("^not there"); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Benchmark = require('benchmark'); | |
| Benchmark.prototype.setup = function() { | |
| a = ["test"]; | |
| for (var i = 0; i < 10000; i++) { | |
| a.push("some other stuff"); | |
| } | |
| s = a.join(); | |
| }; | |
| var suite = new Benchmark.Suite(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Benchmark = require('benchmark'); | |
| Benchmark.prototype.setup = function() { | |
| s = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxtestyyyyyyyyyyyyyyyyyyyyy'; | |
| re = new RegExp('te[xs]t'); | |
| }; | |
| var suite = new Benchmark.Suite(); | |
| // add tests | |
| suite.add('regex test', function() { | |
| var r1 = re.test(s); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function rssPipesFilterFunction(articles) { | |
| return articles.slice(0, 10); | |
| } | |
| /* | |
| * Copyright (c) 2013 Daishi Kato | |
| * Licensed under the MIT License | |
| * http://www.opensource.org/licenses/mit-license.php | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function rssPipesFilterFunction(articles) { | |
| var keywords = ["ABC", "DEF", "GHI"]; | |
| var i, len = keywords.length; | |
| var newArticles = []; | |
| articles.forEach(function(article) { | |
| if (article.title) { | |
| for (i = 0; i < len; i++) { | |
| if (article.title.indexOf(keywords[i]) >= 0) { | |
| newArticles.push(article); | |
| break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function rssPipesFilterFunction(articles) { | |
| var newArticles = []; | |
| articles.forEach(function(article) { | |
| if (article.title && article.title.lastIndexOf('AD:', 0) != 0 && article.title.lastIndexOf('PR:', 0) != 0) { | |
| newArticles.push(article); | |
| } | |
| }); | |
| return newArticles; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function rssPipesFilterFunction(articles) { | |
| var re = new RegExp("http://[\\w\\.]+/[\\w\\.]*"); | |
| articles.forEach(function(article) { | |
| var match = re.exec(article.title); | |
| if (match) { | |
| article.link = match[0]; | |
| } | |
| }); | |
| return articles; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function rssPipesFilterFunction(articles) { | |
| var keywords = ["keyword01", "keyword02", "keyword03"]; | |
| var i, len = keywords.length; | |
| articles.forEach(function(article) { | |
| if (article.title) { | |
| for (i = 0; i < len; i++) { | |
| if (article.title.indexOf(keywords[i]) >= 0) { | |
| article.title = "*** " + article.title; | |
| break; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html> | |
| <head> | |
| <title>canvas test</title> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0" /> | |
| <meta name="apple-mobile-web-app-capable" content="yes" /> | |
| <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> | |
| <style> | |
| html, body { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var FB = require('fb'); | |
| FB.api('oauth/access_token', { | |
| client_id: process.env.FACEBOOK_APP_ID, | |
| client_secret: process.env.FACEBOOK_SECRET, | |
| grant_type: 'client_credentials' | |
| }, function(res) { | |
| if (!res || res.error) { | |
| console.log('error occurred when getting access token:', res && res.error); | |
| return; |
OlderNewer