text:
using System;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using System.Xml.Linq;

namespace Editor
{
    public sealed class MatrixEquation : EquationContainer
    {
        int columns = 1;
        int rows = 1;
        double CellSpace { get { return FontSize * .7; } }

        public override Thickness Margin
        {
            get { return new Thickness(FontSize * .15, 0, FontSize * .15, 0); }
        }

        public MatrixEquation(EquationContainer parent, int rows, int columns)
            : base(parent)
        {
            this.rows = rows;
            this.columns = columns;
            for (int i = 0; i < columns * rows; i++)
            {
                childEquations.Add(new RowContainer(this));
            }
            ActiveChild = childEquations.First();
        }

        public override XElement Serialize()
        {
            XElement thisElement = new XElement(GetType().Name);
            XElement parameters = new XElement("parameters");
            parameters.Add(new XElement(typeof(int).FullName, rows));
            parameters.Add(new XElement(typeof(int).FullName, columns));
            thisElement.Add(parameters);
            foreach (EquationBase eb in childEquations)
            {
                thisElement.Add(eb.Serialize());
            }
            return thisElement;
        }

        public override void DeSerialize(XElement xElement)
        {
            XElement[] elements = xElement.Elements(typeof(RowContainer).Name).ToArray();
            for (int i = 0; i < childEquations.Count; i++)
            {
                childEquations[i].DeSerialize(elements[i]);
            }
            CalculateSize();
        }

        public override double Top
        {
            get { return base.Top; }
            set
            {
                base.Top = value;
                double[] rowRefYs = new double[rows];
                double[] topOffsets = new double[rows + 1];

                for (int i = 0; i < rows; i++)
                {
                    rowRefYs[i] = childEquations.Skip(i * columns).Take(columns).Max(x => x.RefY);
                    topOffsets[i + 1] = childEquations.Skip(i * columns).Take(columns).Max(x => x.Height) + topOffsets[i];
                }

                for (int i = 0; i < rows; i++)
                {
                    for (int j = 0; j < columns; j++)
                    {
                        childEquations[i * columns + j].MidY = Top + rowRefYs[i] + topOffsets[i] + CellSpace * i;
                    }
                }
            }
        }

        public override double Left
        {
            get { return base.Left; }
            set
            {
                base.Left = value;
                double[] columnRefXs = new double[columns];
                double[] leftOffsets = new double[columns + 1];
                for (int i = 0; i < columns; i++)
                {
                    for (int j = 0; j < rows; j++)
                    {
                        columnRefXs[i] = Math.Max(childEquations[j * columns + i].RefX, columnRefXs[i]);
                        leftOffsets[i + 1] = Math.Max(childEquations[j * columns + i].Width, leftOffsets[i + 1]);
                    }
                    leftOffsets[i + 1] += leftOffsets[i];
                }
                for (int i = 0; i < columns; i++)
                {
                    for (int j = 0; j < rows; j++)
                    {
                        childEquations[j * columns + i].MidX = value + columnRefXs[i] + leftOffsets[i] + CellSpace * i;
                    }
                }
            }
        }

        protected override void CalculateWidth()
        {
            double[] columnWidths = new double[columns];
            for (int i = 0; i < columns; i++)
            {
                for (int j = 0; j < rows; j++)
                {
                    columnWidths[i] = Math.Max(childEquations[j * columns + i].Width, columnWidths[i]);
                }
            }
            Width = columnWidths.Sum() + CellSpace * (columns - 1);
        }

        protected override void CalculateHeight()
        {
            double[] rowHeights = new double[rows];
            for (int i = 0; i < rows; i++)
            {
                rowHeights[i] = childEquations.Skip(i * columns).Take(columns).Max(x => x.Height);
            }
            Height = rowHeights.Sum() + CellSpace * (rows - 1);
        }

        public override double RefY
        {
            get
            {
                if (rows == 1)
                {
                    return childEquations.Max(x => x.RefY);
                }
                else if (rows % 2 == 0)
                {
                    //return childEquations.Take(rows / 2 * columns).Sum(x => x.Height) - CellSpace / 2 + FontSize * .3;
                    double[] rowHeights = new double[rows / 2];
                    for (int i = 0; i < rows / 2; i++)
                    {
                        rowHeights[i] = childEquations.Skip(i * columns).Take(columns).Max(x => x.Height);
                    }
                    return rowHeights.Sum() + CellSpace * rows/2 - CellSpace/2 + FontSize * .1;
                }
                else
                {
                    //return childEquations.Skip(rows / 2 * columns).Take(columns).Max(x => x.MidY) - Top;
                    double[] rowHeights = new double[rows / 2 + 1];
                    for (int i = 0; i < rows / 2; i++)
                    {
                        rowHeights[i] = childEquations.Skip(i * columns).Take(columns).Max(x => x.Height);
                    }
                    rowHeights[rows / 2] = childEquations.Skip(rows / 2 * columns).Take(columns).Max(x => x.RefY);
                    return rowHeights.Sum() + CellSpace * (rows / 2);// -FontSize * .1;
                }
            }
        }

