<commit_before>vvavarvar var fvar fsvar fs var fs =var fs = var fs = rvar fs = revar fs = reqvar fs = requvar fs = requivar fs = requirvar fs = requirevar fs = require(var fs = require('var fs = require('fvar fs = require('fsvar fs = require('fs'var fs = require('fs')var fs = require('fs');var fs = require('fs');
var fs = require('fs');
vvar fs = require('fs');
vavar fs = require('fs');
varvar fs = require('fs');
var var fs = require('fs');
var cvar fs = require('fs');
var chvar fs = require('fs');
var chivar fs = require('fs');
var chilvar fs = require('fs');
var childvar fs = require('fs');
var child_var fs = require('fs');
var child_pvar fs = require('fs');
var child_prvar fs = require('fs');
var child_provar fs = require('fs');
var child_procvar fs = require('fs');
var child_procevar fs = require('fs');
var child_procesvar fs = require('fs');
var child_processvar fs = require('fs');
var child_process var fs = require('fs');
var child_process =var fs = require('fs');
var child_process = var fs = require('fs');
var child_process = rvar fs = require('fs');
var child_process = revar fs = require('fs');
var child_process = reqvar fs = require('fs');
var child_process = requvar fs = require('fs');
var child_process = requivar fs = require('fs');
var child_process = requirvar fs = require('fs');
var child_process = requirevar fs = require('fs');
var child_process = require(var fs = require('fs');
var child_process = require('var fs = require('fs');
var child_process = require('cvar fs = require('fs');
var child_process = require('chvar fs = require('fs');
var child_process = require('chivar fs = require('fs');
var child_process = require('chilvar fs = require('fs');
var child_process = require('childvar fs = require('fs');
var child_process = require('child_var fs = require('fs');
var child_process = require('child_pvar fs = require('fs');
var child_process = require('child_prvar fs = require('fs');
var child_process = require('child_provar fs = require('fs');
var child_process = require('child_procvar fs = require('fs');
var child_process = require('child_procevar fs = require('fs');
var child_process = require('child_procesvar fs = require('fs');
var child_process = require('child_processvar fs = require('fs');
var child_process = require('child_process'var fs = require('fs');
var child_process = require('child_process')var fs = require('fs');
var child_process = require('child_process')
var fs = require('fs');
var child_process = require('child_process')

var fs = require('fs');
var child_process = require('child_process')

ivar fs = require('fs');
var child_process = require('child_process')

ifvar fs = require('fs');
var child_process = require('child_process')

if var fs = require('fs');
var child_process = require('child_process')

if (var fs = require('fs');
var child_process = require('child_process')

if ( var fs = require('fs');
var child_process = require('child_process')

if ( pvar fs = require('fs');
var child_process = require('child_process')

if ( prvar fs = require('fs');
var child_process = require('child_process')

if ( provar fs = require('fs');
var child_process = require('child_process')

if ( procvar fs = require('fs');
var child_process = require('child_process')

if ( procevar fs = require('fs');
var child_process = require('child_process')

if ( procesvar fs = require('fs');
var child_process = require('child_process')

if ( processvar fs = require('fs');
var child_process = require('child_process')

if ( process.var fs = require('fs');
var child_process = require('child_process')

if ( process.avar fs = require('fs');
var child_process = require('child_process')

if ( process.arvar fs = require('fs');
var child_process = require('child_process')

if ( process.argvar fs = require('fs');
var child_process = require('child_process')

if ( process.argvvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ]var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] &var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] &&var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && pvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && prvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && provar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && procvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && procevar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && procesvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && processvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.avar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.arvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argvvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ]var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] )var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
 var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  vvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  vavar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  varvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var ivar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var invar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFivar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFilvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFilevar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile =var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = pvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = prvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = provar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = procvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = procevar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = procesvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = processvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.avar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.arvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argvvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[<commit_msg>Update character<commit_after>vvavarvar var fvar fsvar fs var fs =var fs = var fs = rvar fs = revar fs = reqvar fs = requvar fs = requivar fs = requirvar fs = requirevar fs = require(var fs = require('var fs = require('fvar fs = require('fsvar fs = require('fs'var fs = require('fs')var fs = require('fs');var fs = require('fs');
var fs = require('fs');
vvar fs = require('fs');
vavar fs = require('fs');
varvar fs = require('fs');
var var fs = require('fs');
var cvar fs = require('fs');
var chvar fs = require('fs');
var chivar fs = require('fs');
var chilvar fs = require('fs');
var childvar fs = require('fs');
var child_var fs = require('fs');
var child_pvar fs = require('fs');
var child_prvar fs = require('fs');
var child_provar fs = require('fs');
var child_procvar fs = require('fs');
var child_procevar fs = require('fs');
var child_procesvar fs = require('fs');
var child_processvar fs = require('fs');
var child_process var fs = require('fs');
var child_process =var fs = require('fs');
var child_process = var fs = require('fs');
var child_process = rvar fs = require('fs');
var child_process = revar fs = require('fs');
var child_process = reqvar fs = require('fs');
var child_process = requvar fs = require('fs');
var child_process = requivar fs = require('fs');
var child_process = requirvar fs = require('fs');
var child_process = requirevar fs = require('fs');
var child_process = require(var fs = require('fs');
var child_process = require('var fs = require('fs');
var child_process = require('cvar fs = require('fs');
var child_process = require('chvar fs = require('fs');
var child_process = require('chivar fs = require('fs');
var child_process = require('chilvar fs = require('fs');
var child_process = require('childvar fs = require('fs');
var child_process = require('child_var fs = require('fs');
var child_process = require('child_pvar fs = require('fs');
var child_process = require('child_prvar fs = require('fs');
var child_process = require('child_provar fs = require('fs');
var child_process = require('child_procvar fs = require('fs');
var child_process = require('child_procevar fs = require('fs');
var child_process = require('child_procesvar fs = require('fs');
var child_process = require('child_processvar fs = require('fs');
var child_process = require('child_process'var fs = require('fs');
var child_process = require('child_process')var fs = require('fs');
var child_process = require('child_process')
var fs = require('fs');
var child_process = require('child_process')

var fs = require('fs');
var child_process = require('child_process')

ivar fs = require('fs');
var child_process = require('child_process')

ifvar fs = require('fs');
var child_process = require('child_process')

if var fs = require('fs');
var child_process = require('child_process')

if (var fs = require('fs');
var child_process = require('child_process')

if ( var fs = require('fs');
var child_process = require('child_process')

if ( pvar fs = require('fs');
var child_process = require('child_process')

if ( prvar fs = require('fs');
var child_process = require('child_process')

if ( provar fs = require('fs');
var child_process = require('child_process')

if ( procvar fs = require('fs');
var child_process = require('child_process')

if ( procevar fs = require('fs');
var child_process = require('child_process')

if ( procesvar fs = require('fs');
var child_process = require('child_process')

if ( processvar fs = require('fs');
var child_process = require('child_process')

if ( process.var fs = require('fs');
var child_process = require('child_process')

if ( process.avar fs = require('fs');
var child_process = require('child_process')

if ( process.arvar fs = require('fs');
var child_process = require('child_process')

if ( process.argvar fs = require('fs');
var child_process = require('child_process')

if ( process.argvvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ]var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] &var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] &&var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && pvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && prvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && provar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && procvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && procevar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && procesvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && processvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.avar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.arvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argvvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ]var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] )var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
 var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  vvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  vavar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  varvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var ivar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var invar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFivar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFilvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFilevar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile =var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = pvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = prvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = provar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = procvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = procevar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = procesvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = processvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.avar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.arvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argvvar fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[var fs = require('fs');
var child_process = require('child_process')

if ( process.argv[ 2 ] && process.argv[ 3 ] ) {
  var inFile = process.argv[ <|endoftext|>


<commit_before>const Discord = require("discord.js");
const fs = require("fs");
const date = require("date");
const bot = new Discord.Client();
const prefix = "!";
const botToken = require("./bottoken");

bot.on("ready", () => {
    console.log("Klar");
    bot.user.setGame("Skriv !help för hjälp.");
});

var dabRespond = [
    "Du kan inte tvinga mig",
    "Du kan inte tvinga mig",
    "Du kan inte tvinga mig",
    "Du kan inte tvinga mig",
    "Du kan inte tvinga mig",
    "Du kan inte tvinga mig",
    "Vad är det du inte förstår?",
    "Jävla människor ska alltid komma och tjata",
    "Okej då, ***DAB***"
];

Date.prototype.getWeek = function() {
    var onejan = new Date(this.getFullYear(), 0, 1);
    return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7);
}

var weekNumber = (new Date()).getWeek();
var widthSchema = "600"
var heightSchema = "600"

var schemaLink = "http://www.novasoftware.se/ImgGen/schedulegenerator.aspx?format=png&schoolid=80220/sv-se&type=1&id={EA17E85E-CBFC-4836-935C-04780337F6D5}&period=&week="+weekNumber+"&mode=0&printer=0&colors=32&head=0&clock=0&foot=0&day=0&width="+widthSchema+"&height="+heightSchema+"&maxwidth=1883&maxheight=847"

bot.on("message", (message) => {

    if (!message.content.startsWith(prefix)) return;
    if (message.author.bot) return;

    //console.log(test);

    var split = message.content.substring(prefix.length).split(' ');

    switch (split[0].toLowerCase()) {

        case "help":
            message.channel.send({
                embed: new Discord.RichEmbed()
                    .setAuthor("Kommandon:", bot.user.avatarURL)
                    .addField("Allmäna kommandon:", "!help - visar denna meny\n!github - skickar länken till botens github repo\n!ping - visar botens internal ping (för felsökning)")
                    .addField("Skolrelaterade kommandon:", "!schema - visar veckans schema\n!hex - ger dig en slumpmässig färg")
                    .setColor("0x111111")
            });
            break;
        case "schema":
            message.channel.send({
                embed: new Discord.RichEmbed()
                    .setAuthor("Schema V. "+weekNumber+":")
                    .setImage(schemaLink)
                    .setColor("0x"+("000000"+Math.random().toString(16).slice(2, 8).toUpperCase()).slice(-6))
            });
            break;
        case "github":
            message.author.send("https://github.com/ChilladeChillin/ITGDiscordBot");
            break;
        case "dab":
            message.channel.send(dabRespond[Math.floor(Math.random() * dabRespond.length)]);
            break;
        case "say":
            var textFromSender = message.content;
            message.delete(0);
            if (message.author.id==="164283691802165250") {
                message.channel.send(message.content.substring(5));
                break;
            }
            else {
                break;
            }
        case "ping":
            message.channel.send(bot.ping+" ms");
            break;
        case "hex":
            var randomhex = ("000000"+Math.random().toString(16).slice(2, 8).toUpperCase()).slice(-6);
            message.channel.send({
                embed: new Discord.RichEmbed()
                    .setAuthor("Hex:")
                    .setDescription("#"+randomhex)
                    .setColor("0x"+randomhex)
            });
        //case "bordejag"
            //[Math.floor(Math.random() * bordejag.length)]
    }
});

bot.login(botToken);<commit_msg>slängde runt lite med hur titeln på !schema ser ut<commit_after>const Discord = require("discord.js");
const fs = require("fs");
const date = require("date");
const bot = new Discord.Client();
const prefix = "!";
const botToken = require("./bottoken");

bot.on("ready", () => {
    console.log("Klar");
    bot.user.setGame("Skriv !help för hjälp.");
});

var dabRespond = [
    "Du kan inte tvinga mig",
    "Du kan inte tvinga mig",
    "Du kan inte tvinga mig",
    "Du kan inte tvinga mig",
    "Du kan inte tvinga mig",
    "Du kan inte tvinga mig",
    "Vad är det du inte förstår?",
    "Jävla människor ska alltid komma och tjata",
    "Okej då, ***DAB***"
];

Date.prototype.getWeek = function() {
    var onejan = new Date(this.getFullYear(), 0, 1);
    return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7);
}

var weekNumber = (new Date()).getWeek();
var widthSchema = "600"
var heightSchema = "600"

var schemaLink = "http://www.novasoftware.se/ImgGen/schedulegenerator.aspx?format=png&schoolid=80220/sv-se&type=1&id={EA17E85E-CBFC-4836-935C-04780337F6D5}&period=&week="+weekNumber+"&mode=0&printer=0&colors=32&head=0&clock=0&foot=0&day=0&width="+widthSchema+"&height="+heightSchema+"&maxwidth=1883&maxheight=847"

bot.on("message", (message) => {

    if (!message.content.startsWith(prefix)) return;
    if (message.author.bot) return;

    //console.log(test);

    var split = message.content.substring(prefix.length).split(' ');

    switch (split[0].toLowerCase()) {

        case "help":
            message.channel.send({
                embed: new Discord.RichEmbed()
                    .setAuthor("Kommandon:", bot.user.avatarURL)
                    .addField("Allmäna kommandon:", "!help - visar denna meny\n!github - skickar länken till botens github repo\n!ping - visar botens internal ping (för felsökning)")
                    .addField("Skolrelaterade kommandon:", "!schema - visar veckans schema\n!hex - ger dig en slumpmässig färg")
                    .setColor("0x111111")
            });
            break;
        case "schema":
            message.channel.send({
                embed: new Discord.RichEmbed()
                    .setAuthor("Schema v."+weekNumber+":")
                    .setImage(schemaLink)
                    .setColor("0x"+("000000"+Math.random().toString(16).slice(2, 8).toUpperCase()).slice(-6))
            });
            break;
        case "github":
            message.author.send("https://github.com/ChilladeChillin/ITGDiscordBot");
            break;
        case "dab":
            message.channel.send(dabRespond[Math.floor(Math.random() * dabRespond.length)]);
            break;
        case "say":
            var textFromSender = message.content;
            message.delete(0);
            if (message.author.id==="164283691802165250") {
                message.channel.send(message.content.substring(5));
                break;
            }
            else {
                break;
            }
        case "ping":
            message.channel.send(bot.ping+" ms");
            break;
        case "hex":
            var randomhex = ("000000"+Math.random().toString(16).slice(2, 8).toUpperCase()).slice(-6);
            message.channel.send({
                embed: new Discord.RichEmbed()
                    .setAuthor("Hex:")
                    .setDescription("#"+randomhex)
                    .setColor("0x"+randomhex)
            });
        //case "bordejag"
            //[Math.floor(Math.random() * bordejag.length)]
    }
});

bot.login(botToken);<|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",
  "Updat<commit_msg>Work in Progress<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",
  "Update<|endoftext|>


<commit_before>var postcss = require('postcss');

var replacements = new RegExp('url\(([^)]+)\)', 'gi');

function replaceWithFontUrl(match, matchGroup) {
  return "font-url" + matchGroup;
}

function replaceWithImageUrl(match, matchGroup) {
  return "image-url" + matchGroup;
}

function replaceWithAssetUrl(match, matchGroup) {
  return "asset-url" + matchGroup;
}

function isImage(string) {
  return !!string.match(/(\.png|\.jpg|\.jpeg|\.gif|\.svg|\.tif|\.tiff)/);
}

var RailsAssetUrls = postcss.plugin('postcss-rails-asset-urls', function (version) {
  version = version || '4.0.0';

  if (version.substring(0, 1) > 3) {
    return function(css) {
      css.eachDecl(function(decl) {
        decl.value = decl.value.replace(replacements, replaceWithAssetUrl);
      });
    };
  } else {
    return function(css) {
      css.eachDecl(function(decl) {
        if (decl.parent.name === 'font-face') {
          decl.value = decl.value.replace(replacements, replaceWithFontUrl);
        } else if (isImage(decl.value)) {
          decl.value = decl.value.replace(replacements, replaceWithImageUrl);
        }
      });
    };
  }
});

if (process.env.NODE_ENV === 'test') {
  RailsAssetUrls.replaceWithFontUrl = replaceWithFontUrl;
  RailsAssetUrls.replaceWithImageUrl = replaceWithImageUrl;
  RailsAssetUrls.replaceWithAssetUrl = replaceWithAssetUrl;
  RailsAssetUrls.isImage = isImage;
}

module.exports = RailsAssetUrls;
<commit_msg>removing deprecated function<commit_after>var postcss = require('postcss');

var replacements = new RegExp('url\(([^)]+)\)', 'gi');

function replaceWithFontUrl(match, matchGroup) {
  return "font-url" + matchGroup;
}

function replaceWithImageUrl(match, matchGroup) {
  return "image-url" + matchGroup;
}

function replaceWithAssetUrl(match, matchGroup) {
  return "asset-url" + matchGroup;
}

function isImage(string) {
  return !!string.match(/(\.png|\.jpg|\.jpeg|\.gif|\.svg|\.tif|\.tiff)/);
}

var RailsAssetUrls = postcss.plugin('postcss-rails-asset-urls', function (version) {
  version = version || '4.0.0';

  if (version.substring(0, 1) > 3) {
    return function(css) {
      css.walkDecls(function(decl) {
        decl.value = decl.value.replace(replacements, replaceWithAssetUrl);
      });
    };
  } else {
    return function(css) {
      css.walkDecls(function(decl) {
        if (decl.parent.name === 'font-face') {
          decl.value = decl.value.replace(replacements, replaceWithFontUrl);
        } else if (isImage(decl.value)) {
          decl.value = decl.value.replace(replacements, replaceWithImageUrl);
        }
      });
    };
  }
});

if (process.env.NODE_ENV === 'test') {
  RailsAssetUrls.replaceWithFontUrl = replaceWithFontUrl;
  RailsAssetUrls.replaceWithImageUrl = replaceWithImageUrl;
  RailsAssetUrls.replaceWithAssetUrl = replaceWithAssetUrl;
  RailsAssetUrls.isImage = isImage;
}

module.exports = RailsAssetUrls;
<|endoftext|>


<commit_before>var fs = require('fs');
var child_process = require('child_process')
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

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"
]

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)
    try {
      child_process.execFileSync('/usr/bin/git', ['add', outFile])
    } catch (e) {
      console.error("Couldn't add %s to git: %s", outFile, e)
    }
    var timeout = randomIntFromInterval(0, max_sleep) * 1000
    var counter = 0
    process.stdout.write("Queueing up the first commit...\r");
    setTimeout(commit, timeout, outFD, outFile, data, counter, length);
  })
} else {
  console.info("Usage:")
  console.info("node commit.js infil<commit_msg>Updated the readme<commit_after>var fs = require('fs');
var child_process = require('child_process')
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

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"
]

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)
    try {
      child_process.execFileSync('/usr/bin/git', ['add', outFile])
    } catch (e) {
      console.error("Couldn't add %s to git: %s", outFile, e)
    }
    var timeout = randomIntFromInterval(0, max_sleep) * 1000
    var counter = 0
    process.stdout.write("Queueing up the first commit...\r");
    setTimeout(commit, timeout, outFD, outFile, data, counter, length);
  })
} else {
  console.info("Usage:")
  console.info("node commit.js infile outfile [max_time_in_seconds] [step]")
}

functi<|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",
  "Correcting style",
  "Logic error"
]

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 message = commit_messages[randomIntFromInterval(0, co<commit_msg>Updated the readme<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",
  "Correcting style",
  "Logic error"
]

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 message = commit_messages[randomIntFromInterval(0, com<|endoftext|>


<commit_before>'use strict';

const MemDuplex = require('./MemDuplex.js');

function _sendMemDuplexToResponse(memDuplexes, index, response, logger){
    if(memDuplexes[index] === undefined){
        return response.end();
    }
    const memDuplexOnCall = memDuplexes[index];
    memDuplexOnCall.on('data', chunk => {
        response.write(chunk);
    });
    memDuplexOnCall.on('error', () => {
        logger.error('error piping data from source');
        return response.end();
    });
    memDuplexOnCall.on('end', () => {
        return process.nextTick(_sendMemDuplexToResponse,
            memDuplexes, index + 1, response, logger);
    });
}

function _fillMemDuplex(memDuplexes, index, dataRetrievalFn, response, logger){
    return dataRetrievalFn(memDuplexes[index].location, logger,
        (err, readable) => {
        if(err){
            logger.error('failed to get full object');
            return response.end();
        }
        readable.pipe(memDuplexes[index]);
        if(memDuplexes[index + 2]){
            readable.on('end', () => {
                return process.nextTick(_fillMemDuplex, memDuplexes, index + 2,
                    dataRetrievalFn, response, logger);
            });
        }
        readable.on('error', () => {
            logger.error('error piping data from readable to memDuplex');
            return response.end();
        });
    });
}

exports.readySetStream = function readySetStream(locations, dataRetrievalFn,
    response, logger) {
    if (!logger) {
        logger = console;
    }
    if (locations.length === 0) {
        return response.end();
    }
    const memDuplexes = locations.map((location) => {
        return new MemDuplex(location);
    });

    _sendMemDuplexToResponse(memDuplexes, 0, response, logger);
    _fillMemDuplex(memDuplexes, 0, dataRetrievalFn, response, logger);
    if (memDuplexes.length > 1){
        _fillMemDuplex(memDuplexes, 1, dataRetrievalFn, response, logger);
    }
}
<commit_msg>FIX: Send back error on get<commit_after>'use strict';

const MemDuplex = require('./MemDuplex.js');

function _sendMemDuplexToResponse(memDuplexes, index, response, logger){
    if(memDuplexes[index] === undefined){
        return response.end();
    }
    const memDuplexOnCall = memDuplexes[index];
    memDuplexOnCall.on('data', chunk => {
        response.write(chunk);
    });
    memDuplexOnCall.on('error', () => {
        logger.error('error piping data from source');
        return response.end();
    });
    memDuplexOnCall.on('end', () => {
        return process.nextTick(_sendMemDuplexToResponse,
            memDuplexes, index + 1, response, logger);
    });
}

function _fillMemDuplex(memDuplexes, index, dataRetrievalFn, response, logger){
    return dataRetrievalFn(memDuplexes[index].location, logger,
        (err, readable) => {
        if(err){
            logger.error('failed to get full object', {
                error: err,
                method: '_fillMemDuplex',
            });
            return response.connection.destroy();
        }
        readable.pipe(memDuplexes[index]);
        if(memDuplexes[index + 2]){
            readable.on('end', () => {
                return process.nextTick(_fillMemDuplex, memDuplexes, index + 2,
                    dataRetrievalFn, response, logger);
            });
        }
        readable.on('error', () => {
            logger.error('error piping data from readable to memDuplex');
            return response.connection.destroy();
        });
    });
}

exports.readySetStream = function readySetStream(locations, dataRetrievalFn,
    response, logger) {
    if (!logger) {
        logger = console;
    }
    if (locations.length === 0) {
        return response.end();
    }
    const memDuplexes = locations.map((location) => {
        return new MemDuplex(location);
    });

    _sendMemDuplexToResponse(memDuplexes, 0, response, logger);
    _fillMemDuplex(memDuplexes, 0, dataRetrievalFn, response, logger);
    if (memDuplexes.length > 1){
        _fillMemDuplex(memDuplexes, 1, dataRetrievalFn, response, logger);
    }
}
<|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",
  "Correcting style",
  "Logic error"
]

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 message = commit_messages[randomIntFromInterval(0, commit_messages.length - 1)]
    var args = ['commit', outFile, '-m', message]
    for (var counter = 0; counter < length; counter++)
    {
      var message = commit_messages[randomIntFromInterval(0, commit_messages.length - 1)]
      var args = ['commit', outFile, '-m', message]
      fs.writeSync(outFD, data.slice(counter, counter+1), 0, 1)
      sleep(Math.random() * max_sleep)
      child_process.execFileSync('/usr/bin/git', args)
    }
  })
} else {
  console.info("Usage:")
  console.info("node commit.js infile outfile [time in seconds]")
}

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

process.on('exit', function<commit_msg>Quick fix<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",
  "Correcting style",
  "Logic error"
]

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 message = commit_messages[randomIntFromInterval(0, commit_messages.length - 1)]
    var args = ['commit', outFile, '-m', message]
    for (var counter = 0; counter < length; counter++)
    {
      var message = commit_messages[randomIntFromInterval(0, commit_messages.length - 1)]
      var args = ['commit', outFile, '-m', message]
      fs.writeSync(outFD, data.slice(counter, counter+1), 0, 1)
      sleep(Math.random() * max_sleep)
      child_process.execFileSync('/usr/bin/git', args)
    }
  })
} else {
  console.info("Usage:")
  console.info("node commit.js infile outfile [time in seconds]")
}

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

process.on('exit', function <|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_msg>You feeling lucky punk?<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(c<|endoftext|>


<commit_before>(function () {

  // TODO: serialzation/deserialization for: Promise, Generator, Proxy
  // TODO: working with native functions (e.g. setTimeout)

  'use strict';

  const globalObject = (typeof global === 'object') ? global : window;
  const exports = (typeof module === 'object' && typeof module.exports === 'object') ? module.exports : (globalObject.isopod = {});

  // ---------------
  // -- UTILITIES --
  // ---------------

  function each (obj, fn) {
    Object.keys(obj).forEach(function (k) {
      fn(k, obj[k]);
    });
  }

  function flags (r) {
    if (r.flags) return r.flags;
    return (r.ignoreCase ? 'i' : '') + (r.multiline ? 'm' : '') + (r.global ? 'g' : '') + (r.sticky ? 'y' : '');
  }

  // -------------------
  // -- SERIALIZATION --
  // -------------------

  const typedArrayConstructors = new Set([
    Int8Array,
    Uint8Array,
    Uint8ClampedArray,
    Int16Array,
    Uint16Array,
    Int32Array,
    Uint32Array,
    Float32Array,
    Float64Array
  ]);

  const typedArrayTypes = new Set();
  typedArrayConstructors.forEach(function (constructor) {
    typedArrayTypes.add(constructor.name);
  });

  const bufferableConstructors = new Set([
    DataView
  ]);
  typedArrayConstructors.forEach(function (constructor) {
    bufferableConstructors.add(constructor);
  });

  const bufferableTypes = new Map();
  bufferableConstructors.forEach(function (constructor) {
    bufferableTypes.set(constructor.name, constructor);
  });

  const specialTypes = new Set([
    undefined,
    null,
    NaN,
    Infinity,
    -Infinity
  ]);

  const nativeConstructors = new Set([
    Boolean,
    Number,
    Object,
    Function,
    Set,
    Symbol,
    Array,
    Map,
    RegExp,
    Error,
    ArrayBuffer,
    Date
  ]);
  bufferableConstructors.forEach(function (constructor) {
    nativeConstructors.add(constructor);
  });

  const nativePrototypes = new Set();
  nativeConstructors.forEach(function (constructor) {
    nativePrototypes.add(constructor.prototype);
  });

  const allowedTypes = new Set();
  nativeConstructors.forEach(function (constructor) {
    allowedTypes.add(constructor.name);
  });
  specialTypes.forEach(function (specialType) {
    allowedTypes.add(`${specialType}`);
  });

  function baseTypeOf (thing) {
    return Object.prototype.toString.call(thing).slice(8,-1);
  }

  function isopodTypeOf (thing) {
    const type = specialTypes.has(thing) ? `${thing}` : baseTypeOf(thing);
    return allowedTypes.has(type) ? type : 'Unsupported'; // TODO: consider throwing error for unsupported types
  }

  const parensPattern = /\(.+\)/;
  function getSymbolString (sym) {
    return sym.toString().match(parensPattern)[0].slice(1,-1);
  }

  function hasNonNativeConstructor (obj) {
    return Object.prototype.hasOwnProperty.call(obj, 'constructor') && !nativeConstructors.has(obj.constructor);
  }

  // TODO: better name
  function isRef (thing) {
    return thing instanceof Object || typeof thing === 'symbol' || specialTypes.has(thing);
  }

  function isPlainOrTypedArray (thing) {
    const type = baseTypeOf(thing);
    return type === 'Array' || typedArrayTypes.has(type);
  }

  // function getTypedArrayBuffer (typedArray) {
  //   // in case a typed array has a non-standard prototype
  //   const currentProto = Object.getPrototypeOf(typedArray);
  //   const originalProto = bufferableTypes.get(isopodTypeOf(typedArray)).prototype;
  //   // temporarily change prototype back to original
  //   Object.setPrototypeOf(typedArray, originalProto);
  //   // grab buffer off of it
  //   const buffer = typedArray.buffer;
  //   // change back to assigned prototype
  //   Object.setPrototypeOf(typedArray, currentProto);
  //   return buffer;
  // }

  function bufferableSource (bufferable) {
    // in case a bufferable has a non-standard prototype
    const currentProto = Object.getPrototypeOf(bufferable);
    const originalProto = bufferableTypes.get(isopodTypeOf(bufferable)).prototype;
    // temporarily change prototype back to original
    Object.setPrototypeOf(bufferable, originalProto);
    // a bufferable's source contains its buffer, the byteOffset, and the length
    const source = {
      buffer: bufferable.buffer,
      byteOffset: bufferable.byteOffset,
      length: bufferable.length
    };
    // change back to assigned prototype
    Object.setPrototypeOf(bufferable, currentProto);
    return source;
  }

  // given some object or primitive, convert it into a format that will retain all its details when stringified
  exports.serialize = function (root) {

    // deal with trivial case
    if (!isRef(root)) return root;

    // the serialized result will be an array of "dehydrated" objects
    const serialized = [];
    // the idCache keeps track of any objects (or symbols) that have been seen already
    const idCache = new Map();

    // incorporate an object (or symbol) into the cache and return the seed of a dehydrated stand-in
    function assoc (original) {
      const dehydrated = {};
      // the id represents the location of the dehydrated object in the root serialized array
      const id = serialized.push(dehydrated)-1;
      idCache.set(original, id);
      return dehydrated;
    }

    // catch-all to obtain various meaningful "source" values from native Object types
    function sourceValueFrom (original, type) {
      // objects and special values don't have a "source"
      if (type === 'Object' || specialTypes.has(original)) return;
      if (bufferableTypes.has(type)) {
        // make sure to attach the buffer by reference
        const source = bufferableSource(original);
        source.buffer = dehydrate(source.buffer);
        return source;
      }
      switch (type) {
        // a symbol's source is the string used to construct it
        case 'Symbol': return getSymbolString(original);
        // a function's source is its source string
        case 'Function': return Function.prototype.toString.call(original);
        case 'RegExp': return [original.source, flags(original)];
        case 'Error': {
          return {
            message: Object.prototype.hasOwnProperty.call(original, 'message') ? original.message : undefined,
            stack: original.stack
          };
        }
        // an array's source is an array copy of its elements
        case 'Array': return Array.prototype.map.call(original, dehydrate);
        case 'Set': {
          // a set's source is an array of the set elements
          const source = [];
          Set.prototype.forEach.call(original, function (elem) {
            source.push(dehydrate(elem));
          });
          return source;
        }
        case 'Map': {
          // a map's source is an array of key-value pair arrays
          const source = [];
          Map.prototype.forEach.call(original, function (v, k) {
            source.push([k,v].map(dehydrate));
          });
          return source;
        }
        // an array buffer's source is its Uint8Array representation
        case 'ArrayBuffer': return Array.prototype.slice.call(new Uint8Array(original));
        case 'Date': return Date.prototype.valueOf.call(original);
      }
    }

    // return any keys in the original not accounted for in the source
    function cloneKeys (original, source) {
      // special values do not have keys
      if (specialTypes.has(original)) return;
      const clone = {};
      const proto = Object.getPrototypeOf(original);
      // include original's __proto__ when cloning it, if it's non-native
      if (!nativePrototypes.has(proto)) {
        Object.defineProperty(clone, '__proto__', {
          value: dehydrate(proto),
          enumerable: true // ensure that it will show up as a result of stringification
        });
      }
      // include the original's constructor if it has one
      if (hasNonNativeConstructor(original)) {
        const constructor = original.constructor;
        if (constructor instanceof Object && constructor.prototype === original) {
          clone.constructor = dehydrate(constructor);
        }
      }
      // include all keys in original not yet accounted for by the source
      each(original, function (k, v) {
        // make sure not to double include numerical array keys already in the source
        if (source && isPlainOrTypedArray(original) && !Number.isNaN(Number(k))) return;
        clone[k] = dehydrate(v);
      });
      return clone;
    }

    // convert something into a rehydratable format
    function dehydrate (thing) {
      // non-refs (i.e. something that is neither a symbol, an object, nor a special value) remain themselves
      if (!isRef(thing)) return thing;
      if (!idCache.has(thing)) {
        // incorporate the object into the cache
        const dehydrated = assoc(thing);
        // set its type (helps streamline deserialization)
        dehydrated.type = isopodTypeOf(thing);
        // set its "source" value (helps streamline deserialization)
        dehydrated.source = sourceValueFrom(thing, dehydrated.type);
        // set any additional keys not included in the source
        dehydrated.keys = cloneKeys(thing, dehydrated.source);
      }
      // objects are replaced with the id representing their location in the root serialized array (helps streamline deserialization)
      return [idCache.get(thing)]
    }

    // kick off the recursive process of dehydrating everything in the original
    dehydrate(root);

    return serialized;

  };

  // ---------------------
  // -- DESERIALIZATION --
  // ---------------------

  // convert a dehydrated object back into something of the correct type
  function typedFromDehydrated (dehydrated) {
    switch (dehydrated.type) {
      case 'Symbol': return Symbol(dehydrated.source);
      case 'Function': return eval(`(${dehydrated.source})`); // TODO: alternative to eval
      case 'Set': return new Set();
      case 'Map': return new Map();
      case 'Array': return [];
      case 'RegExp': return new RegExp(dehydrated.source[0], dehydrated.source[1]);
      case 'Error': {
        const err = Error(dehydrated.source.message);
        if (dehydrated.source.stack) {
          Object.defineProperty(err, 'stack', {
            value: dehydrated.source.stack,
            enumerable: false
          });
        }
        return err;
      }
      case 'Object': return {};
      case 'null': return null;
      case 'undefined': return undefined;
      case 'NaN': return NaN;
      case 'Infinity': return Infinity;
      case '-Infinity': return -Infinity;
      case 'ArrayBuffer': return new Uint8Array(dehydrated.source).buffer;
      case 'Date': return new Date(dehydrated.source);
    }
  }

  // use the dehydrated format to populate an empty object of the correct type
  function hydrateOne (hydrated, dehydrated, refs) {
    // special values need no further hydration
    if (specialTypes.has(hydrated)) return;
    // account for any objects that are duplicate references
    function possibleRef (v) {
      return Array.isArray(v) ? refs[v[0]] : v;
    }
    switch (dehydrated.type) {
      case 'Set': {
        // a set incorporates its source array as elements
        dehydrated.source.forEach(function (elem) {
          hydrated.add(possibleRef(elem));
        });
        break;
      }
      case 'Map': {
        // a map incorporates its source array as key-value entries
        dehydrated.source.forEach(function (mapEntry) {
          const k = mapEntry[0]; // TODO: could replace with destructuring
          const v = mapEntry[1]; // TODO: could replace with destructuring
          hydrated.set(possibleRef(k), possibleRef(v));
        });
        break;
      }
      case 'Array': {
        // an array incorporates its source array as elements
        dehydrated.source.forEach(function (elem) {
          hydrated.push(possibleRef(elem));
        });
        break;
      }
    }
    // incorporate any additional keys from the dehydrated object
    each(dehydrated.keys, function (k, v) {
      if (k === 'constructor') {
        Object.defineProperty(hydrated, 'constructor', {
          value: possibleRef(v),
          enumerable: false
        });
      } else {
        hydrated[k] = possibleRef(v);
      }
    });
  }

  // convert a serialized thing into a fully imbued clone of the original, i.e. the one that got serialized in the first place
  exports.deserialize = function (serialized) {
    // if the base serialized root is not an array it is simply a primitive value
    if (!Array.isArray(serialized)) return serialized;
    // the mapping corresponds the being-hydrated and dehydrated versions of the data
    const mapping = new Map();
    // stores bufferables to get to after the first pass
    const todoBufferables = new Map();
    // hold references to the being-hydrated objects
    const refs = serialized.map(function (dehydrated, index) {
      if (bufferableTypes.has(dehydrated.type)) {
        // will need the dehydrated version and index in refs array for later use
        todoBufferables.set(dehydrated, index);
      } else {
        const emptyHydrated = typedFromDehydrated(dehydrated);
        mapping.set(dehydrated, emptyHydrated);
        return emptyHydrated;
      }
    });
    // bufferables cannot be constructed as empty and filled in later, they need their underlying buffer at construction time, which we only have access to after the first pass
    todoBufferables.forEach(function (index, dehydrated) {
      const constructor = bufferableTypes.get(dehydrated.type);
      const buffer = refs[dehydrated.source.buffer[0]];
      const byteOffset = dehydrated.source.byteOffset;
      const length = dehydrated.source.length;
      const bufferable = new constructor(buffer, byteOffset, length);
      // attach properly typed reference at that index
      refs[index] = bufferable;
      // include properly typed reference to be further enriched in the final hydration step
      mapping.set(dehydrated, bufferable);
    });
    // final pass, imbue each empty (but properly typed) object with all its glorious details
    mapping.forEach(function (emptyHydrated, dehydrated) {
      hydrateOne(emptyHydrated, dehydrated, refs);
    });
    // the first ref is now a clone of the base object that was originally serialized
    return refs[0];
  };

})();
<commit_msg>Remove dead code<commit_after>(function () {

  // TODO: serialzation/deserialization for: Promise, Generator, Proxy
  // TODO: working with native functions (e.g. setTimeout)

  'use strict';

  const globalObject = (typeof global === 'object') ? global : window;
  const exports = (typeof module === 'object' && typeof module.exports === 'object') ? module.exports : (globalObject.isopod = {});

  // ---------------
  // -- UTILITIES --
  // ---------------

  function each (obj, fn) {
    Object.keys(obj).forEach(function (k) {
      fn(k, obj[k]);
    });
  }

  function flags (r) {
    if (r.flags) return r.flags;
    return (r.ignoreCase ? 'i' : '') + (r.multiline ? 'm' : '') + (r.global ? 'g' : '') + (r.sticky ? 'y' : '');
  }

  // -------------------
  // -- SERIALIZATION --
  // -------------------

  const typedArrayConstructors = new Set([
    Int8Array,
    Uint8Array,
    Uint8ClampedArray,
    Int16Array,
    Uint16Array,
    Int32Array,
    Uint32Array,
    Float32Array,
    Float64Array
  ]);

  const typedArrayTypes = new Set();
  typedArrayConstructors.forEach(function (constructor) {
    typedArrayTypes.add(constructor.name);
  });

  const bufferableConstructors = new Set([
    DataView
  ]);
  typedArrayConstructors.forEach(function (constructor) {
    bufferableConstructors.add(constructor);
  });

  const bufferableTypes = new Map();
  bufferableConstructors.forEach(function (constructor) {
    bufferableTypes.set(constructor.name, constructor);
  });

  const specialTypes = new Set([
    undefined,
    null,
    NaN,
    Infinity,
    -Infinity
  ]);

  const nativeConstructors = new Set([
    Boolean,
    Number,
    Object,
    Function,
    Set,
    Symbol,
    Array,
    Map,
    RegExp,
    Error,
    ArrayBuffer,
    Date
  ]);
  bufferableConstructors.forEach(function (constructor) {
    nativeConstructors.add(constructor);
  });

  const nativePrototypes = new Set();
  nativeConstructors.forEach(function (constructor) {
    nativePrototypes.add(constructor.prototype);
  });

  const allowedTypes = new Set();
  nativeConstructors.forEach(function (constructor) {
    allowedTypes.add(constructor.name);
  });
  specialTypes.forEach(function (specialType) {
    allowedTypes.add(`${specialType}`);
  });

  function baseTypeOf (thing) {
    return Object.prototype.toString.call(thing).slice(8,-1);
  }

  function isopodTypeOf (thing) {
    const type = specialTypes.has(thing) ? `${thing}` : baseTypeOf(thing);
    return allowedTypes.has(type) ? type : 'Unsupported'; // TODO: consider throwing error for unsupported types
  }

  const parensPattern = /\(.+\)/;
  function getSymbolString (sym) {
    return sym.toString().match(parensPattern)[0].slice(1,-1);
  }

  function hasNonNativeConstructor (obj) {
    return Object.prototype.hasOwnProperty.call(obj, 'constructor') && !nativeConstructors.has(obj.constructor);
  }

  // TODO: better name
  function isRef (thing) {
    return thing instanceof Object || typeof thing === 'symbol' || specialTypes.has(thing);
  }

  function isPlainOrTypedArray (thing) {
    const type = baseTypeOf(thing);
    return type === 'Array' || typedArrayTypes.has(type);
  }

  function bufferableSource (bufferable) {
    // in case a bufferable has a non-standard prototype
    const currentProto = Object.getPrototypeOf(bufferable);
    const originalProto = bufferableTypes.get(isopodTypeOf(bufferable)).prototype;
    // temporarily change prototype back to original
    Object.setPrototypeOf(bufferable, originalProto);
    // a bufferable's source contains its buffer, the byteOffset, and the length
    const source = {
      buffer: bufferable.buffer,
      byteOffset: bufferable.byteOffset,
      length: bufferable.length
    };
    // change back to assigned prototype
    Object.setPrototypeOf(bufferable, currentProto);
    return source;
  }

  // given some object or primitive, convert it into a format that will retain all its details when stringified
  exports.serialize = function (root) {

    // deal with trivial case
    if (!isRef(root)) return root;

    // the serialized result will be an array of "dehydrated" objects
    const serialized = [];
    // the idCache keeps track of any objects (or symbols) that have been seen already
    const idCache = new Map();

    // incorporate an object (or symbol) into the cache and return the seed of a dehydrated stand-in
    function assoc (original) {
      const dehydrated = {};
      // the id represents the location of the dehydrated object in the root serialized array
      const id = serialized.push(dehydrated)-1;
      idCache.set(original, id);
      return dehydrated;
    }

    // catch-all to obtain various meaningful "source" values from native Object types
    function sourceValueFrom (original, type) {
      // objects and special values don't have a "source"
      if (type === 'Object' || specialTypes.has(original)) return;
      if (bufferableTypes.has(type)) {
        // make sure to attach the buffer by reference
        const source = bufferableSource(original);
        source.buffer = dehydrate(source.buffer);
        return source;
      }
      switch (type) {
        // a symbol's source is the string used to construct it
        case 'Symbol': return getSymbolString(original);
        // a function's source is its source string
        case 'Function': return Function.prototype.toString.call(original);
        case 'RegExp': return [original.source, flags(original)];
        case 'Error': {
          return {
            message: Object.prototype.hasOwnProperty.call(original, 'message') ? original.message : undefined,
            stack: original.stack
          };
        }
        // an array's source is an array copy of its elements
        case 'Array': return Array.prototype.map.call(original, dehydrate);
        case 'Set': {
          // a set's source is an array of the set elements
          const source = [];
          Set.prototype.forEach.call(original, function (elem) {
            source.push(dehydrate(elem));
          });
          return source;
        }
        case 'Map': {
          // a map's source is an array of key-value pair arrays
          const source = [];
          Map.prototype.forEach.call(original, function (v, k) {
            source.push([k,v].map(dehydrate));
          });
          return source;
        }
        // an array buffer's source is its Uint8Array representation
        case 'ArrayBuffer': return Array.prototype.slice.call(new Uint8Array(original));
        case 'Date': return Date.prototype.valueOf.call(original);
      }
    }

    // return any keys in the original not accounted for in the source
    function cloneKeys (original, source) {
      // special values do not have keys
      if (specialTypes.has(original)) return;
      const clone = {};
      const proto = Object.getPrototypeOf(original);
      // include original's __proto__ when cloning it, if it's non-native
      if (!nativePrototypes.has(proto)) {
        Object.defineProperty(clone, '__proto__', {
          value: dehydrate(proto),
          enumerable: true // ensure that it will show up as a result of stringification
        });
      }
      // include the original's constructor if it has one
      if (hasNonNativeConstructor(original)) {
        const constructor = original.constructor;
        if (constructor instanceof Object && constructor.prototype === original) {
          clone.constructor = dehydrate(constructor);
        }
      }
      // include all keys in original not yet accounted for by the source
      each(original, function (k, v) {
        // make sure not to double include numerical array keys already in the source
        if (source && isPlainOrTypedArray(original) && !Number.isNaN(Number(k))) return;
        clone[k] = dehydrate(v);
      });
      return clone;
    }

    // convert something into a rehydratable format
    function dehydrate (thing) {
      // non-refs (i.e. something that is neither a symbol, an object, nor a special value) remain themselves
      if (!isRef(thing)) return thing;
      if (!idCache.has(thing)) {
        // incorporate the object into the cache
        const dehydrated = assoc(thing);
        // set its type (helps streamline deserialization)
        dehydrated.type = isopodTypeOf(thing);
        // set its "source" value (helps streamline deserialization)
        dehydrated.source = sourceValueFrom(thing, dehydrated.type);
        // set any additional keys not included in the source
        dehydrated.keys = cloneKeys(thing, dehydrated.source);
      }
      // objects are replaced with the id representing their location in the root serialized array (helps streamline deserialization)
      return [idCache.get(thing)]
    }

    // kick off the recursive process of dehydrating everything in the original
    dehydrate(root);

    return serialized;

  };

  // ---------------------
  // -- DESERIALIZATION --
  // ---------------------

  // convert a dehydrated object back into something of the correct type
  function typedFromDehydrated (dehydrated) {
    switch (dehydrated.type) {
      case 'Symbol': return Symbol(dehydrated.source);
      case 'Function': return eval(`(${dehydrated.source})`); // TODO: alternative to eval
      case 'Set': return new Set();
      case 'Map': return new Map();
      case 'Array': return [];
      case 'RegExp': return new RegExp(dehydrated.source[0], dehydrated.source[1]);
      case 'Error': {
        const err = Error(dehydrated.source.message);
        if (dehydrated.source.stack) {
          Object.defineProperty(err, 'stack', {
            value: dehydrated.source.stack,
            enumerable: false
          });
        }
        return err;
      }
      case 'Object': return {};
      case 'null': return null;
      case 'undefined': return undefined;
      case 'NaN': return NaN;
      case 'Infinity': return Infinity;
      case '-Infinity': return -Infinity;
      case 'ArrayBuffer': return new Uint8Array(dehydrated.source).buffer;
      case 'Date': return new Date(dehydrated.source);
    }
  }

  // use the dehydrated format to populate an empty object of the correct type
  function hydrateOne (hydrated, dehydrated, refs) {
    // special values need no further hydration
    if (specialTypes.has(hydrated)) return;
    // account for any objects that are duplicate references
    function possibleRef (v) {
      return Array.isArray(v) ? refs[v[0]] : v;
    }
    switch (dehydrated.type) {
      case 'Set': {
        // a set incorporates its source array as elements
        dehydrated.source.forEach(function (elem) {
          hydrated.add(possibleRef(elem));
        });
        break;
      }
      case 'Map': {
        // a map incorporates its source array as key-value entries
        dehydrated.source.forEach(function (mapEntry) {
          const k = mapEntry[0]; // TODO: could replace with destructuring
          const v = mapEntry[1]; // TODO: could replace with destructuring
          hydrated.set(possibleRef(k), possibleRef(v));
        });
        break;
      }
      case 'Array': {
        // an array incorporates its source array as elements
        dehydrated.source.forEach(function (elem) {
          hydrated.push(possibleRef(elem));
        });
        break;
      }
    }
    // incorporate any additional keys from the dehydrated object
    each(dehydrated.keys, function (k, v) {
      if (k === 'constructor') {
        Object.defineProperty(hydrated, 'constructor', {
          value: possibleRef(v),
          enumerable: false
        });
      } else {
        hydrated[k] = possibleRef(v);
      }
    });
  }

  // convert a serialized thing into a fully imbued clone of the original, i.e. the one that got serialized in the first place
  exports.deserialize = function (serialized) {
    // if the base serialized root is not an array it is simply a primitive value
    if (!Array.isArray(serialized)) return serialized;
    // the mapping corresponds the being-hydrated and dehydrated versions of the data
    const mapping = new Map();
    // stores bufferables to get to after the first pass
    const todoBufferables = new Map();
    // hold references to the being-hydrated objects
    const refs = serialized.map(function (dehydrated, index) {
      if (bufferableTypes.has(dehydrated.type)) {
        // will need the dehydrated version and index in refs array for later use
        todoBufferables.set(dehydrated, index);
      } else {
        const emptyHydrated = typedFromDehydrated(dehydrated);
        mapping.set(dehydrated, emptyHydrated);
        return emptyHydrated;
      }
    });
    // bufferables cannot be constructed as empty and filled in later, they need their underlying buffer at construction time, which we only have access to after the first pass
    todoBufferables.forEach(function (index, dehydrated) {
      const constructor = bufferableTypes.get(dehydrated.type);
      const buffer = refs[dehydrated.source.buffer[0]];
      const byteOffset = dehydrated.source.byteOffset;
      const length = dehydrated.source.length;
      const bufferable = new constructor(buffer, byteOffset, length);
      // attach properly typed reference at that index
      refs[index] = bufferable;
      // include properly typed reference to be further enriched in the final hydration step
      mapping.set(dehydrated, bufferable);
    });
    // final pass, imbue each empty (but properly typed) object with all its glorious details
    mapping.forEach(function (emptyHydrated, dehydrated) {
      hydrateOne(emptyHydrated, dehydrated, refs);
    });
    // the first ref is now a clone of the base object that was originally serialized
    return refs[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] [<commit_msg>Well that seemed pretty easy<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] [s<|endoftext|>


<commit_before>var fs = require('fs');
var child_process = require('child_process')
var max_sleep = 300
//Added a comm<commit_msg>Fixed a typo<commit_after>var fs = require('fs');
var child_process = require('child_process')
var max_sleep = 300
//Added a comme<|endoftext|>


<commit_before>/* eslint-env node */
'use strict';

const writeFile = require('broccoli-file-creator');
const mergeTrees = require('broccoli-merge-trees');
const dasherize = require('ember-cli-string-utils').dasherize;

function addMath(trees) {
  let index = '';

  Object.getOwnPropertyNames(Math).forEach(key => {
    let func = Math[key];
    if (typeof func === 'function' && func.length) {
      let dasherized = dasherize(key);
      index += `export { default as ${key} } from './${dasherized}';`;
      trees.push(writeFile(`math/${dasherized}.js`, `
        import curriedComputed from 'ember-macro-helpers/curried-computed';

        export default curriedComputed(Math.${key});
      `));
    }
  });

  trees.push(writeFile(`math/index.js`, index));
}

module.exports = {
  name: 'ember-awesome-macros',

  treeForAddon(tree) {
    let trees = [tree];

    addMath(trees);

    tree = mergeTrees(trees);

    return this._super.treeForAddon.call(this, tree);
  }
};
<commit_msg>fix linting error<commit_after>/* eslint-env node */
'use strict';

const writeFile = require('broccoli-file-creator');
const mergeTrees = require('broccoli-merge-trees');
const dasherize = require('ember-cli-string-utils').dasherize;

function addMath(trees) {
  let index = '';

  Object.getOwnPropertyNames(Math).forEach(key => {
    let func = Math[key];
    if (typeof func === 'function' && func.length) {
      let dasherized = dasherize(key);
      index += `export { default as ${key} } from './${dasherized}';`;
      trees.push(writeFile(`math/${dasherized}.js`, `
        import curriedComputed from 'ember-macro-helpers/curried-computed';

        export default curriedComputed(Math.${key});
      `));
    }
  });

  trees.push(writeFile('math/index.js', index));
}

module.exports = {
  name: 'ember-awesome-macros',

  treeForAddon(tree) {
    let trees = [tree];

    addMath(trees);

    tree = mergeTrees(trees);

    return this._super.treeForAddon.call(this, tree);
  }
};
<|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);
    }
 <commit_msg>Fixing punctuation<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);
    }
  <|endoftext|>