<commit_before>/// <reference path="//Microsoft.WinJS.2.0/js/base.js" />
/// <reference path="//Microsoft.WinJS.2.0/js/ui.js" />
(function () {
    "use strict";

    WinJS.Namespace.define("WinJSContrib.UI", {
        TabPages: WinJS.Class.define(
            // Define the constructor function for the PageControlNavigator.
            function TabPages(element, options) {
                var ctrl = this;
                options = options || {};
                ctrl.element = element || document.createElement("div");
                ctrl.element.className = 'mcn-tabpages ' + ctrl.element.className;
                if (WinJSContrib.CrossPlatform && WinJSContrib.CrossPlatform.crossPlatformClass)
                    WinJSContrib.CrossPlatform.crossPlatformClass(ctrl.element);
                ctrl.tabHeader = options.header || element.querySelector('.mcn-tabpages-header');
                ctrl.tabHeaderTemplate = options.headerTemplate;
                ctrl.tabContent = options.content || element.querySelector('.mcn-tabpages-content');
                ctrl.tabLinkUri = options.uri;
                ctrl.tabLinkArgs = options.args;
                ctrl.tabs = {
                    "default": []
                };

                if (!ctrl.tabContent) {
                    ctrl.tabContent = document.createElement('DIV');
                    ctrl.tabContent.className = 'mcn-tabpages-content';
                    ctrl.element.appendChild(ctrl.tabContent);
                }
                ctrl.navigator = new WinJSContrib.UI.PageControlNavigator(ctrl.tabContent, { global: false, delay: 10, disableHistory: true });
                ctrl.navigator.animationWaitForPreviousPageClose = false;
                ctrl.navigator.animations.exitPage = WinJSContrib.UI.Animation.tabExitPage;
                ctrl.navigator.animations.enterPage = WinJSContrib.UI.Animation.tabEnterPage;

                if (!ctrl.tabHeader) {
                    ctrl.tabHeader = document.createElement('DIV');
                    ctrl.tabHeader.className = 'mcn-tabpages-header';
                    ctrl.element.appendChild(ctrl.tabHeader);
                }

                ctrl._createGroupHeader('default');

                if (options.registerTabs) {
                    ctrl.registerTabs();
                }

                if (options.swipeSlide && WinJSContrib.UI.SwipeSlide) {
                    ctrl.setSwipeSlideOnDefaultTab(options.rightbar);
                }

            }, {
                _createGroupHeader: function (group) {
                    var ctrl = this;
                    if (ctrl.tabs[group] && ctrl.tabs[group].tabGroup)
                        return;

                    var defaultgroup = document.createElement('DIV');
                    defaultgroup.className = 'header-group-' + group + ' mcn-tabpages-headergroup';
                    if (!ctrl.tabs[group])
                        ctrl.tabs[group] = [];

                    ctrl.tabs[group].tabGroup = defaultgroup;
                    ctrl.tabHeader.appendChild(defaultgroup);
                },

                setSwipeRightbar: function () {
                    var ctrl = this;
                    ctrl.left = 'right';
                    ctrl.right = 'left';
                },

                setSwipeSlideOnDefaultTab: function (rightbar) {
                    var ctrl = this;

                    if (rightbar) {
                        ctrl.setSwipeRightbar();
                    }
                    else {
                        ctrl.left = 'left';
                        ctrl.right = 'right';
                    }

                    ctrl.swipeSlide = new WinJSContrib.UI.SwipeSlide(ctrl.tabContent);
                    ctrl.navigator.animations.exitPage = function (elt) { return WinJSContrib.UI.Animation.fadeOut(elt, { duration: 100 }) };

                    ctrl.swipeSlide.onswipe = function (arg) {
                        var targetStyle = ctrl.swipeSlide.target.style;
                        if (targetStyle.hasOwnProperty('webkitTransform')) {
                            console.log('running on webkit');
                        }

                        ctrl.swipeSlide.swipeHandled = true;
                        if (ctrl.currentTab && ctrl.navigator.pageElement) {
                            var pageElt = ctrl.navigator.pageElement;
                            pageElt.style.transform = targetStyle.transform;
                            if (targetStyle.hasOwnProperty('webkitTransform')) {
                                pageElt.style.webkitTransform = targetStyle.webkitTransform;
                                targetStyle.webkitTransform = '';
                            }
                            targetStyle.transform = '';

                            if (arg.detail.direction == 'left') {
                                pageElt.winControl.getAnimationElements = function () { return null; }
                                //ctrl.navigator.pageElement.exitPage = function () { return WinJS.Promise.wrap(); };
                                WinJSContrib.UI.Animation.slideToLeft(pageElt);
                            }
                            else if (arg.detail.direction == 'right') {
                                pageElt.winControl.getAnimationElements = function () { return null; }
                                //ctrl.navigator.pageElement.exitPage = function () { return WinJS.Promise.wrap(); };
                                WinJSContrib.UI.Animation.slideToRight(pageElt);
                            }
                            //ctrl.navigator.pageElement.style.opacity = 0;
                        }
                        targetStyle.transform = '';
                        if (targetStyle.hasOwnProperty('webkitTransform'))
                            targetStyle.webkitTransform = '';

                        if (ctrl.currentTab == null)
                            ctrl.selectFirst();

                        else if (arg.detail.direction == 'right') {
                            ctrl.navigator.animations.enterPage = function () {
                                return WinJSContrib.UI.Animation.slideFromLeft(ctrl.tabContent);
                            }

                            if (ctrl.currentTab.index == 0) {
                                ctrl.selectByIndex(ctrl.tabs.default.length - 1)
                            }
                            else {
                                ctrl.selectByIndex(ctrl.currentTab.index - 1);
                            }

                        } else if (arg.detail.direction == 'left') {
                            ctrl.navigator.animations.enterPage = function () {
                                return WinJSContrib.UI.Animation.slideFromRight(ctrl.tabContent);
                            }

                            if (ctrl.currentTab.index == ctrl.tabs.default.length - 1) {
                                ctrl.selectByIndex(0)
                            }
                            else {
                                ctrl.selectByIndex(ctrl.currentTab.index + 1);
                            }

                        }

                    }

                },

                getPageLinkArgs: function (tab) {
                    var ctrl = this;
                    return tab.link.args || ctrl.tabLinkArgs;
                },

                getPageLink: function (tab) {
                    var ctrl = this;
                    if (tab.link.uri || ctrl.tabLinkUri) {
                        return { uri: tab.link.uri || ctrl.tabLinkUri, args: ctrl.getPageLinkArgs(tab) };
                    }
                },

                selectFirst: function (skipHeader) {
                    this.selectTab(this.tabs.default[0], skipHeader);
                },

                selectTab: function (tab, skipHeader) {
                    var ctrl = this;

                    if (tab == ctrl.currentTab)
                        return;

                    var link = ctrl.getPageLink(tab);
                    if (link) {
                        ctrl.navigator.open(link.uri, link.args);
                        ctrl.currentTab = tab;
                        var currentHeader = ctrl.tabHeader.querySelector('.mcn-tabpages-headeritem.current');
                        if (currentHeader) WinJS.Utilities.removeClass(currentHeader, 'current');

                        if (!skipHeader)
                            ctrl.selectTabHeader();
                    }
                },

                selectTabHeader: function () {
                    var ctrl = this;
                    if (ctrl.currentTab) {
                        WinJS.Utilities.addClass(ctrl.currentTab.element, 'current');
                    }
                },

                selectByIndex: function (index, skipHeader, group) {
                    var ctrl = this;

                    var grp = ctrl.tabs[group || 'default'];
                    var tab = grp[index];

                    if (tab)
                        ctrl.selectTab(tab, skipHeader);
                },

                selectByItem: function (item, skipHeader, group) {
                    var ctrl = this;
                    var grp = ctrl.tabs[group || 'default'];
                    for (var i = 0 ; i < grp.length; i++) {
                        var tab = grp[i];
                        if (tab.item == item) {
                            ctrl.selectTab(tab, skipHeader);
                            break;
                        }
                    }
                },

                registerTabs: function (tabItems, group) {
                    var ctrl = this;
                    var grp = ctrl.tabs[group || 'default'];
                    if (!grp) {
                        ctrl._createGroupHeader(group);
                        grp = ctrl.tabs[group];
                    }

                    var tabElements = ctrl.element.querySelectorAll('.mcn-tabpages-headeritem');
                    for (var i = 0 ; i < tabElements.length; i++) {
                        var element = tabElements[i];
                        (function (element) {
                            var tab = {
                                element: element,
                                link: {
                                    uri: element.getAttribute('data-tabtarget')
                                }
                            };
                            element.mcnTab = tab;
                            grp.tabGroup.appendChild(element);
                            tab.index = grp.length;
                            tab.group = group;
                            grp.push(tab);
                            $(tab.element).tap(function () {
                                ctrl.selectTab(tab);
                            });
                        })(element);
                    }
                },

                addTab: function (tabItem, group) {
                    this.addTabs([tabItem], group);
                },

                addTabs: function (tabItems, group) {
                    var ctrl = this;
                    var grp = ctrl.tabs[group || 'default'];
                    if (!grp) {
                        ctrl._createGroupHeader(group);
                        grp = ctrl.tabs[group];
                    }

                    var container = grp.tabGroup;
                    var template = ctrl.tabHeaderTemplate;
                    if (template)
                        template = WinJSContrib.Utils.getTemplate(template);

                    tabItems.forEach(function (tabitem) {
                        var tabelt = document.createElement('DIV');
                        tabelt.className = 'mcn-tabpages-headeritem';
                        container.appendChild(tabelt);

                        var tab = {
                            element: tabelt,
                            item: tabitem,
                            link: {
                                uri: tabitem.uri || tabitem.href || ctrl.tabLinkUri,
                                args: tabitem.args || null,
                                oninvoked: tabitem.invoked
                            }
                        };

                        tabelt.mcnTab = tab;
                        tab.index = grp.length;
                        tab.group = group;
                        grp.push(tab);
                        $(tabelt).tap(function () {
                            if (tab.link.oninvoked) {
                                tab.link.oninvoked(ctrl, tab);
                            }
                            else {
                                ctrl.selectTab(tab);
                            }
                        });

                        template.render(tabitem).done(function (rendered) {
                            while (rendered.children.length > 0) {
                                tabelt.appendChild(rendered.children[0]);
                            }

                        });
                    });
                },

            })
    });
})();
<commit_msg>tab update<commit_after>
/// <reference path="//Microsoft.WinJS.2.0/js/base.js" />
/// <reference path="//Microsoft.WinJS.2.0/js/ui.js" />
(function () {
    "use strict";

    WinJS.Namespace.define("WinJSContrib.UI", {
        TabPages: WinJS.Class.define(
            // Define the constructor function for the PageControlNavigator.
            function TabPages(element, options) {
                var ctrl = this;
                options = options || {};
                ctrl.element = element || document.createElement("div");
                ctrl.element.className = 'mcn-tabpages ' + ctrl.element.className;
                if (WinJSContrib.CrossPlatform && WinJSContrib.CrossPlatform.crossPlatformClass)
                    WinJSContrib.CrossPlatform.crossPlatformClass(ctrl.element);
                ctrl.tabHeader = options.header || element.querySelector('.mcn-tabpages-header');
                ctrl.tabHeaderTemplate = options.headerTemplate;
                ctrl.tabContent = options.content || element.querySelector('.mcn-tabpages-content');
                ctrl.tabLinkUri = options.uri;
                ctrl.tabLinkArgs = options.args;
                ctrl.tabs = {
                    "default": []
                };

                if (!ctrl.tabContent) {
                    ctrl.tabContent = document.createElement('DIV');
                    ctrl.tabContent.className = 'mcn-tabpages-content';
                    ctrl.element.appendChild(ctrl.tabContent);
                }
                ctrl.navigator = new WinJSContrib.UI.PageControlNavigator(ctrl.tabContent, { global: false, delay: 10, disableHistory: true });
                ctrl.navigator.animationWaitForPreviousPageClose = false;
                ctrl.navigator.animations.exitPage = WinJSContrib.UI.Animation.tabExitPage;
                ctrl.navigator.animations.enterPage = WinJSContrib.UI.Animation.tabEnterPage;

                if (!ctrl.tabHeader) {
                    ctrl.tabHeader = document.createElement('DIV');
                    ctrl.tabHeader.className = 'mcn-tabpages-header';
                    ctrl.element.appendChild(ctrl.tabHeader);
                }

                ctrl._createGroupHeader('default');

                if (options.registerTabs) {
                    ctrl.registerTabs();
                }

                if (options.swipeSlide && WinJSContrib.UI.SwipeSlide) {
                    ctrl.setSwipeSlideOnDefaultTab(options.rightbar);
                }

            }, {
                _createGroupHeader: function (group) {
                    var ctrl = this;
                    if (ctrl.tabs[group] && ctrl.tabs[group].tabGroup)
                        return;

                    var defaultgroup = document.createElement('DIV');
                    defaultgroup.className = 'header-group-' + group + ' mcn-tabpages-headergroup';
                    if (!ctrl.tabs[group])
                        ctrl.tabs[group] = [];

                    ctrl.tabs[group].tabGroup = defaultgroup;
                    ctrl.tabHeader.appendChild(defaultgroup);
                },

                setSwipeRightbar: function () {
                    var ctrl = this;
                    ctrl.left = 'right';
                    ctrl.right = 'left';
                },

                setSwipeSlideOnDefaultTab: function (rightbar) {
                    var ctrl = this;

                    if (rightbar) {
                        ctrl.setSwipeRightbar();
                    }
                    else {
                        ctrl.left = 'left';
                        ctrl.right = 'right';
                    }

                    ctrl.swipeSlide = new WinJSContrib.UI.SwipeSlide(ctrl.tabContent);
                    ctrl.navigator.animations.exitPage = function (elt) { return WinJSContrib.UI.Animation.fadeOut(elt, { duration: 100 }) };

                    ctrl.swipeSlide.onswipe = function (arg) {
                        var targetStyle = ctrl.swipeSlide.target.style;
                        if (targetStyle.hasOwnProperty('webkitTransform')) {
                            console.log('running on webkit');
                        }

                        ctrl.swipeSlide.swipeHandled = true;
                        if (ctrl.currentTab && ctrl.navigator.pageElement) {
                            var pageElt = ctrl.navigator.pageElement;
                            pageElt.style.transform = targetStyle.transform;
                            if (targetStyle.hasOwnProperty('webkitTransform')) {
                                pageElt.style.webkitTransform = targetStyle.webkitTransform;
                                targetStyle.webkitTransform = '';
                            }
                            targetStyle.transform = '';

                            if (arg.detail.direction == 'left') {
                                pageElt.winControl.getAnimationElements = function () { return null; }
                                //ctrl.navigator.pageElement.exitPage = function () { return WinJS.Promise.wrap(); };
                                WinJSContrib.UI.Animation.slideToLeft(pageElt);
                            }
                            else if (arg.detail.direction == 'right') {
                                pageElt.winControl.getAnimationElements = function () { return null; }
                                //ctrl.navigator.pageElement.exitPage = function () { return WinJS.Promise.wrap(); };
                                WinJSContrib.UI.Animation.slideToRight(pageElt);
                            }
                            //ctrl.navigator.pageElement.style.opacity = 0;
                        }
                        targetStyle.transform = '';
                        if (targetStyle.hasOwnProperty('webkitTransform'))
                            targetStyle.webkitTransform = '';

                        if (ctrl.currentTab == null)
                            ctrl.selectFirst();

                        else if (arg.detail.direction == 'right') {
                            ctrl.navigator.animations.enterPage = function () {
                                return WinJSContrib.UI.Animation.slideFromLeft(ctrl.tabContent);
                            }

                            if (ctrl.currentTab.index == 0) {
                                ctrl.selectByIndex(ctrl.tabs.default.length - 1)
                            }
                            else {
                                ctrl.selectByIndex(ctrl.currentTab.index - 1);
                            }

                        } else if (arg.detail.direction == 'left') {
                            ctrl.navigator.animations.enterPage = function () {
                                return WinJSContrib.UI.Animation.slideFromRight(ctrl.tabContent);
                            }

                            if (ctrl.currentTab.index == ctrl.tabs.default.length - 1) {
                                ctrl.selectByIndex(0)
                            }
                            else {
                                ctrl.selectByIndex(ctrl.currentTab.index + 1);
                            }

                        }

                    }

                },

                getPageLinkArgs: function (tab) {
                    var ctrl = this;
                    return tab.link.args || ctrl.tabLinkArgs;
                },

                getPageLink: function (tab) {
                    var ctrl = this;
                    if (tab.link.uri || ctrl.tabLinkUri) {
                        return { uri: tab.link.uri || ctrl.tabLinkUri, args: ctrl.getPageLinkArgs(tab) };
                    }
                },

                selectFirst: function (skipHeader) {
                    this.selectTab(this.tabs.default[0], skipHeader);
                },

                selectTab: function (tab, skipHeader, args) {
                    var ctrl = this;

                    if (tab == ctrl.currentTab)
                        return;

                    var link = ctrl.getPageLink(tab);
                    if (link) {
                        var navArgs = $.extend({}, args, link.args);

                        ctrl.navigator.open(link.uri, navArgs);
                        ctrl.currentTab = tab;
                        var currentHeader = ctrl.tabHeader.querySelector('.mcn-tabpages-headeritem.current');
                        if (currentHeader) WinJS.Utilities.removeClass(currentHeader, 'current');

                        if (!skipHeader)
                            ctrl.selectTabHeader();
                    }
                },

                selectTabHeader: function () {
                    var ctrl = this;
                    if (ctrl.currentTab) {
                        WinJS.Utilities.addClass(ctrl.currentTab.element, 'current');
                    }
                },

                selectByIndex: function (index, skipHeader, group, args) {
                    var ctrl = this;

                    var grp = ctrl.tabs[group || 'default'];
                    var tab = grp[index];

                    if (tab)
                        ctrl.selectTab(tab, skipHeader, args);
                },

                selectByName: function (name, skipHeader, group, args) {
                    var ctrl = this;

                    var grp = ctrl.tabs[group || 'default'];
                    for (var i = 0 ; i < grp.length; i++) {
                        var tab = grp[i];
                        if (tab.item && (tab.item.id === name || tab.item.name === name)) {
                            ctrl.selectTab(tab, skipHeader, args);
                            break;
                        }
                    }
                },

                selectByItem: function (item, skipHeader, group, args) {
                    var ctrl = this;
                    var grp = ctrl.tabs[group || 'default'];
                    for (var i = 0 ; i < grp.length; i++) {
                        var tab = grp[i];
                        if (tab.item == item) {
                            ctrl.selectTab(tab, skipHeader, args);
                            break;
                        }
                    }
                },

                registerTabs: function (tabItems, group) {
                    var ctrl = this;
                    var grp = ctrl.tabs[group || 'default'];
                    if (!grp) {
                        ctrl._createGroupHeader(group);
                        grp = ctrl.tabs[group];
                    }

                    var tabElements = ctrl.element.querySelectorAll('.mcn-tabpages-headeritem');
                    for (var i = 0 ; i < tabElements.length; i++) {
                        var element = tabElements[i];
                        (function (element) {
                            var tab = {
                                element: element,
                                link: {
                                    uri: element.getAttribute('data-tabtarget')
                                }
                            };
                            element.mcnTab = tab;
                            grp.tabGroup.appendChild(element);
                            tab.index = grp.length;
                            tab.group = group;
                            grp.push(tab);
                            $(tab.element).tap(function () {
                                ctrl.selectTab(tab);
                            });
                        })(element);
                    }
                },

                addTab: function (tabItem, group) {
                    this.addTabs([tabItem], group);
                },

                addTabs: function (tabItems, group) {
                    var ctrl = this;
                    var grp = ctrl.tabs[group || 'default'];
                    if (!grp) {
                        ctrl._createGroupHeader(group);
                        grp = ctrl.tabs[group];
                    }

                    var container = grp.tabGroup;
                    var template = ctrl.tabHeaderTemplate;
                    if (template)
                        template = WinJSContrib.Utils.getTemplate(template);

                    tabItems.forEach(function (tabitem) {
                        var tabelt = document.createElement('DIV');
                        tabelt.className = 'mcn-tabpages-headeritem';
                        container.appendChild(tabelt);

                        var tab = {
                            element: tabelt,
                            item: tabitem,
                            link: {
                                uri: tabitem.uri || tabitem.href || ctrl.tabLinkUri,
                                args: tabitem.args || null,
                                oninvoked: tabitem.invoked
                            }
                        };

                        tabelt.mcnTab = tab;
                        tab.index = grp.length;
                        tab.group = group;
                        grp.push(tab);
                        $(tabelt).tap(function () {
                            if (tab.link.oninvoked) {
                                tab.link.oninvoked(ctrl, tab);
                            }
                            else {
                                ctrl.selectTab(tab);
                            }
                        });

                        template.render(tabitem).done(function (rendered) {
                            while (rendered.children.length > 0) {
                                tabelt.appendChild(rendered.children[0]);
                            }

                        });
                    });
                },

            })
    });
})();
<|endoftext|>


