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
| select 'Last 30 Days', sum(measure1) | |
| from time t, fact f | |
| where f.timeid = t.timeid | |
| and | |
| f.date between applib.add_days(current_date, -30) and current_date | |
| UNION ALL | |
| select 'Current Month', sum(measure1) | |
| from time t, fact f | |
| where f.timeid = t.timeid | |
| and t.month = applib.extract_timestamp(current_timestamp, 'MONTH')+1 |
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
| console.log("Fetching docs..."); | |
| var j = 0; | |
| var docs = []; | |
| var ids = []; | |
| nano.list({ stale: "ok" }, function(err, data, headers){ | |
| console.log("Updating " + data.rows.length + " docs..."); | |
| for (var i = 0; i < data.rows.length; i++) { | |
| ids.push(data.rows[i].id); | |
| } | |
| }); |
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
| console.log("Fetching docs..."); | |
| var j = 0; | |
| var docs = []; | |
| var ids = []; | |
| nano.list({ stale: "ok" }, function(err, data, headers){ | |
| console.log("Updating " + data.rows.length + " docs..."); | |
| for (var i = 0; i < data.rows.length; i++) { | |
| ids.push(data.rows[i].id); | |
| } | |
| }); |
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
| console.log("Fetching docs..."); | |
| var j = 0; | |
| var docs = []; | |
| var startdoc = '0'; | |
| function fetchdocs(){ | |
| nano.list({ stale: "ok", startkey:startdoc, limit:2000, include_docs:true}, function(err, data, headers){ | |
| console.log("Updating " + data.rows.length + " docs..."); | |
| for (var i = 0; i < data.rows.length; i++) { | |
| var doc = data.rows[i].doc; | |
| //console.log(doc); |
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 request = require('request').defaults({json: true}), | |
| transfuse = require('transfuse'), | |
| JSONStream = require('JSONStream'); | |
| function transform(couchdb, funcString, headers) { | |
| var down = request({url: couchdb + '/_all_docs?include_docs=true'}), | |
| up = request({url: couchdb + '/_bulk_docs', method: "POST", headers: headers}), | |
| tr = transfuse(['rows', /./, 'doc'], funcString, JSONStream.stringify("{\"docs\":[\n", "\n,\n", "\n]}\n")); | |
| down.pipe(tr) | |
| tr.pipe(up) |
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
| { | |
| "Jan 27 2012 11:03": "139990", | |
| "Jan 27 2012 11:04": "153905", | |
| "Jan 27 2012 11:05": "153666", | |
| "Jan 27 2012 11:06": "150723", | |
| "Jan 27 2012 11:07": "145660", | |
| "Jan 27 2012 11:08": "85044" | |
| } |
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
| #!/usr/bin/python | |
| # inspired by http://www.thinkgeek.com/homeoffice/e9cb/ | |
| import random | |
| if random.randint(0, 1) == 0: | |
| print "Cat is dead. :(" | |
| else: | |
| print "Cat is alive! :)" |
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
| #!/usr/bin/python | |
| import random | |
| import sys | |
| print random.choice(sys.argv[1:]) |
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
| json2csv.py | |
| real 5m28.824s | |
| user 5m27.584s | |
| sys 0m1.524s | |
| C (https://github.com/jehiah/json2csv) | |
| real 0m15.945s | |
| user 0m15.181s | |
| sys 0m1.204s |
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
| Perl | |
| real 12m35.264s | |
| user 8m45.136s | |
| sys 3m29.606s | |
| Python | |
| real 33m28.333s | |
| user 31m40.628s | |
| sys 1m25.188s |