        public override bool ConsumeKey(Key key)
        {
            if (ActiveChild.ConsumeKey(key))
            {
                CalculateSize();
                return true;
            }
            int currentIndex = childEquations.IndexOf(ActiveChild);
            if (key == Key.Right)
            {
                if (currentIndex % columns < columns - 1)//not last column?
                {
                    ActiveChild = childEquations[currentIndex + 1];
                    return true;
                }
            }
            else if (key == Key.Left)
            {
                if (currentIndex % columns > 0)//not last column?
                {
                    ActiveChild = childEquations[currentIndex - 1];
                    return true;
                }
            }
            else if (key == Key.Up)
            {
                if (currentIndex / columns > 0)//not in first row?
                {
                    Point point = ActiveChild.GetVerticalCaretLocation();
                    ActiveChild = childEquations[currentIndex - columns]; ;
                    point.Y = ActiveChild.Top + 1;
                    ActiveChild.SetCursorOnKeyUpDown(key, point);
                    return true;
                }
            }
            else if (key == Key.Down)
            {
                if (currentIndex / columns < rows - 1)//not in last row?
                {
                    Point point = ActiveChild.GetVerticalCaretLocation();
                    ActiveChild = childEquations[currentIndex + columns]; ;
                    point.Y = ActiveChild.Top + 1;
                    ActiveChild.SetCursorOnKeyUpDown(key, point);
                    return true;
                }
            }
            return false;
        }
    }
}


text:
package ch.heigvd.amt.gamy.web.controllers;

import ch.heigvd.amt.gamy.services.dao.TestDataManagerLocal;
import java.io.IOException;
import java.sql.Date;
import javax.ejb.EJB;
import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * GenRandomData is the controller affected to the generation of the testing
 * data. This servlet read from the URL all information of what it should do:
 * customGen is the mode of generation.
 * nbAcc is the number of account to create.
 * nbApp is how many apps per account.
 * nbEndUser is the number of end user per app.
 * forceDate is the fictive date when all was created.
 */

public class GenRandomData extends HttpServlet {

   @EJB
   TestDataManagerLocal testDataManager;

   /**
    * Processes requests for both HTTP GET and POST
    * methods.
    *
    * @param request servlet request
    * @param response servlet response
    * @throws ServletException if a servlet-specific error occurs
    * @throws IOException if an I/O error occurs
    */
   protected void processRequest(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
      response.setContentType("text/html;charset=UTF-8");
   }

   /**
    * Handles the HTTP GET method.
    *
    * @param request servlet request
    * @param response servlet response
    * @throws ServletException if a servlet-specific error occurs
    * @throws IOException if an I/O error occurs
    */
   @Override
   protected void doGet(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {

      // Read the parameter from the URL.
      String customGen = request.getParameter("customGen");

      // If it null do nothing.
      if (customGen != null) {

         // Look at the mode generation. Mode 1.
         if (Integer.parseInt(customGen) == 1) {

            // Try to create all data specified on the URL.
            try {
               testDataManager.generateTestData(Integer.parseInt(request.getParameter("nbAcc")),
                       Integer.parseInt(request.getParameter("nbApp")),
                       Integer.parseInt(request.getParameter("nbEndUser")),
                       Date.valueOf(request.getParameter("forceDate")));
            } catch (Exception ex) {

               // If something bad happen during the generation.
               // TODO : do something as an error.
               /*response.sendError(404);
               return;*/
            }
         }
      }
	  else {
		  try {
               testDataManager.generateTestData();
            } catch (Exception ex) {

               // If something bad happen during the generation.
               // TODO : do something as an error.
               /*response.sendError(404);
               return;*/
            }
	  }

      // Redirect to homeapps.
      response.sendRedirect("homeapps");
   }

   /**
    * Handles the HTTP POST method.
    *
    * @param request servlet request
    * @param response servlet response
    * @throws ServletException if a servlet-specific error occurs
    * @throws IOException if an I/O error occurs
    */
   @Override
   protected void doPost(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
      processRequest(request, response);
   }

   /**
    * Returns a short description of the servlet.
    *
    * @return a String containing servlet description
    */
   @Override
   public String getServletInfo() {
      return "Short description";
   }
}

redpajama_set_name: RedPajamaGithub


text:
package com.s24.search.solr.analysis.jdbc;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.sql.DataSource;
import java.util.Map;
import java.util.Objects;

/**
 * Factory to create {@link JdbcReader}s from a Solr params.
 */
@SuppressWarnings("unused") // API
public final class JdbcReaderFactory {
   /**
    * Logger.
    */
   private static final Logger LOGGER = LoggerFactory.getLogger(JdbcReaderFactory.class);