<commit_before>var child_process = require('child_process')
var fs = require('fs');
var max_sleep = 300
var step = 10
//Added a comment that achieves no real goal.
//Non-blocking loop
//Adjustable step
//Status line
//Add a rough time indicator
//First cut at libfaketime support

var commit_messages = [
  "Fixing an important issue with the universe.",
  "Someone poisoned the waterhole!",
  "You feeling lucky punk?",
  "Five bullets or six?",
  "Fixed memory parsing error #1337",
  "Cleaned out the intertubes",
  "AAAAAAAAAAARGH!",
  "Fixed a typo",
  "Updated the readme",
  "Fixing a typo added in the last readme update",
  "GET A HAIRCUT!",
  "Updated the readme again",
  "Found an issue with the letter 'a', so I fixed it.",
  "Incompatible dimensions found, Cthuhlu Error 666",
  "Who you calling a fool?",
  "How many more of these can I make?",
  "Fixing an error introduced in the last commit",
  "Re-updating the readme.",
  "Work in Progress",
  "WIP",
  "Quick fix",
  "Grammar fix",
  "Fixing punctuation",
  "Correcting style",
  "Logic error",
  "Almost there",
  "Nearly got it",
  "Not quite working",
  "Ooops!",
  "Did I do that?",
  "Commit all the required changes",
  "Really commit all the required changes",
  "Should work now",
  "Back out the last commit",
  "Reverting changes",
  "One more time...",
  "Re-commiting last",
  "One more User Story done",
  "Can work my way through the Kanban",
  "Sprint complete",
  "Well that seemed pretty easy",
  "What do you mean you can't pack up the commit?",
  "Merge in master",
  "Fast-forwarding changes"
]

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[ 2 ]
  var outFile = process.argv[ 3 ]
  if (inFile == outFile) {
    console.error("Aborted: infile and outfile must be different")
    return(-1);
  }
  if (process.argv [ 4 ]) max_sleep = process.argv [ 4 ]
  if (process.argv [ 5 ]) step = parseInt(process.argv [ 5 ])
  console.info("Writing from %s to %s, with up to %s seconds between commits of %s bytes", inFile, outFile, max_sleep, step)
  var outFD = fs.openSync(outFile, 'w')
  fs.readFile(inFile, function(err,data) {
    var length = data.length
    var commit_count = Math.ceil(length / step)
    var commit_time = commit_count * max_sleep / 2
    var commit_time_hour = Math.floor(commit_time / 3600)
    var commit_time_rem = commit_time - (commit_time_hour * 3600)
    var commit_time_min = Math.floor(commit_time_rem / 60)
    var commit_time_sec = commit_time_rem - (commit_time_min * 60)
    console.info("Input file is %s Bytes, this will generate %s commits and take approximately %s hours %s minutes %s seconds", length, commit_count, commit_time_hour, commit_time_min, commit_time_sec)
    var t_offset = 0
    if (process.env.FAKETIME) {
      // 20% buffer, to reduce the likelihood of going in to the future
      t_offset = commit_time * -1.2;
      faketime(t_offset);
    }
    try {
      child_process.execFileSync('git', ['add', outFile])
    } catch (e) {
      console.error("Couldn't add %s to git: %s", outFile, e)
    }
    var counter = 0
    process.stdout.write("Queueing up the first commit...\r");
    var timeout;
    if (process.env.FAKETIME) {
      faketime(t_offset);
      timeout = 20;
    } else {
      timeout = randomIntFromInterval(0, max_sleep) * 1000
    }
    setTimeout(commit, timeout, t_offset, outFD, outFile, data, counter, length);
  })
} else {
  console.info("Usage:")
  console.info("node commit.js infile outfile [max_time_in_seconds] [step]")
}

