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 EventsEmitter = require('events').EventEmitter; | |
| pg.connect(..., function(err, client, done) { | |
| var pageSize = 50; | |
| var emitter = new EventsEmitter(); | |
| emitter.on('next', function(offset) { | |
| callHandlersPaginated(offset); | |
| }); | |
| emitter.on('end', function() { |
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
| // same as previous gist, but now via 'async' library | |
| var async = require('async'); | |
| // some dummy rows | |
| var rows = []; | |
| for (var i = 0; i < 10000; i++) { | |
| rows.push("this is row " + i); | |
| } |
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
| // some dummy rows | |
| var rows = []; | |
| for (var i = 0; i < 10000; i++) { | |
| rows.push("this is row " + i); | |
| } | |
| var index = 0; | |
| var currentlyRunning = 0, maxRunning = 200; | |
| function callHandler(row, cb) { |
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 floor(i, n) { | |
| var r = i % n; | |
| return i - r; | |
| }; | |
| function floorToHours(date, nHours) { | |
| var hourInMillis = 1000 * 60 * 60; | |
| var dateInMillis = date.valueOf(); | |
| return new Date(floor(dateInMillis, nHours * hourInMillis)); | |
| }; |
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
| // credit: http://rzrsharp.net/2011/06/27/what-does-coffeescripts-do-do.html | |
| var closures = []; | |
| function createClosures() { | |
| for (var i = 0; i < 5; i++) { | |
| closures[i] = function() { | |
| console.log("i=" + i); | |
| } | |
| } | |
| } |
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
| module CopyableAttributes | |
| def self.included(base) | |
| def copyable_attributes_keys2 | |
| attributes.keys - self.class.protected_attributes.to_a - [ "created_at", "updated_at"] - foreign_key_list | |
| # TODO: we also need to remove foreign keys... maybe have class method 'uncopyable_attributes_keys'? | |
| end | |
| private | |
| def relevant_base_class |
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
| /* fun exercise around aunt Lily and her cats... */ | |
| (function (owner) { | |
| function randomInt(i) { | |
| return Math.floor(Math.random() * i); | |
| } | |
| function randomText() { | |
| var texts = [ |
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
| <!-- | |
| see also: https://github.com/blueimp/jQuery-File-Upload/issues/473 | |
| This didn't work with an 'old' version of the plugin, try the latest one. | |
| Idea is to do file upload all programmatically, thus only sending files once user has confirmed what to do with the files. | |
| --> | |
| <div class="row"> | |
| <div class="span10"> |
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
| diff --git a/grails-app/views/layouts/main.gsp b/grails-app/views/layouts/main.gsp | |
| index 4e70434..8d3dcae 100644 | |
| --- a/grails-app/views/layouts/main.gsp | |
| +++ b/grails-app/views/layouts/main.gsp | |
| @@ -12,14 +12,23 @@ | |
| <link rel="shortcut icon" href="${resource(dir: 'images', file: 'favicon.ico')}" type="image/x-icon"> | |
| <link rel="apple-touch-icon" href="${resource(dir: 'images', file: 'apple-touch-icon.png')}"> | |
| <link rel="apple-touch-icon" sizes="114x114" href="${resource(dir: 'images', file: 'apple-touch-icon-retina.png')}"> | |
| + <link rel="stylesheet" href="/todo/css/bootstrap.css" /> | |
| <!-- <link rel="stylesheet" href="${resource(dir: 'css', file: 'main.css')}" type="text/css"> --> |
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>Just testing...</title> | |
| </head> | |
| <body> | |
| <script type="text/javascript"> | |
| function updateFile() { | |
| var files = document.getElementById("uploadInput").files; | |
| var nFiles = files.length; |