   /**
    * Create the {@link JdbcReader} from configuration.
    *
    * Set synonyms file to a fixed name.
    * This is needed because our patched resource loader should load the synonyms exactly once.
    *
    * @param config
    *           Configuration.
    * @param originalParamName
    *           Default synonym file name.
    * @return JdbcReader.
    */
   public static JdbcReader createFromSolrParams(Map<String, String> config, String originalParamName) {
      Objects.requireNonNull(config);

      // Set a fixed synonyms "file".
      // This "file" will be loaded from the database by the JdbcResourceLoader.
      if (originalParamName != null) {
         config.put(originalParamName, JdbcResourceLoader.DATABASE);
      }

      DataSource dataSource = JdbcDataSourceFactory.getDataSource(config);
      String sql = config.remove(JdbcReaderFactoryParams.SQL);
      String ignoreString = config.remove(JdbcReaderFactoryParams.IGNORE);
      boolean ignore = !"false".equals(ignoreString);

      return new SimpleJdbcReader(dataSource, sql, ignore);
   }
}


text:
            <a class="brand hidden-desktop" href="<?php echo SITE_URL; ?>">
                Navigate

                 <?php include_once 'main_menu_items.php'; ?>


text:
module Spree
  class Promotion
    module Actions
      CreateAdjustment.class_eval do
        def compute_amount(order)
          if calculator.is_a?(Calculator::FlatPercentOrderTotal)
            compute(order) * -1
          else
            [(order.item_total + order.ship_total), compute(order)].min * -1
          end
        end
      end
    end
  end
end


text:
void ProcDamageRegister::activateProc(string effectName){
}

void ProcDamageRegister::applyDamage(string skill, int damage){
}


text:
import React, { Component } from 'react';
import Button from 'react-bootstrap/lib/Button';

class Tables extends Component {

	constructor() {
		super();
		this.state = {
			init: false,
			tableNames: null,
		};
	}

	listTables() {
		console.log('in list tables');
		var dynamodb = this.props.dynamodb;
		if (dynamodb != null) {
			dynamodb.listTables(function(err, data) {
				console.log("returning table names: " + data.TableNames);
				this.setState({
					init: true,
					tableNames: data.TableNames,
				});
			}.bind(this));
		}
		else {
			this.setState({
				init: true
			});
		}
	}

	createNewTable() {
		var inputElement = document.getElementById("DBNameText");
		if (inputElement == null) return;

		var tableName = inputElement.value;
		if (tableName === "") {
			alert('Please enter the name of the new person');
			return;
		}

		var dynamodb = this.props.dynamodb;
		if (dynamodb == null) {
			console.log('no dynamodb');
			return;
		}

		var params = {
			TableName : tableName,
			KeySchema: [
				{ AttributeName: "year", KeyType: "HASH"},  //Partition key
				{ AttributeName: "title", KeyType: "RANGE" }  //Sort key
			],
			AttributeDefinitions: [
				{ AttributeName: "year", AttributeType: "N" },
				{ AttributeName: "title", AttributeType: "S" }
			],
			ProvisionedThroughput: {
				ReadCapacityUnits: 10,
				WriteCapacityUnits: 10
			}
		};

		console.log("about to create a table");
		dynamodb.createTable(params, function(err, data) {
			if (err) {
				console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2));
			} else {
				console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2));
				this.listTables();
			}
		}.bind(this));
	}

	renderHeader() {
		return

			<input id="DBNameText" name="DBNameText" className="DB Name" type="text"/>
			<Button bsStyle="primary" onClick={() => this.createNewTable()}> Create Table </Button>

;
	}

	render() {
		console.log('render table names');
		if (this.state.tableNames == null) {
			if (!this.state.init) {
				this.listTables();
			}
			return this.renderHeader();
		}
		else {
			console.log('about to render the names');
			return (

					{this.renderHeader()}

Table Names

					{this.state.tableNames.map(function(item, i) {
						return (
{item}
);
					})}

);
		}
	}
}

export default Tables;


text:
package org.mule.mvel2.optimizers.dynamic;

import org.mule.mvel2.compiler.Accessor;

public interface DynamicAccessor extends Accessor {
  public void deoptimize();
}


text:
Calculator
==========

This is a command-line tool that is simply a front-end for the CalcLib library.