function sleep(seconds) {
  var endTime = new Date().getTime() + (seconds * 1000);
  while (new Date().getTime() <= endTime) {;}
}

function randomIntFromInterval(min,max)
{
   return Math.floor(Math.random()*(max-min+1)+min);
}

function commit(t_offset, outFD, outFile, data, counter, length)
{
  if (counter < length)
  {
    var message = commit_messages[randomIntFromInterval(0, commit_messages.length - 1)]
    var args = ['commit', outFile, '-m', message]
    if (counter + step >= length) step = length - counter
    process.stdout.write("\033[2K Writing " + counter + "/" + length + " bytes: " + message + "\r");
    fs.writeSync(outFD, data.slice(counter, counter+step), 0, step)
    child_process.execFileSync('/Applications/Xcode.app/Contents/Developer/usr/bin/git', args)
<commit_msg>Reverting changes<commit_after>var child_process = require('child_process')
var fs = require('fs');
var max_sleep = 300
var step = 10
//Added a comment that achieves no real goal.
//Non-blocking loop
//Adjustable step
//Status line
//Add a rough time indicator
//First cut at libfaketime support

var commit_messages = [
  "Fixing an important issue with the universe.",
  "Someone poisoned the waterhole!",
  "You feeling lucky punk?",
  "Five bullets or six?",
  "Fixed memory parsing error #1337",
  "Cleaned out the intertubes",
  "AAAAAAAAAAARGH!",
  "Fixed a typo",
  "Updated the readme",
  "Fixing a typo added in the last readme update",
  "GET A HAIRCUT!",
  "Updated the readme again",
  "Found an issue with the letter 'a', so I fixed it.",
  "Incompatible dimensions found, Cthuhlu Error 666",
  "Who you calling a fool?",
  "How many more of these can I make?",
  "Fixing an error introduced in the last commit",
  "Re-updating the readme.",
  "Work in Progress",
  "WIP",
  "Quick fix",
  "Grammar fix",
  "Fixing punctuation",
  "Correcting style",
  "Logic error",
  "Almost there",
  "Nearly got it",
  "Not quite working",
  "Ooops!",
  "Did I do that?",
  "Commit all the required changes",
  "Really commit all the required changes",
  "Should work now",
  "Back out the last commit",
  "Reverting changes",
  "One more time...",
  "Re-commiting last",
  "One more User Story done",
  "Can work my way through the Kanban",
  "Sprint complete",
  "Well that seemed pretty easy",
  "What do you mean you can't pack up the commit?",
  "Merge in master",
  "Fast-forwarding changes"
]

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[ 2 ]
  var outFile = process.argv[ 3 ]
  if (inFile == outFile) {
    console.error("Aborted: infile and outfile must be different")
    return(-1);
  }
  if (process.argv [ 4 ]) max_sleep = process.argv [ 4 ]
  if (process.argv [ 5 ]) step = parseInt(process.argv [ 5 ])
  console.info("Writing from %s to %s, with up to %s seconds between commits of %s bytes", inFile, outFile, max_sleep, step)
  var outFD = fs.openSync(outFile, 'w')
  fs.readFile(inFile, function(err,data) {
    var length = data.length
    var commit_count = Math.ceil(length / step)
    var commit_time = commit_count * max_sleep / 2
    var commit_time_hour = Math.floor(commit_time / 3600)
    var commit_time_rem = commit_time - (commit_time_hour * 3600)
    var commit_time_min = Math.floor(commit_time_rem / 60)
    var commit_time_sec = commit_time_rem - (commit_time_min * 60)
    console.info("Input file is %s Bytes, this will generate %s commits and take approximately %s hours %s minutes %s seconds", length, commit_count, commit_time_hour, commit_time_min, commit_time_sec)
    var t_offset = 0
    if (process.env.FAKETIME) {
      // 20% buffer, to reduce the likelihood of going in to the future
      t_offset = commit_time * -1.2;
      faketime(t_offset);
    }
    try {
      child_process.execFileSync('git', ['add', outFile])
    } catch (e) {
      console.error("Couldn't add %s to git: %s", outFile, e)
    }
    var counter = 0
    process.stdout.write("Queueing up the first commit...\r");
    var timeout;
    if (process.env.FAKETIME) {
      faketime(t_offset);
      timeout = 20;
    } else {
      timeout = randomIntFromInterval(0, max_sleep) * 1000
    }
    setTimeout(commit, timeout, t_offset, outFD, outFile, data, counter, length);
  })
} else {
  console.info("Usage:")
  console.info("node commit.js infile outfile [max_time_in_seconds] [step]")
}

function sleep(seconds) {
  var endTime = new Date().getTime() + (seconds * 1000);
  while (new Date().getTime() <= endTime) {;}
}

function randomIntFromInterval(min,max)
{
   return Math.floor(Math.random()*(max-min+1)+min);
}

function commit(t_offset, outFD, outFile, data, counter, length)
{
  if (counter < length)
  {
    var message = commit_messages[randomIntFromInterval(0, commit_messages.length - 1)]
    var args = ['commit', outFile, '-m', message]
    if (counter + step >= length) step = length - counter
    process.stdout.write("\033[2K Writing " + counter + "/" + length + " bytes: " + message + "\r");
    fs.writeSync(outFD, data.slice(counter, counter+step), 0, step)
    child_process.execFileSync('/Applications/Xcode.app/Contents/Developer/usr/bin/git', args)
 <|endoftext|>


<commit_before>var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Gnip 30-Day Search' });
});

module.exports = router;
<commit_msg>Update index.js<commit_after>var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Twitter 30-Day Search' });
});

module.exports = router;
<|endoftext|>


<commit_before>var fs = require('fs');
var child_process = require('child_process')
var max_sleep = 300

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[ 2 ]
  var outFile = process.argv[ 3 ]
  if (process.argv [ 4 ]) max_sleep = process.argv [ 4 ]
  console.info("Writing from %s to %s, with up to %s seconds between commits", inFile, outFile, max_sleep)
  var outFD = fs.openSync(outFile, 'w')
  fs.readFile(inFile, function(err,data) {
    var length = data.length
    console.info("Bytes: %s", length)
    try {
      child_process.execFileSync('/usr/bin/git', ['add', outFile])
    } catch (e) {
      console.error("Couldn't add %s to git: %s", outFile, e)
    }
    var args = ['commit', outFile, '-m', 'Update character']
    for (var counter = 0; counter < length; counter++)
    {
      fs.writeSync(outFD, data.slice(counter, counter+1), 0, 1)
      sleep(Math.random() * max_sleep)
      child_process.execFileS<commit_msg>Update character<commit_after>var fs = require('fs');
var child_process = require('child_process')
var max_sleep = 300

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[ 2 ]
  var outFile = process.argv[ 3 ]
  if (process.argv [ 4 ]) max_sleep = process.argv [ 4 ]
  console.info("Writing from %s to %s, with up to %s seconds between commits", inFile, outFile, max_sleep)
  var outFD = fs.openSync(outFile, 'w')
  fs.readFile(inFile, function(err,data) {
    var length = data.length
    console.info("Bytes: %s", length)
    try {
      child_process.execFileSync('/usr/bin/git', ['add', outFile])
    } catch (e) {
      console.error("Couldn't add %s to git: %s", outFile, e)
    }
    var args = ['commit', outFile, '-m', 'Update character']
    for (var counter = 0; counter < length; counter++)
    {
      fs.writeSync(outFD, data.slice(counter, counter+1), 0, 1)
      sleep(Math.random() * max_sleep)
      child_process.execFileSy<|endoftext|>


<commit_before>angular.module('routes', ['ui.router'])
  .controller('home', require('./controllers/home'))
  .controller('login', require('./controllers/login'))
  .config(function($stateProvider) {
    $stateProvider
      .state('home', {
        url: '/',
        controller: 'home',
        template: require('./views/home'),

        // This is an example of a resolve
        // It is commented out, because it will cause the route to fail
        //
        // resolve: {
        //   things: function(CoolThings) {
        //     return CoolThings.getList()
        //   }
        // }
      })
      .state('login', {
        url: '/login',
        template: require('./views/login'),
        controller: 'login',
      })
  })<commit_msg>Added various routes for some of the new views.<commit_after>angular.module('routes', ['ui.router'])
  .controller('home', require('./controllers/home'))
  .controller('login', require('./controllers/login'))
  .config(function($stateProvider) {
    $stateProvider
      .state('home', {
        url: '/',
        controller: 'home',
        template: require('./views/home'),

        // This is an example of a resolve
        // It is commented out, because it will cause the route to fail
        //
        // resolve: {
        //   things: function(CoolThings) {
        //     return CoolThings.getList()
        //   }
        // }
      })
      .state('login', {
        url: '/login',
        template: require('./views/login'),
        controller: 'login',
      })
      // Users
      .state('user', {
        url: '/user',
        template: require('./views/user'),
        controller: 'user',
      })
      // Admins
      .state('admin', {
        url: '/admin',
        template: require('./views/admin'),
        controller: 'admin',
      })
      // Organizations
      .state('orgs', {
        url: '/orgs',
        template: require('./views/orgs'),
        controller: 'orgs',
      })
      // Modules
      .state('modules', {
        url: '/modules',
        template: require('./views/modules'),
        controller: 'modules',
      })
      // Classes
      //.state('classes', {
      //  url: '/classes',
      //  template: require('./views/classes'),
      //  controller: 'classes',
      //})
      // Courses
      .state('courses', {
        url: '/courses',
        template: require('./views/courses'),
        controller: 'courses',
      })
      // Static about page
      .state('about', {
        url: '/about',
        template: require('./views/about'),
      })

  })<|endoftext|>


<commit_before>var child_process = require('child_process')
var fs = require('fs');
var max_sleep = 300
var step = 10
//Added a comment that achieves no real goal.
//Non-blocking loop
//Adjustable step
//Status line
//Add a rough time indicator
//First cut at libfaketime support

var commit_messages = [
  "Fixing an important issue with the universe.",
  "Someone poisoned the waterhole!",
  "You feeling lucky punk?",
  "Five bullets or six?",
  "Fixed memory parsing error #1337",
  "Cleaned out the intertubes",
  "AAAAAAAAAAARGH!",
  "Fixed a typo",
  "Updated the readme",
  "Fixing a typo added in the last readme update",
  "GET A HAIRCUT!",
  "Updated the readme again",
  "Found an issue with the letter 'a', so I fixed it.",
  "Incompatible dimensions found, Cthuhlu Error 666",
  "Who you calling a fool?",
  "How many more of these can I make?",
  "Fixing an error introduced in the last commit",
  "Re-updating the readme.",
  "Work in Progress",
  "WIP",
  "Quick fix",
  "Grammar fix",
  "Fixing punctuation",
  "Correcting style",
  "Logic error",
  "Almost there",
  "Nearly got it",
  "Not quite working",
  "Ooops!",
  "Did I do that?",
  "Commit all the required changes",
  "Really commit all the required changes",
  "Should work now",
  "Back out the last commit",
  "Reverting changes",
  "One more time...",
  "Re-commiting last",
  "One more User Story done",
  "Can work my way through the Kanban",
  "Sprint complete",
  "Well that seemed pretty easy",
  "What do you mean you can't pack up the commit?",
  "Merge in master",
  "Fast-forwarding changes",
  "Merging in private branch",
  "Time machines are real man!"
]

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[ 2 ]
  var outFile = process.argv[ 3 ]
  if (inFile == outFile) {
    console.error("Aborted: infile and outfile must be different")
    return(-1);
  }
  if (process.argv [ 4 ]) max_sleep = process.argv [ 4 ]
  if (process.argv [ 5 ]) step = parseInt(process.argv [ 5 ])
  console.info("Writing from %s to %s, with up to %s seconds between commits of %s bytes", inFile, outFile, max_sleep, step)
  var outFD = fs.openSync(outFile, 'w')
  fs.readFile(inFile, function(err,data) {
    var length = data.length
    var commit_count = Math.ceil(length / step)
    var commit_time = commit_count * max_sleep / 2
    var commit_time_hour = Math.floor(commit_time / 3600)
    var commit_time_rem = commit_time - (commit_time_hour * 3600)
    var commit_time_min = Math.floor(commit_time_rem / 60)
    var commit_time_sec = commit_time_rem - (commit_time_min * 60)
    console.info("Input file is %s Bytes, this will generate %s commits and take approximately %s hours %s minutes %s seconds", length, commit_count, commit_time_hour, commit_time_min, commit_time_sec)
    var t_offset = 0
    if (process.env.FAKETIME) {
      // 10% buffer, to reduce the likelihood of going in to the future
      t_offset = commit_time * -1.1;
      faketime(t_offset);
    }
    try {
      child_process.execFileSync('git', ['add', outFile])
    } catch (e) {
      console.error("Couldn't add %s to git: %s", outFile, e)
    }
    var counter = 0
    process.stdout.write("Queueing up the first commit...\r");
    var timeout;
    if (process.env.FAKETIME) {
      faketime(t_offset);
      timeout = 20;
    } else {
      timeout = randomIntFromInterval(0, max_sleep) * 1000
    }
    setTimeout(commit, timeout, t_offset, outFD, outFile, data, counter, length);
  <commit_msg>GET A HAIRCUT!<commit_after>var child_process = require('child_process')
var fs = require('fs');
var max_sleep = 300
var step = 10
//Added a comment that achieves no real goal.
//Non-blocking loop
//Adjustable step
//Status line
//Add a rough time indicator
//First cut at libfaketime support

var commit_messages = [
  "Fixing an important issue with the universe.",
  "Someone poisoned the waterhole!",
  "You feeling lucky punk?",
  "Five bullets or six?",
  "Fixed memory parsing error #1337",
  "Cleaned out the intertubes",
  "AAAAAAAAAAARGH!",
  "Fixed a typo",
  "Updated the readme",
  "Fixing a typo added in the last readme update",
  "GET A HAIRCUT!",
  "Updated the readme again",
  "Found an issue with the letter 'a', so I fixed it.",
  "Incompatible dimensions found, Cthuhlu Error 666",
  "Who you calling a fool?",
  "How many more of these can I make?",
  "Fixing an error introduced in the last commit",
  "Re-updating the readme.",
  "Work in Progress",
  "WIP",
  "Quick fix",
  "Grammar fix",
  "Fixing punctuation",
  "Correcting style",
  "Logic error",
  "Almost there",
  "Nearly got it",
  "Not quite working",
  "Ooops!",
  "Did I do that?",
  "Commit all the required changes",
  "Really commit all the required changes",
  "Should work now",
  "Back out the last commit",
  "Reverting changes",
  "One more time...",
  "Re-commiting last",
  "One more User Story done",
  "Can work my way through the Kanban",
  "Sprint complete",
  "Well that seemed pretty easy",
  "What do you mean you can't pack up the commit?",
  "Merge in master",
  "Fast-forwarding changes",
  "Merging in private branch",
  "Time machines are real man!"
]

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[ 2 ]
  var outFile = process.argv[ 3 ]
  if (inFile == outFile) {
    console.error("Aborted: infile and outfile must be different")
    return(-1);
  }
  if (process.argv [ 4 ]) max_sleep = process.argv [ 4 ]
  if (process.argv [ 5 ]) step = parseInt(process.argv [ 5 ])
  console.info("Writing from %s to %s, with up to %s seconds between commits of %s bytes", inFile, outFile, max_sleep, step)
  var outFD = fs.openSync(outFile, 'w')
  fs.readFile(inFile, function(err,data) {
    var length = data.length
    var commit_count = Math.ceil(length / step)
    var commit_time = commit_count * max_sleep / 2
    var commit_time_hour = Math.floor(commit_time / 3600)
    var commit_time_rem = commit_time - (commit_time_hour * 3600)
    var commit_time_min = Math.floor(commit_time_rem / 60)
    var commit_time_sec = commit_time_rem - (commit_time_min * 60)
    console.info("Input file is %s Bytes, this will generate %s commits and take approximately %s hours %s minutes %s seconds", length, commit_count, commit_time_hour, commit_time_min, commit_time_sec)
    var t_offset = 0
    if (process.env.FAKETIME) {
      // 10% buffer, to reduce the likelihood of going in to the future
      t_offset = commit_time * -1.1;
      faketime(t_offset);
    }
    try {
      child_process.execFileSync('git', ['add', outFile])
    } catch (e) {
      console.error("Couldn't add %s to git: %s", outFile, e)
    }
    var counter = 0
    process.stdout.write("Queueing up the first commit...\r");
    var timeout;
    if (process.env.FAKETIME) {
      faketime(t_offset);
      timeout = 20;
    } else {
      timeout = randomIntFromInterval(0, max_sleep) * 1000
    }
    setTimeout(commit, timeout, t_offset, outFD, outFile, data, counter, length);
  })
} else {
  consol<|endoftext|>


<commit_before>var models = require('../models')
  , async = require('async')

exports.addRoutes = function(app) {
  var requireAuthorization = function(requestingUser, timelineId, callback) {
    models.Timeline.findById(timelineId, { start : 0 }, function(err, timeline) {
      if (err)
        return callback(err, null)

      models.FeedFactory.findById(timeline.userId, function(err, feed) {
        if (err || !feed)
          return callback(err, null)

        switch (feed.type) {
          case 'group' :
            feed.getAdministratorsIds(function(err, administratorsIds) {
              callback(err, administratorsIds.indexOf(requestingUser.id) != -1)
            })
            break

          default :
            callback(null, feed.id == requestingUser.id)
            break
        }
      })
    })
  }

  var postSerializer = {
    select: ['id', 'body', 'createdBy', 'attachments', 'comments', 'createdAt', 'updatedAt', 'updatedAt', 'likes', 'groups'],
    createdBy: { select: ['id', 'username'] },
    comments: { select: ['id', 'body', 'createdBy'],
                createdBy: { select: ['id', 'username', 'info'],
                             info: {select: ['screenName'] }}},
    likes: { select: ['id', 'username', 'info'],
             info: {select: ['screenName'] }},
    groups: { select: ['id', 'username', 'info'],
              info: {select: ['screenName'] }}
  }

  app.get('/v1/posts/:postId', function(req, res) {
    models.Post.findById(req.params.postId, function(err, post) {
      if (!post)
        return res.jsonp({'error': 'Not found'}, 404);

      post.toJSON(postSerializer, function(err, json) {
        res.jsonp(json);
      })
    })
  })

  app.post('/v1/posts/:postId/like', function(req, res) {
    if (!req.user)
      return res.jsonp({})

    models.Post.addLike(req.params.postId, req.user.id, function(err, r) {
      // post.toJSON({}, function(err, json) { res.jsonp(json) })
      if (err) return res.jsonp({}, 422)

      res.jsonp({})
    })
  })

  app.post('/v1/posts/:postId/unlike', function(req, res) {
    if (!req.user)
      return res.jsonp({})

    models.Post.removeLike(req.params.postId, req.user.id, function(err, r) {
      if (err) return res.jsonp({}, 422)

      res.jsonp({})
    })
  })

  app.delete('/v1/posts/:postId', function(req, res) {
    if (!req.user || req.user.username == 'anonymous')
      return res.jsonp({})

    models.Post.findById(req.params.postId, function(err, post) {
      if (!post || req.user.id != post.userId)
        return res.jsonp({})

      post.getCommentsIds(function(err, ids) {
        models.Post.destroy(req.params.postId, function(err, r) {
          res.jsonp({})
        })
      })
    })
  })

  app.patch('/v1/posts/:postId', function(req, res) {
    if (!req.user || req.user.username == 'anonymous')
      return res.jsonp({})

    models.Post.findById(req.params.postId, function(err, post) {
      if (!post || req.user.id != post.userId)
        return res.jsonp({})

      var params = { body: req.body.body }
      post.update(params, function(err, post) {
        if (err) return res.jsonp({}, 422)

        res.jsonp({})
      })
    })
  })

  app.post('/v1/posts', function(req, res) {
    if(!req.user)
      return res.jsonp({})

    if(req.body.timelinesIds && req.body.timelinesIds.length > 0) {
      var timelinesIds = Array.isArray(req.body.timelinesIds) ? req.body.timelinesIds : [req.body.timelinesIds]

      async.forEach(timelinesIds, function(timelineId, done) {
        requireAuthorization(req.user, timelineId, function(err, valid) {
          if (err || !valid)
            done(err)

          req.user.newPost({
            body: req.body.body,
            timelineId: timelineId,
            files: req.files
          }, function(err, newPost) {
            newPost.create(function(err, post) {
              done(err)
            })
          })
        })
      }, function(err) {
        if (err) return res.jsonp({}, 422)

        res.jsonp({})
      })
    } else {
      req.user.getPostsTimelineId(function(err, timelineId) {
        req.user.newPost({
          body: req.body.body,
          timelineId: timelineId,
          files: req.files
        }, function(err, newPost) {
          newPost.create(function(err, post) {
            if (err) return res.jsonp({}, 422)

            post.toJSON(postSerializer, function(err, json) { res.jsonp(json) })
          })
        })
      })
    }
  })
}
<commit_msg>Temp returns timelineId assignment.<commit_after>var models = require('../models')
  , async = require('async')

exports.addRoutes = function(app) {
  var requireAuthorization = function(requestingUser, timelineId, callback) {
    models.Timeline.findById(timelineId, { start : 0 }, function(err, timeline) {
      if (err)
        return callback(err, null)

      models.FeedFactory.findById(timeline.userId, function(err, feed) {
        if (err || !feed)
          return callback(err, null)

        switch (feed.type) {
          case 'group' :
            feed.getAdministratorsIds(function(err, administratorsIds) {
              callback(err, administratorsIds.indexOf(requestingUser.id) != -1)
            })
            break

          default :
            callback(null, feed.id == requestingUser.id)
            break
        }
      })
    })
  }

  var postSerializer = {
    select: ['id', 'body', 'createdBy', 'attachments', 'comments', 'createdAt', 'updatedAt', 'updatedAt', 'likes', 'groups'],
    createdBy: { select: ['id', 'username'] },
    comments: { select: ['id', 'body', 'createdBy'],
                createdBy: { select: ['id', 'username', 'info'],
                             info: {select: ['screenName'] }}},
    likes: { select: ['id', 'username', 'info'],
             info: {select: ['screenName'] }},
    groups: { select: ['id', 'username', 'info'],
              info: {select: ['screenName'] }}
  }

  app.get('/v1/posts/:postId', function(req, res) {
    models.Post.findById(req.params.postId, function(err, post) {
      if (!post)
        return res.jsonp({'error': 'Not found'}, 404);

      post.toJSON(postSerializer, function(err, json) {
        res.jsonp(json);
      })
    })
  })

  app.post('/v1/posts/:postId/like', function(req, res) {
    if (!req.user)
      return res.jsonp({})

    models.Post.addLike(req.params.postId, req.user.id, function(err, r) {
      // post.toJSON({}, function(err, json) { res.jsonp(json) })
      if (err) return res.jsonp({}, 422)

      res.jsonp({})
    })
  })

  app.post('/v1/posts/:postId/unlike', function(req, res) {
    if (!req.user)
      return res.jsonp({})

    models.Post.removeLike(req.params.postId, req.user.id, function(err, r) {
      if (err) return res.jsonp({}, 422)

      res.jsonp({})
    })
  })

  app.delete('/v1/posts/:postId', function(req, res) {
    if (!req.user || req.user.username == 'anonymous')
      return res.jsonp({})

    models.Post.findById(req.params.postId, function(err, post) {
      if (!post || req.user.id != post.userId)
        return res.jsonp({})

      post.getCommentsIds(function(err, ids) {
        models.Post.destroy(req.params.postId, function(err, r) {
          res.jsonp({})
        })
      })
    })
  })

  app.patch('/v1/posts/:postId', function(req, res) {
    if (!req.user || req.user.username == 'anonymous')
      return res.jsonp({})

    models.Post.findById(req.params.postId, function(err, post) {
      if (!post || req.user.id != post.userId)
        return res.jsonp({})

      var params = { body: req.body.body }
      post.update(params, function(err, post) {
        if (err) return res.jsonp({}, 422)

        res.jsonp({})
      })
    })
  })

  app.post('/v1/posts', function(req, res) {
    if(!req.user)
      return res.jsonp({})

    if(req.body.timelinesIds && req.body.timelinesIds.length > 0) {
      var timelinesIds = Array.isArray(req.body.timelinesIds) ? req.body.timelinesIds : [req.body.timelinesIds]

      async.forEach(timelinesIds, function(timelineId, done) {
        requireAuthorization(req.user, timelineId, function(err, valid) {
          if (err || !valid)
            done(err)

          req.user.newPost({
            body: req.body.body,
            timelineId: timelineId,
            files: req.files
          }, function(err, newPost) {
            // TODO: review next line
            newPost.timelineId = timelineId
            newPost.create(function(err, post) {
              done(err)
            })
          })
        })
      }, function(err) {
        if (err) return res.jsonp({}, 422)

        res.jsonp({})
      })
    } else {
      req.user.getPostsTimelineId(function(err, timelineId) {
        req.user.newPost({
          body: req.body.body,
          timelineId: timelineId,
          files: req.files
        }, function(err, newPost) {
          newPost.create(function(err, post) {
            if (err) return res.jsonp({}, 422)

            post.toJSON(postSerializer, function(err, json) { res.jsonp(json) })
          })
        })
      })
    }
  })
}
<|endoftext|>


<commit_before>var child_process = require('child_process')
var fs = require('fs');
var max_sleep = 300
var step = 10
//Added a comment that achieves no real goal.
//Non-blocking loop
//Adjustable step
//Status line
//Add a rough time indicator
//First cut at libfaketime support

var commit_messages = [
  "Fixing an important issue with the universe.",
  "Someone poisoned the waterhole!",
  "You feeling lucky punk?",
  "Five bullets or six?",
  "Fixed memory parsing error #1337",
  "Cleaned out the intertubes",
  "AAAAAAAAAAARGH!",
  "Fixed a typo",
  "Updated the readme",
  "Fixing a typo added in the last readme update",
  "GET A HAIRCUT!",
  "Updated the readme again",
  "Found an issue with the letter 'a', so I fixed it.",
  "Incompatible dimensions found, Cthuhlu Error 666",
  "Who you calling a fool?",
  "How many more of these can I make?",
  "Fixing an error introduced in the las<commit_msg>Fixed memory parsing error #1337<commit_after>var child_process = require('child_process')
var fs = require('fs');
var max_sleep = 300
var step = 10
//Added a comment that achieves no real goal.
//Non-blocking loop
//Adjustable step
//Status line
//Add a rough time indicator
//First cut at libfaketime support

var commit_messages = [
  "Fixing an important issue with the universe.",
  "Someone poisoned the waterhole!",
  "You feeling lucky punk?",
  "Five bullets or six?",
  "Fixed memory parsing error #1337",
  "Cleaned out the intertubes",
  "AAAAAAAAAAARGH!",
  "Fixed a typo",
  "Updated the readme",
  "Fixing a typo added in the last readme update",
  "GET A HAIRCUT!",
  "Updated the readme again",
  "Found an issue with the letter 'a', so I fixed it.",
  "Incompatible dimensions found, Cthuhlu Error 666",
  "Who you calling a fool?",
  "How many more of these can I make?",
  "Fixing an error introduced in the last<|endoftext|>


<commit_before>exports.findById = function(req, res) {
	var id = req.params.id;
	console.log('Retrieving post: ' + id);
	db.collection('posts', function(err, collection) {
		collection.findOne({'_id':new BSON.ObjectID(id)}, function(err, item) {
			res.send(item);
		});
	});
};

exports.findRecent = function(req, res) {
        var end = new Date();
        var start = new Date();
        start.setMinutes(start.getMinutes() - 15);
	console.log(start);
	console.log(end);
	db.collection('posts', function(err, collection) {
		collection.find({created_on: {$gte: start, $lt: end}}).toArray(function(err, items) {
			res.send(items);
		});
	});
};

exports.findAll = function(req, res) {
	db.collection('posts', function(err, collection) {
		collection.find().toArray(function(err, items) {
			res.send(items);
		});
	});
};

exports.addPost = function(req, res) {
	var post = req.body;
	console.log("Post Body: ");
	console.log(post);
	db.collection('posts', function(err, collection) {
		collection.insert(post, {safe:true}, function(err, result) {
			if(err) {
				res.send({'error':'An error during posting has occured'});
			} else {
				console.log('Success: ' + JSON.stringify(result[0]));
				res.send(result[0]);
			}
		});
	});
}

exports.updatePost = function(req, res) {
	var id = req.params.id;
	var post = req.body;
	conosle.log('Updating post: ' + id);
	console.log(JSON.stringify(post));
	db.collection('posts', function(err, collection) {
		collection.update({'_id':new BSON.ObjectID(id)}, post, {safe:true}, function(err, result) {
			if (err) {
				console.log('Error updating weather post: ' + err);
				res.send({'error':'An error has occured'});
			} else {
				console.log('' + result + ' post(s) updated');
				res.send(post);
			}
		});
	});
}

exports.deletePost = function(req, res) {
	var id = req.params.id;
	console.log('Deleting post: ' + id);
	db.collection('posts', function(err, collection) {
		collection.remove({'_id':new BSON.ObjectID(id)}, {safe:true}, function(err, result) {
			if (err) {
				res.send({'error':'An error during deletion has occurred - ' + err});
			} else {
				console.log('' + result + ' post(s) deleted');
				res.send(req.body);
			}
		});
	});
}
<commit_msg>updated script to pull 15 minutes of data only at start<commit_after>exports.findById = function(req, res) {
	var id = req.params.id;
	console.log('Retrieving post: ' + id);
	db.collection('posts', function(err, collection) {
		collection.findOne({'_id':new BSON.ObjectID(id)}, function(err, item) {
			res.send(item);
		});
	});
};

exports.findRecent = function(req, res) {
        var end = new Date();
        var start = new Date();
        start.setMinutes(start.getMinutes() - 15);
	db.collection('posts', function(err, collection) {
		collection.find({status: {$gte: start, $lt: end}}).toArray(function(err, items) {
			res.send(items);
		});
	});
};

exports.findAll = function(req, res) {
	db.collection('posts', function(err, collection) {
		collection.find().toArray(function(err, items) {
			res.send(items);
		});
	});
};

exports.addPost = function(req, res) {
	var post = req.body;
	console.log("Post Body: ");
	console.log(post);
	db.collection('posts', function(err, collection) {
		collection.insert(post, {safe:true}, function(err, result) {
			if(err) {
				res.send({'error':'An error during posting has occured'});
			} else {
				console.log('Success: ' + JSON.stringify(result[0]));
				res.send(result[0]);
			}
		});
	});
}

exports.updatePost = function(req, res) {
	var id = req.params.id;
	var post = req.body;
	conosle.log('Updating post: ' + id);
	console.log(JSON.stringify(post));
	db.collection('posts', function(err, collection) {
		collection.update({'_id':new BSON.ObjectID(id)}, post, {safe:true}, function(err, result) {
			if (err) {
				console.log('Error updating weather post: ' + err);
				res.send({'error':'An error has occured'});
			} else {
				console.log('' + result + ' post(s) updated');
				res.send(post);
			}
		});
	});
}

exports.deletePost = function(req, res) {
	var id = req.params.id;
	console.log('Deleting post: ' + id);
	db.collection('posts', function(err, collection) {
		collection.remove({'_id':new BSON.ObjectID(id)}, {safe:true}, function(err, result) {
			if (err) {
				res.send({'error':'An error during deletion has occurred - ' + err});
			} else {
				console.log('' + result + ' post(s) deleted');
				res.send(req.body);
			}
		});
	});
}
<|endoftext|>


<commit_before>var fs = require('fs');
var child_process = require('child_process')
var max_sleep = 300
//Added a comment that achieves no real goal.

var commit_messages = [
  "Fixing an important issue with the universe.",
  "Someone poisoned the waterhole!",
  "You feeling lucky punk?",
  "Five bullets or six?",
  "Fixed memory parsing error #1337",
  "Cleaned out the intertubes",
  "AAAAAAAAAAARGH!",
  "Fixed a typo",
  "Updated the readme",
  "Fixing a typo added in the last readme update",
  "GET A HAIRCUT!",
  "Updated the readme again",
  "Found an issue with the letter 'a', so I fixed it.",
  "Incompatible dimensions found, Cthuhlu Error 666",
  "Who you calling a fool?",
  "How many more of these can I make?",
  "Fixing an error introduced in the last commit",
  "Re-updating the readme.",
  "Work in Progress",
  "WIP",
  "Quick fix",
  "Grammar fix",
  "Fixing punctuation",
 <commit_msg>Fixed memory parsing error #1337<commit_after>var fs = require('fs');
var child_process = require('child_process')
var max_sleep = 300
//Added a comment that achieves no real goal.

var commit_messages = [
  "Fixing an important issue with the universe.",
  "Someone poisoned the waterhole!",
  "You feeling lucky punk?",
  "Five bullets or six?",
  "Fixed memory parsing error #1337",
  "Cleaned out the intertubes",
  "AAAAAAAAAAARGH!",
  "Fixed a typo",
  "Updated the readme",
  "Fixing a typo added in the last readme update",
  "GET A HAIRCUT!",
  "Updated the readme again",
  "Found an issue with the letter 'a', so I fixed it.",
  "Incompatible dimensions found, Cthuhlu Error 666",
  "Who you calling a fool?",
  "How many more of these can I make?",
  "Fixing an error introduced in the last commit",
  "Re-updating the readme.",
  "Work in Progress",
  "WIP",
  "Quick fix",
  "Grammar fix",
  "Fixing punctuation",
  <|endoftext|>


<commit_before>(function() {
  'use strict';

  var RplusFns = {
    ready: function (fn) {
      if (document.readyState !== 'loading'){
        fn();
      } else {
        document.addEventListener('DOMContentLoaded', fn);
      }
    },
    hasClass: function ($ele, $className) {
      if ($ele.classList) {
        return $ele.classList.contains($className);
      } else {
        return new RegExp('(^| )' + $className + '( |$)', 'gi').test($ele.className);
      }
    },
    ajax: function ($path, $fn) {
      var ajax = new XMLHttpRequest();
      ajax.open('GET', $path, true);
      ajax.send();
      ajax.onload = function(e) {
        $fn({data: ajax.responseText});
      };
    },
    injectHTML: function (inlineContent) {
      var div = document.createElement('div');
      div.innerHTML = inlineContent;
      document.body.insertBefore(div, document.body.childNodes[0]);
    }
  };

  var initIcons = function () {
    RplusFns.ready(function () {
      if (!RplusFns.hasClass(document.documentElement, 'inlinesvg')) {
        injectInlineSvg();
      } else {
        injectInlinePng();
      }
    });
  };

  var injectInlinePng = function () {
    var inlinePng = localStorage.getItem('inlinePng');

    if (inlinePng) {
      RplusFns.injectHTML(inlinePng);
    } else {
      var pngStylePath = document.getElementById('js-icons-fallback').firstChild.data.match(/href="(.+?)"/)[1];
      RplusFns.ajax(pngStylePath, function (ajaxRespond) {
        var inlinePngContent = '<style>' + ajaxRespond.data + '</sctyle>';
        RplusFns.injectHTML(inlinePngContent);
        localStorage.setItem('inlinePng', inlinePngContent);
      });
    }
  };

  var injectInlineSvg = function () {
    var inlineSvg = localStorage.getItem('inlineSvg');

    if (inlineSvg) {
      RplusFns.injectHTML(inlineSvg);
    } else {
      RplusFns.ajax('./images/inject-svg/svgstore.svg', function (ajaxRespond) {
        var inlineSvgContent = ajaxRespond.data;
        RplusFns.injectHTML(inlineSvgContent);
        localStorage.setItem('inlineSvg', inlineSvgContent);
      });
    }
  };

  (function modernizrInit () {
    var htmlClassName = localStorage.getItem('modernizrAllClass');
    var lastDetectTime = localStorage.getItem('modernizrLastDetectTime') * 1;
    var detectDuration = lastDetectTime ? (new Date().getTime() - lastDetectTime) : false;

    if (htmlClassName && detectDuration < 259200000 ) { // 259200000 === 3 days
      document.documentElement.className = htmlClassName;
      initIcons();
      return;
    }

    var _head = document.getElementsByTagName('head')[0];
    var _injectJs = document.createElement('script');
    _injectJs.src = '//cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js';
    _injectJs.addEventListener('load', function () {
      localStorage.setItem('modernizrAllClass', document.documentElement.className);
      localStorage.setItem('modernizrLastDetectTime', new Date().getTime());
      initIcons();
    });
    _head.appendChild(_injectJs);
  })();

})();
<commit_msg>refactor: merge two inject type to one function. This closes issue #6<commit_after>(function() {
  'use strict';

  var RplusFns = {
    ready: function (fn) {
      if (document.readyState !== 'loading'){
        fn();
      } else {
        document.addEventListener('DOMContentLoaded', fn);
      }
    },
    hasClass: function ($ele, $className) {
      if ($ele.classList) {
        return $ele.classList.contains($className);
      } else {
        return new RegExp('(^| )' + $className + '( |$)', 'gi').test($ele.className);
      }
    },
    ajax: function ($path, $fn) {
      var ajax = new XMLHttpRequest();
      ajax.open('GET', $path, true);
      ajax.send();
      ajax.onload = function () {
        $fn({data: ajax.responseText});
      };
    },
    injectHTML: function (inlineContent) {
      var div = document.createElement('div');
      div.innerHTML = inlineContent;
      document.body.insertBefore(div, document.body.childNodes[0]);
    }
  };

  var initIcons = function () {
    RplusFns.ready(function () {
      if (RplusFns.hasClass(document.documentElement, 'inlinesvg')) {
        injectInline('svg');
      } else {
        injectInline('png');
      }
    });
  };

  var injectInline = function (type) {
    var _isSvgType = (type === 'svg');
    var _type = (_isSvgType ? 'inlineSvg' : 'inlinePng');
    var localData = localStorage.getItem(_type);

    if (localData) {
      RplusFns.injectHTML(localData);
    } else {
      var iconSource = (_isSvgType ? './images/inject-svg/svgstore.svg' : document.getElementById('js-icons-fallback').firstChild.data.match(/href="(.+?)"/)[1]);
      RplusFns.ajax(iconSource, function (response) {
        var inlineContent = response.data;

        if (!_isSvgType) {
          inlineContent = '<style>' + inlineContent + '</sctyle>';
        }

        RplusFns.injectHTML(inlineContent);
        localStorage.setItem(_type, inlineContent);
      });
    }
  };

  (function modernizrInit () {
    var htmlClassName = localStorage.getItem('modernizrAllClass');
    var lastDetectTime = localStorage.getItem('modernizrLastDetectTime') * 1;
    var detectDuration = lastDetectTime ? (new Date().getTime() - lastDetectTime) : false;

    if (htmlClassName && detectDuration < 259200000 ) { // 259200000 === 3 days
      document.documentElement.className = htmlClassName;
      initIcons();
      return;
    }

    var _head = document.getElementsByTagName('head')[0];
    var _injectJs = document.createElement('script');
    _injectJs.src = '//cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js';
    _injectJs.addEventListener('load', function () {
      localStorage.setItem('modernizrAllClass', document.documentElement.className);
      localStorage.setItem('modernizrLastDetectTime', new Date().getTime());
      initIcons();
    });
    _head.appendChild(_injectJs);
  })();

})();
<|endoftext|>


<commit_before>var fs = require('fs');
var child_process = require('child_process')
var max_sleep = 300

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[ 2 ]
  var outFile = process.argv[ 3 ]
  if (process.argv [ 4 ]) max_sleep = process.argv [ 4 ]
  console.info("Writing from %s to %s, with up to %s seconds between commits", inFile, outFile, max_sleep)
  var outFD = fs.openSync(outFile, 'w')
  fs.readFile(inFile, function(err,data) {
    var length = data.length
    console.info("Bytes: %s", length)
    try {
      child_process.execFileSync('/usr/bin/git', ['add', outFile])
    } catch (e) {
      <commit_msg>Update character<commit_after>var fs = require('fs');
var child_process = require('child_process')
var max_sleep = 300

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[ 2 ]
  var outFile = process.argv[ 3 ]
  if (process.argv [ 4 ]) max_sleep = process.argv [ 4 ]
  console.info("Writing from %s to %s, with up to %s seconds between commits", inFile, outFile, max_sleep)
  var outFD = fs.openSync(outFile, 'w')
  fs.readFile(inFile, function(err,data) {
    var length = data.length
    console.info("Bytes: %s", length)
    try {
      child_process.execFileSync('/usr/bin/git', ['add', outFile])
    } catch (e) {
      c<|endoftext|>


<commit_before>/*global require, $ */
'use strict';

require.config({
    shim: {
        underscore: {
            exports: '_'
        },
        backbone: {
            deps: ['underscore', 'jquery'],
            exports: 'Backbone'
        },
        bootstrap: {
            deps: ['jquery'],
            exports: 'jquery'
        }
    },
    paths: {
        jquery: '../bower_components/jquery/jquery',
        backbone: '../bower_components/backbone-amd/backbone',
        underscore: '../bower_components/underscore-amd/underscore',
        bootstrap: 'vendor/bootstrap'
    }
});

require(['backbone', 'routes/application-router', 'views/application-view', 'collections/application-collection'], function(Backbone, Router, Views, Collections) {
    var appRouter = new Router();
    var redTweets = new Collections([], {
        hashTag: 'coke'
    });
    var blueTweets = new Collections([], {
        hashTag: 'pepsi'
    });
    var redTweetArea = new Views.TweetAreaView({
        collection: redTweets,
        addClazz: 'reveal-right'
    });
    var blueTweetArea = new Views.TweetAreaView({
        collection: blueTweets,
        addClazz: 'reveal-left'
    });

    /*
     *
     * Expose Application to window for debugging and testing
     *
     */
    var app = {
        lib: {
            Views: {
                TweetView: Views.TweetView
            }
        },
        views: {
            red: redTweetArea,
            blue: blueTweetArea
        },
        router: appRouter,
        tweets: {
            red: redTweets,
            blue: blueTweets
        },
        interval: {}
    };
    window.app = app;

    /*
     * Bind Tweet Areas to existing DOM Elements
     */
    redTweetArea.setElement('.red.tweet-area');
    blueTweetArea.setElement('.blue.tweet-area');

    /*
     * Fetch first tweets
     */
    setTimeout(function() {
        app.tweets.red.fetch();
        app.tweets.blue.fetch();
    }, 0);

    /*
     * Start fetching tweets every 10 seconds
     */
    app.interval.red = setInterval(function() {
        app.tweets.red.fetch();
    }, 8000);
    app.interval.blue = setInterval(function() {
        app.tweets.blue.fetch();
    }, 8000);

    /*
     *
     * This belongs in a navbar view but it's not
     * very complex. Leaving it here for now.
     * Basically a toggle for starting and stopping
     * the fetching of tweets.
     *
     */
    var labels = {
        coke: {
            stop: 'Stop coke',
            start: 'Start coke'
        },
        pepsi: {
            stop: 'Stop pepsi',
            start: 'Start pepsi'
        }
    };
    var $cokebtn = $('.navbar .btn-coke');
    $cokebtn.on('click', function() {
        if ($cokebtn.text() === labels.coke.stop) {
            clearInterval(app.interval.red);
            $cokebtn.text(labels.coke.start);
        } else {
            app.tweets.red.fetch();
            app.interval.red = setInterval(function() {
                app.tweets.red.fetch();
            }, 10000);
            $cokebtn.text(labels.coke.stop);
        }
    });

    var $pepsibtn = $('.navbar .btn-pepsi');
    $pepsibtn.on('click', function() {
        if ($pepsibtn.text() === labels.pepsi.stop) {
            clearInterval(app.interval.blue);
            $pepsibtn.text(labels.pepsi.start);
        } else {
            app.tweets.blue.fetch();
            app.interval.blue = setInterval(function() {
                app.tweets.blue.fetch();
            }, 10000);
            $pepsibtn.text(labels.pepsi.stop);
        }
    });
});
<commit_msg>Debounce the start/stop buttons<commit_after>/*global require, $ */
'use strict';

require.config({
    shim: {
        underscore: {
            exports: '_'
        },
        backbone: {
            deps: ['underscore', 'jquery'],
            exports: 'Backbone'
        },
        bootstrap: {
            deps: ['jquery'],
            exports: 'jquery'
        }
    },
    paths: {
        jquery: '../bower_components/jquery/jquery',
        backbone: '../bower_components/backbone-amd/backbone',
        underscore: '../bower_components/underscore-amd/underscore',
        bootstrap: 'vendor/bootstrap'
    }
});

require(['underscore', 'backbone', 'routes/application-router', 'views/application-view', 'collections/application-collection'], function(_, Backbone, Router, Views, Collections) {
    var appRouter = new Router();
    var redTweets = new Collections([], {
        hashTag: 'coke'
    });
    var blueTweets = new Collections([], {
        hashTag: 'pepsi'
    });
    var redTweetArea = new Views.TweetAreaView({
        collection: redTweets,
        addClazz: 'reveal-right'
    });
    var blueTweetArea = new Views.TweetAreaView({
        collection: blueTweets,
        addClazz: 'reveal-left'
    });

    /*
     *
     * Expose Application to window for debugging and testing
     *
     */
    var app = {
        lib: {
            Views: {
                TweetView: Views.TweetView
            }
        },
        views: {
            red: redTweetArea,
            blue: blueTweetArea
        },
        router: appRouter,
        tweets: {
            red: redTweets,
            blue: blueTweets
        },
        interval: {}
    };
    window.app = app;

    /*
     * Bind Tweet Areas to existing DOM Elements
     */
    redTweetArea.setElement('.red.tweet-area');
    blueTweetArea.setElement('.blue.tweet-area');

    /*
     * Fetch first tweets
     */
    setTimeout(function() {
        app.tweets.red.fetch();
        app.tweets.blue.fetch();
    }, 0);

    /*
     * Start fetching tweets every 10 seconds
     */
    app.interval.red = setInterval(function() {
        app.tweets.red.fetch();
    }, 8000);
    app.interval.blue = setInterval(function() {
        app.tweets.blue.fetch();
    }, 8000);

    /*
     *
     * This belongs in a navbar view but it's not
     * very complex. Leaving it here for now.
     * Basically a toggle for starting and stopping
     * the fetching of tweets.
     *
     */
    var labels = {
        coke: {
            stop: 'Stop coke',
            start: 'Start coke'
        },
        pepsi: {
            stop: 'Stop pepsi',
            start: 'Start pepsi'
        }
    };
    var $cokebtn = $('.navbar .btn-coke');
    $cokebtn.on('click', _.debounce(function() {
        if ($cokebtn.text() === labels.coke.stop) {
            clearInterval(app.interval.red);
            $cokebtn.text(labels.coke.start);
        } else {
            app.tweets.red.fetch();
            app.interval.red = setInterval(function() {
                app.tweets.red.fetch();
            }, 10000);
            $cokebtn.text(labels.coke.stop);
        }
    }, 250, true));

    var $pepsibtn = $('.navbar .btn-pepsi');
    $pepsibtn.on('click', _.debounce(function() {
        if ($pepsibtn.text() === labels.pepsi.stop) {
            clearInterval(app.interval.blue);
            $pepsibtn.text(labels.pepsi.start);
        } else {
            app.tweets.blue.fetch();
            app.interval.blue = setInterval(function() {
                app.tweets.blue.fetch();
            }, 10000);
            $pepsibtn.text(labels.pepsi.stop);
        }
    }, 250, true));
});
<|endoftext|>


<commit_before>var child_process = require('child_process')
var fs = require('fs');
var max_sleep = 300
var step = 10
//Added a comment that achieves no real goal.
//Non-blocking loop
//Adjustable step
//Status line
//Add a rough time indicator
//First cut at libfaketime support

var commit_messages = [
  "Fixing an important issue with the universe.",
  "Someone poisoned the waterhole!",
  "You feeling lucky punk?",
  "Five bullets or six?",
  "Fixed memory parsing error #1337",
  "Cleaned out the intertubes",
  "AAAAAAAAAAARGH!",
  "Fixed a typo",
  "Updated the readme",
  "Fixing a typo added in the last readme update",
  "GET A HAIRCUT!",
  "Updated the readme again",
  "Found an issue with the letter 'a', so I fixed it.",
  "Incompatible dimensions found, Cthuhlu Error 666",
  "Who you calling a fool?",
  "How many more of these can I make?",
  "Fixing an error introduced in the last commit",
  "Re-updating the readme.",
  "Work in Progress",
  "WIP",
  "Quick fix",
  "Grammar fix",
  "Fixing punctuation",
  "Correcting style",
  "Logic error",
  "Almost there",
  "Nearly got it",
  "Not quite working",
  "Ooops!",
  "Did I do that?",
  "Commit all the required changes",
  "Really commit all the required changes",
  "Should work now",
  "Back out the last commit",
  "Reverting changes",
  "One more time...",
  "Re-commiting last",
  "One more User Story done",
  "Can work my way through the Kanban",
  "Sprint complete",
  "Well that seemed pretty easy",
  "What do you mean you can't pack up the commit?",
  "Merge in master",
  "Fast-forwarding changes",
  "Merging in private branch",
  "Time machines are real man!"
]

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[ 2 ]
  var outFile = process.argv[ 3 ]
  if (inFile == outFile) {
    console.error("Aborted: infile and outfile must be different")
    return(-1);
  }
  if (process.argv [ 4 ]) max_sleep = process.argv [ 4 ]
  if (process.argv [ 5 ]) step = parseInt(process.argv [ 5 ])
  console.info("Writing from %s to %s, with up to %s seconds between commits of %s bytes", inFile, outFile, max_sleep, step)
  var outFD = fs.openSync(outFile, 'w')
  fs.readFile(inFile, function(err,data) {
    var length = data.length
    var commit_count = Math.ceil(length / step)
    var commit_time = commit_count * max_sleep / 2
    var commit_time_hour = Math.floor(commit_time / 3600)
    var commit_time_rem = commit_time - (commit_time_hour * 3600)
    var commit_time_min = Math.floor(commit_time_rem / 60)
    var commit_time_sec = commit_time_rem - (commit_time_min * 60)
    console.info("Input file is %s Bytes, this will generate %s commits and take approximately %s hours %s minutes %s seconds", length, commit_count, commit_time_hour, commit_time_min, commit_time_sec)
    var t_offset = 0
    if (process.env.FAKETIME) {
      // 10% buffer, to reduce the likelihood of going in to the future
      t_offset = commit_time * -1.1;
      faketime(t_offset);
<commit_msg>Can work my way through the Kanban<commit_after>var child_process = require('child_process')
var fs = require('fs');
var max_sleep = 300
var step = 10
//Added a comment that achieves no real goal.
//Non-blocking loop
//Adjustable step
//Status line
//Add a rough time indicator
//First cut at libfaketime support

var commit_messages = [
  "Fixing an important issue with the universe.",
  "Someone poisoned the waterhole!",
  "You feeling lucky punk?",
  "Five bullets or six?",
  "Fixed memory parsing error #1337",
  "Cleaned out the intertubes",
  "AAAAAAAAAAARGH!",
  "Fixed a typo",
  "Updated the readme",
  "Fixing a typo added in the last readme update",
  "GET A HAIRCUT!",
  "Updated the readme again",
  "Found an issue with the letter 'a', so I fixed it.",
  "Incompatible dimensions found, Cthuhlu Error 666",
  "Who you calling a fool?",
  "How many more of these can I make?",
  "Fixing an error introduced in the last commit",
  "Re-updating the readme.",
  "Work in Progress",
  "WIP",
  "Quick fix",
  "Grammar fix",
  "Fixing punctuation",
  "Correcting style",
  "Logic error",
  "Almost there",
  "Nearly got it",
  "Not quite working",
  "Ooops!",
  "Did I do that?",
  "Commit all the required changes",
  "Really commit all the required changes",
  "Should work now",
  "Back out the last commit",
  "Reverting changes",
  "One more time...",
  "Re-commiting last",
  "One more User Story done",
  "Can work my way through the Kanban",
  "Sprint complete",
  "Well that seemed pretty easy",
  "What do you mean you can't pack up the commit?",
  "Merge in master",
  "Fast-forwarding changes",
  "Merging in private branch",
  "Time machines are real man!"
]

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[ 2 ]
  var outFile = process.argv[ 3 ]
  if (inFile == outFile) {
    console.error("Aborted: infile and outfile must be different")
    return(-1);
  }
  if (process.argv [ 4 ]) max_sleep = process.argv [ 4 ]
  if (process.argv [ 5 ]) step = parseInt(process.argv [ 5 ])
  console.info("Writing from %s to %s, with up to %s seconds between commits of %s bytes", inFile, outFile, max_sleep, step)
  var outFD = fs.openSync(outFile, 'w')
  fs.readFile(inFile, function(err,data) {
    var length = data.length
    var commit_count = Math.ceil(length / step)
    var commit_time = commit_count * max_sleep / 2
    var commit_time_hour = Math.floor(commit_time / 3600)
    var commit_time_rem = commit_time - (commit_time_hour * 3600)
    var commit_time_min = Math.floor(commit_time_rem / 60)
    var commit_time_sec = commit_time_rem - (commit_time_min * 60)
    console.info("Input file is %s Bytes, this will generate %s commits and take approximately %s hours %s minutes %s seconds", length, commit_count, commit_time_hour, commit_time_min, commit_time_sec)
    var t_offset = 0
    if (process.env.FAKETIME) {
      // 10% buffer, to reduce the likelihood of going in to the future
      t_offset = commit_time * -1.1;
      faketime(t_offset);
    }
    try {
    <|endoftext|>


<commit_before>var child_process = require('child_process')
var fs = require('fs');
var max_sleep = 300
var step = 10
//Added a comment that achieves no real goal.
//Non-blocking loop
//Adjustable step
//Status line
//Add a rough time indicator
//First cut at libfaketime support

var commit_messages = [
  "Fixing an important issue with the universe.",
  "Someone poisoned the waterhole!",
  "You feeling lucky punk?",
  "Five bullets or six?",
  "Fixed memory parsing error #1337",
  "Cleaned out the intertubes",
  "AAAAAAAAAAARGH!",
  "Fixed a typo",
  "Updated the readme",
  "Fixing a typo added in the last readme update",
  "GET A HAIRCUT!",
  "Updated the readme again",
  "Found an issue with the letter 'a', so I fixed it.",
  "Incompatible dimensions found, Cthuhlu Error 666",
  "Who you calling a fool?",
  "How many more of these can I make?",
  "Fixing an error introduced in the last commit",
  "Re-updating the readme.",
  "Work in Progress",
  "WIP",
  "Quick fix",
  "Grammar fix",
  "Fixing punctuation",
  "Correcting style",
  "Logic error",
  "Almost there",
  "Nearly got it",
  "Not quite working",
  "Ooops!",
  "Did I do that?",
  "Commit all the required changes",
  "Really commit all the required changes",
  "Should work now",
  "Back out the last commit",
  "Reverting changes",
  "One more time...",
  "Re-commiting last",
  "One more User Story done",
  "Can work my way through the Kanban",
  "Sprint complete",
  "Well that seemed pretty easy",
  "What do you mean you can't pack up the commit?",
  "Merge in master",
  "Fast-forwarding changes"
]

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[ 2 ]
  var outFile = process.argv[ 3 ]
  if (inFile == outFile) {
    console.error("Aborted: infile and outfile must be different")
    return(-1);
  }
  if (process.argv [ 4 ]) max_sleep = process.argv [ 4 ]
  if (process.argv [ 5 ]) step = parseInt(process.argv [ 5 ])
  console.info("Writing from %s to %s, with up to %s seconds between commits of %s bytes", inFile, outFile, max_sleep, step)
  var outFD = fs.openSync(outFile, 'w')
  fs.readFile(inFile, function(err,data) {
    var length = data.length
    var commit_count = Math.ceil(length / step)
    var commit_time = commit_count * max_sleep / 2
    var commit_time_hour = Math.floor(commit_time / 3600)
    var commit_time_rem = commit_time - (commit_time_hour * 3600)
    var commit_time_min = Math.floor(commit_time_rem / 60)
    var commit_time_sec = commit_time_rem - (commit_time_min * 60)
    console.info("Input file is %s Bytes, this will generate %s commits and take approximately %s hours %s minutes %s seconds", length, commit_count, commit_time_hour, commit_time_min, commit_time_sec)
    var t_offset = 0
    if (process.env.FAKETIME) {
      // 20% buffer, to reduce the likelihood of going in to the future
      t_offset = commit_time * -1.2;
      faketime(t_offset);
    }
    try {
      child_process.execFileSync('git', ['add', outFile])
    } catch (e) {
      console.error("Couldn't add %s to git: %s", outFile, e)
    }
    var counter = 0
    process.stdout.write("Queueing up the first commit...\r");
    var timeout;
    if (process.env.FAKETIME) {
      faketime(t_offset);
      timeout = 20;
    } else {
      timeout = randomIntFromInterval(0, max_sleep) * 1000
    }
    setTimeout(commit, timeout, t_offset, outFD, outFile, data, counter, length);
  })
} else {
  console.info("Usage:")
  console.info("node commit.js infile outfile [max_time_in_seconds] [step]")
}

function sleep(seconds) {
  var endTime = new Date().getTime() + (seconds * 1000);
  while (new Date().getTime() <= endTime) {;}
}

function randomIntFromInterval(min,max)
{
   return Math.floor(Math.random()*(max-min+1)+min);
}

function commit(t_offset, outFD, outFile, data, counter, length)
{
  if (counter < length)
  {
    var message = commit_messages[randomIntFromInterval(0, commit_messages.length - 1)]
    var args = ['commit', outFile, '-m', message]
    if (counter + step >= length) step = length - counter
    process.stdout.write("\033[2K Writing " + counter + "/" + length + " bytes: " + message + "<commit_msg>Reverting changes<commit_after>var child_process = require('child_process')
var fs = require('fs');
var max_sleep = 300
var step = 10
//Added a comment that achieves no real goal.
//Non-blocking loop
//Adjustable step
//Status line
//Add a rough time indicator
//First cut at libfaketime support

var commit_messages = [
  "Fixing an important issue with the universe.",
  "Someone poisoned the waterhole!",
  "You feeling lucky punk?",
  "Five bullets or six?",
  "Fixed memory parsing error #1337",
  "Cleaned out the intertubes",
  "AAAAAAAAAAARGH!",
  "Fixed a typo",
  "Updated the readme",
  "Fixing a typo added in the last readme update",
  "GET A HAIRCUT!",
  "Updated the readme again",
  "Found an issue with the letter 'a', so I fixed it.",
  "Incompatible dimensions found, Cthuhlu Error 666",
  "Who you calling a fool?",
  "How many more of these can I make?",
  "Fixing an error introduced in the last commit",
  "Re-updating the readme.",
  "Work in Progress",
  "WIP",
  "Quick fix",
  "Grammar fix",
  "Fixing punctuation",
  "Correcting style",
  "Logic error",
  "Almost there",
  "Nearly got it",
  "Not quite working",
  "Ooops!",
  "Did I do that?",
  "Commit all the required changes",
  "Really commit all the required changes",
  "Should work now",
  "Back out the last commit",
  "Reverting changes",
  "One more time...",
  "Re-commiting last",
  "One more User Story done",
  "Can work my way through the Kanban",
  "Sprint complete",
  "Well that seemed pretty easy",
  "What do you mean you can't pack up the commit?",
  "Merge in master",
  "Fast-forwarding changes"
]

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[ 2 ]
  var outFile = process.argv[ 3 ]
  if (inFile == outFile) {
    console.error("Aborted: infile and outfile must be different")
    return(-1);
  }
  if (process.argv [ 4 ]) max_sleep = process.argv [ 4 ]
  if (process.argv [ 5 ]) step = parseInt(process.argv [ 5 ])
  console.info("Writing from %s to %s, with up to %s seconds between commits of %s bytes", inFile, outFile, max_sleep, step)
  var outFD = fs.openSync(outFile, 'w')
  fs.readFile(inFile, function(err,data) {
    var length = data.length
    var commit_count = Math.ceil(length / step)
    var commit_time = commit_count * max_sleep / 2
    var commit_time_hour = Math.floor(commit_time / 3600)
    var commit_time_rem = commit_time - (commit_time_hour * 3600)
    var commit_time_min = Math.floor(commit_time_rem / 60)
    var commit_time_sec = commit_time_rem - (commit_time_min * 60)
    console.info("Input file is %s Bytes, this will generate %s commits and take approximately %s hours %s minutes %s seconds", length, commit_count, commit_time_hour, commit_time_min, commit_time_sec)
    var t_offset = 0
    if (process.env.FAKETIME) {
      // 20% buffer, to reduce the likelihood of going in to the future
      t_offset = commit_time * -1.2;
      faketime(t_offset);
    }
    try {
      child_process.execFileSync('git', ['add', outFile])
    } catch (e) {
      console.error("Couldn't add %s to git: %s", outFile, e)
    }
    var counter = 0
    process.stdout.write("Queueing up the first commit...\r");
    var timeout;
    if (process.env.FAKETIME) {
      faketime(t_offset);
      timeout = 20;
    } else {
      timeout = randomIntFromInterval(0, max_sleep) * 1000
    }
    setTimeout(commit, timeout, t_offset, outFD, outFile, data, counter, length);
  })
} else {
  console.info("Usage:")
  console.info("node commit.js infile outfile [max_time_in_seconds] [step]")
}

function sleep(seconds) {
  var endTime = new Date().getTime() + (seconds * 1000);
  while (new Date().getTime() <= endTime) {;}
}

function randomIntFromInterval(min,max)
{
   return Math.floor(Math.random()*(max-min+1)+min);
}

function commit(t_offset, outFD, outFile, data, counter, length)
{
  if (counter < length)
  {
    var message = commit_messages[randomIntFromInterval(0, commit_messages.length - 1)]
    var args = ['commit', outFile, '-m', message]
    if (counter + step >= length) step = length - counter
    process.stdout.write("\033[2K Writing " + counter + "/" + length + " bytes: " + message + "\<|endoftext|>


<commit_before>var fs = require('fs');
var child_process = require('child_process')
var max_sleep = 300
//Added a comment that achieves no real goal.

var commit_messages = [
  "Fixing an important issue with the universe.",
  "Someone poisoned the waterhole!",
  "You feeling luc<commit_msg>Correcting style<commit_after>var fs = require('fs');
var child_process = require('child_process')
var max_sleep = 300
//Added a comment that achieves no real goal.

var commit_messages = [
  "Fixing an important issue with the universe.",
  "Someone poisoned the waterhole!",
  "You feeling luck<|endoftext|>