text:
package mekanism.common.multipart;

import java.util.ArrayList;

import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.api.Range4D;
import mekanism.common.Mekanism;
import mekanism.common.Tier.TransporterTier;
import mekanism.common.content.transporter.TransporterStack;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.util.MekanismUtils;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;

import io.netty.buffer.ByteBuf;

public class PartDiversionTransporter extends PartLogisticalTransporter
{
	public int[] modes = {0, 0, 0, 0, 0, 0};

	@Override
	public String getType()
	{
		return "mekanism:diversion_transporter";
	}

	@Override
	public TransmitterType getTransmitterType()
	{
		return TransmitterType.DIVERSION_TRANSPORTER;
	}

	@Override
	public IIcon getCenterIcon(boolean opaque)
	{
		return transporterIcons.getCenterIcon(5);
	}

	@Override
	public IIcon getSideIcon(boolean opaque)
	{
		return transporterIcons.getSideIcon(opaque ? 14 : (getTransmitter().color != null ? 11 : 10));
	}

	@Override
	public IIcon getSideIconRotated(boolean opaque)
	{
		return transporterIcons.getSideIcon(opaque ? 15 : (getTransmitter().color != null ? 13 : 12));
	}

	@Override
	public boolean renderCenter()
	{
		return true;
	}

	@Override
	public void load(NBTTagCompound nbtTags)
	{
		super.load(nbtTags);

		modes = nbtTags.getIntArray("modes");
	}

	@Override
	public void save(NBTTagCompound nbtTags)
	{
		super.save(nbtTags);

		nbtTags.setIntArray("modes", modes);
	}

	@Override
	public void handlePacketData(ByteBuf dataStream) throws Exception
	{
		super.handlePacketData(dataStream);

		modes[0] = dataStream.readInt();
		modes[1] = dataStream.readInt();
		modes[2] = dataStream.readInt();
		modes[3] = dataStream.readInt();
		modes[4] = dataStream.readInt();
		modes[5] = dataStream.readInt();
	}

	@Override
	public ArrayList getNetworkedData(ArrayList data)
	{
		data = super.getNetworkedData(data);

		data.add(modes[0]);
		data.add(modes[1]);
		data.add(modes[2]);
		data.add(modes[3]);
		data.add(modes[4]);
		data.add(modes[5]);

		return data;
	}

	@Override
	public ArrayList getSyncPacket(TransporterStack stack, boolean kill)
	{
		ArrayList data = super.getSyncPacket(stack, kill);

		data.add(modes[0]);
		data.add(modes[1]);
		data.add(modes[2]);
		data.add(modes[3]);
		data.add(modes[4]);
		data.add(modes[5]);

		return data;
	}

	@Override
	protected boolean onConfigure(EntityPlayer player, int part, int side)
	{
		int newMode = (modes[side] + 1) % 3;
		String description = "ERROR";

		modes[side] = newMode;

		switch(newMode)
		{
			case 0:
				description = MekanismUtils.localize("control.disabled.desc");
				break;
			case 1:
				description = MekanismUtils.localize("control.high.desc");
				break;
			case 2:
				description = MekanismUtils.localize("control.low.desc");
				break;
		}

		refreshConnections();
		tile().notifyPartChange(this);
		notifyTileChange();
		player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleDiverter") + ": " + EnumColor.RED + description));
		Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tile()), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tile())));

		return true;
	}

	@Override
	public boolean canConnect(ForgeDirection side)
	{
		if(!super.canConnect(side))
		{
			return false;
		}

		int mode = modes[side.ordinal()];
		boolean redstone = world().isBlockIndirectlyGettingPowered(x(), y(), z());

		if((mode == 2 && redstone == true) || (mode == 1 && redstone == false))
		{
			return false;
		}

		return true;
	}
}


text:
package revel

// SessionFilter is a Revel Filter that retrieves and sets the session cookie.
// Within Revel, it is available as a Session attribute on Controller instances.
// The name of the Session cookie is set as CookiePrefix + "_SESSION".

var sessionLog = RevelLog.New("section", "session")

func SessionFilter(c *Controller, fc []Filter) {
	CurrentSessionEngine.Decode(c)
	sessionWasEmpty := c.Session.Empty()

	// Make session vars available in templates as {{.session.xyz}}
	c.ViewArgs["session"] = c.Session
	c.ViewArgs["_controller"] = c

	fc[0](c, fc[1:])

	// If session is not empty or if session was not empty then
	// pass it back to the session engine to be encoded
	if !c.Session.Empty() || !sessionWasEmpty {
		CurrentSessionEngine.Encode(c)
	}
}

redpajama_set_name: RedPajamaGithub


text:
require 'spec_helper'

describe ApiNotify::SynchronizerWorker do

  let(:dealer) do
    stub_request(:post, "https://one.example.com/api/v1/dealers").
      to_return(status: 201, body: '{ "other": "10" }')

    dealer = create(:dealer)
    described_class.drain
    dealer
  end

  it "pushes job into queue" do
    Sidekiq::Testing.fake!
    expect{ described_class.perform_async(dealer.api_notify_tasks.last.id) }.to change(described_class.jobs, :size).by(1)
  end

end


text:
@interface NSString (URLDecode)

- (NSString *)stringByDecodingURLFormat;

@end


text:
module Foreigner
  module ConnectionAdapters
    module FbAdapter
      include Foreigner::ConnectionAdapters::Sql2003

      def foreign_keys(table_name)
        fk_info = select_all %{
          SELECT
            detail_relation_constraints.rdb$constraint_name AS foreign_key_name,
            detail_index_segments.rdb$field_name            AS field_name,
            master_relation_constraints.rdb$relation_name   AS referenced_table,
            master_index_segments.rdb$field_name            AS referenced_field,
            rdb$ref_constraints.rdb$update_rule             AS update_rule,
            rdb$ref_constraints.rdb$delete_rule             AS delete_rule
          FROM
            rdb$relation_constraints detail_relation_constraints
            JOIN rdb$index_segments detail_index_segments ON
              detail_relation_constraints.rdb$index_name = detail_index_segments.rdb$index_name
            JOIN rdb$ref_constraints ON
              detail_relation_constraints.rdb$constraint_name = rdb$ref_constraints.rdb$constraint_name
            JOIN rdb$relation_constraints master_relation_constraints ON
              rdb$ref_constraints.rdb$const_name_uq = master_relation_constraints.rdb$constraint_name
            JOIN rdb$index_segments master_index_segments ON
              master_relation_constraints.rdb$index_name = master_index_segments.rdb$index_name
          WHERE
            detail_relation_constraints.rdb$constraint_type = 'FOREIGN KEY' AND
            detail_relation_constraints.rdb$relation_name = '#{ar_to_fb_case(table_name)}'
        }

        fk_info.map do |row|
          options = { :column      => row['field_name'].downcase.strip,
                      :name        => row['foreign_key_name'].downcase.strip,
                      :primary_key => row['referenced_field'].downcase.strip }

          options[:dependent] = case row['delete_rule'].downcase.strip
            when 'cascade'  then :delete
            when 'set null' then :nullify
            when 'restrict' then :restrict
          end

          ForeignKeyDefinition.new(table_name, row['referenced_table'].downcase.strip, options)
        end
      end

      def indexes(table_name, name = nil)
        old_indexes(table_name, name).select { |idx| not foreign_keys(table_name).any? { |fk| fk.options[:name] == idx.name } }
      end

      def dependency_sql(dependency)
        case dependency
          when :nullify then "ON DELETE SET NULL"
          when :delete  then "ON DELETE CASCADE"
          when :restrict then "ON DELETE NO ACTION"
          else ""
        end
      end
    end
  end
end

ActiveRecord::ConnectionAdapters::FbAdapter.class_eval do
  alias_method :old_indexes, :indexes
  include Foreigner::ConnectionAdapters::FbAdapter
end


text:
package net.laivuri.venueapi.service.common.util;

import java.net.URI;
import java.net.URISyntaxException;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.UriInfo;
import org.junit.Test;
import static org.mockito.Mockito.*;

/**
 *
 * @author Juhani Laitakari
 */
public class ResourceCreatedUtilUT {

    /**
     * Test of setLocationHeader method, of class ResourceCreatedUtil.
     *
     * @throws java.net.URISyntaxException
     */
    @Test
    public void testSetLocationHeader() throws URISyntaxException {

        final String headerName = "Location";
        final URI testAbsolutePath = new URI("http://example.org");
        final String testResourceId = "resource-123456";

        final String expectedHeader = testAbsolutePath + "/" + testResourceId;

        // mock UriInfo and stub it to return the absolute path
        UriInfo info = mock(UriInfo.class);
        when(info.getAbsolutePath()).thenReturn(testAbsolutePath);

        // mock HttpServletResponse
        HttpServletResponse resp = mock(HttpServletResponse.class);

        ResourceCreatedUtil.setLocationHeader(resp, info, testResourceId);

        // verify that it's called with the correct header
        verify(resp).addHeader(headerName, expectedHeader);
    }

}


text:
var // Expectation library:
	chai = require( 'chai' ),

	// Module to be tested:
	getMarshal = require( './../lib/json.js' );

// VARIABLES //

var expect = chai.expect,
	assert = chai.assert;

// TESTS //

describe( 'marshal-json', function tests() {
	'use strict';

	// SETUP //

	var marshal;

	beforeEach( function() {
		marshal = getMarshal( '\n' );
	});

	// TESTS //

	it( 'should export function', function test() {
		expect( getMarshal ).to.be.a( 'function' );
	});

	it( 'should return a function', function test() {
		expect( marshal ).to.be.a( 'function' );
	});

	it( 'should return an error if not provided an object or array', function test() {
		var values = [
				5,
				'5',
				true,
				NaN,
				null,
				undefined,
				function(){}
			];

		for ( var i = 0; i < values.length; i++ ) {
			badValue( values[i] );
		}

		function badValue( value ) {
			marshal( value, 'utf8', onError );
		}
		function onError( err ) {
			if ( err ) {
				assert.ok( true );
				return;
			}
			assert.notOk( true );
		}
	});

	it( 'should marshal streamed data as a buffer', function test() {
		marshal( {'foo':'bar'}, 'utf8', function onData( err, data ) {
			if ( err ) {
				assert.notOk( true );
				return;
			}
			assert.ok( data instanceof Buffer );
		});
	});

	it( 'should marshal streamed JSON data', function test() {
		var expected = {'foo':'bar'},
			actual;
		marshal( expected, 'utf8', function onData( err, data ) {
			if ( err ) {
				assert.notOk( true );
				return;
			}
			data = data.toString();
			assert.strictEqual( data.slice( data.length-1 ), '\n' );

			actual = JSON.parse( data.toString() );
			assert.deepEqual( actual, expected );
		});
	});

});


text:
<?php

return [
    'from'   => [
        'name'         => 'From',
        'label'        => 'Redirect From',
        'placeholder'  => 'foo/bar/{var}',
        'instructions' => 'Specify an exact path or pattern to redirect. For example foo/bar/{var} or foo/bar or http://{account}.old.com/{path}.',
        'warning'      => 'Do not include locale hints like en/foo/bar/{var}',
    ],
    'to'     => [
        'name'         => 'To',
        'label'        => 'Redirect To',
        'placeholder'  => 'bar/{var}',
        'instructions' => 'Specify an exact path, pattern replacement or URL to redirect to. For example bar/{var} or bar/baz or https://new.com/account/{account}/{path}.',
    ],
    'status' => [
        'name'         => 'Status',
        'instructions' => 'What kind of redirect is this?',
        'option'       => [
            '301' => '301 - Permanent Redirect',
            '302' => '302 - Temporary Redirect',
        ],
    ],
    'secure' => [
        'name'         => 'Secure',
        'label'        => 'Redirect to a secure URL?',
        'instructions' => 'Do you want to force a secure connection when redirecting?',
        'warning'      => 'This option is ignored if a protocol is included in the Redirect To value.',
    ],
];


text:
using namespace std;

vector<string> secret_handshake::commands(int value) {
    vector<string> answer;
    if (value & (1<<0)) answer.push_back("wink");
    if (value & (1<<1)) answer.push_back("double blink");
    if (value & (1<<2)) answer.push_back("close your eyes");
    if (value & (1<<3)) answer.push_back("jump");
    if (value & (1<<4)) reverse(answer.begin(), answer.end());
    return answer;
}


text:
package br.com.summa.sol.data;

import java.io.Serializable;
import java.util.Collection;

/**
 * A generic collection limited to size N. If more than N
 * elements are added, it will keep the greatest N elements only,
 * discarding the others.

 *
 * @param <E> The type of elements stored in this collection
 *
 * @author Einar Saukas
 */
public interface TopN<E> extends Collection<E>, Serializable {
}


text:
require 'time'
require 'linguist'
require 'thread'
require 'rugged'
require 'parallel'
require 'mongo'
require 'json'
require 'sequel'
require 'trollop'

require_relative 'java'
require_relative 'ruby'
require_relative 'scala'
require_relative 'javascript'
require_relative 'python'
require_relative 'go'

class PullReqDataExtraction

  REQ_LIMIT = 4990
  THREADS = 1

  attr_accessor :prs, :owner, :repo, :all_commits,
                :closed_by_commit, :close_reason, :token

  class << self
    def run(args = ARGV)
      attr_accessor :options, :args, :name, :config

      command = new()
      command.name = self.class.name
      command.args = args

      command.process_options
      command.validate

      command.config = YAML::load_file command.options[:config]

      command.go
    end
  end

  def process_options
    command = self
    @options = Trollop::options do
      banner <<-BANNER
Extract data for pull requests for a given repository

#{File.basename($0)} owner repo token

      BANNER
      opt :config, 'config.yaml file location', :short => 'c',
          :default => 'config.yaml'
    end
  end

  def validate
    if options[:config].nil?
      unless (file_exists?("config.yaml"))
        Trollop::die "No config file in default location (#{Dir.pwd}). You
                        need to specify the #{:config} parameter."
      end
    else
      Trollop::die "Cannot find file #{options[:config]}" \
          unless File.exists?(options[:config])
    end

    Trollop::die 'Three arguments required' if args[2].nil?
  end

  def db
    Thread.current[:sql_db] ||= Proc.new do
      Sequel.single_threaded = true
      Sequel.connect(self.config['sql']['url'], :encoding => 'utf8')
    end.call
    Thread.current[:sql_db]
  end

  def mongo
    Thread.current[:mongo_db] ||= Proc.new do
      uname  = self.config['mongo']['username']
      passwd = self.config['mongo']['password']
      host   = self.config['mongo']['host']
      port   = self.config['mongo']['port']
      db     = self.config['mongo']['db']

      constring = if uname.nil?
                    "mongodb://#{host}:#{port}/#{db}"
                  else
                    "mongodb://#{uname}:#{passwd}@#{host}:#{port}/#{db}"
                  end

      Mongo::Logger.logger.level = Logger::Severity::WARN
      Mongo::Client.new(constring)
    end.call
    Thread.current[:mongo_db]
  end

  def git
    Thread.current[:repo] ||= clone(ARGV[0], ARGV[1])
    Thread.current[:repo]
  end

  # Read a source file from the repo and strip its comments
  # The argument f is the result of Grit.lstree
  # Memoizes result per f
  def semaphore
    @semaphore ||= Mutex.new
    @semaphore
  end

  def stripped(f)
    @stripped ||= Hash.new
    unless @stripped.has_key? f
      semaphore.synchronize do
        unless @stripped.has_key? f
          @stripped[f] = strip_comments(git.read(f[:oid]).data)
        end
      end
    end
    @stripped[f]
  end

  def log(msg, level = 0)
    semaphore.synchronize do
      (0..level).each { STDERR.write ' ' }
      STDERR.puts msg
    end
  end

  # Main command code
  def go
    interrupted = false

    trap('INT') {
      log "#{File.basename($0)}(#{Process.pid}): Received SIGINT, exiting"
      interrupted = true
    }

    self.owner = ARGV[0]
    self.repo = ARGV[1]
    self.token = ARGV[2]

    user_entry = db[:users].first(:login => owner)

    if user_entry.nil?
      Trollop::die "Cannot find user #{owner}"
    end

    q = <<-QUERY
    SELECT p.id, p.language
    FROM projects p, users u
    WHERE u.id = p.owner_id
      AND u.login = ?
      AND p.name = ?
    QUERY
    repo_entry = db.fetch(q, owner, repo).first

    if repo_entry.nil?
      Trollop::die "Cannot find repository #{owner}/#{repo}"
    end

    language = repo_entry[:language]

    case language
      when /ruby/i then self.extend(RubyData)
      when /javascript/i then self.extend(JavascriptData)
      when /java/i then self.extend(JavaData)
      when /scala/i then self.extend(ScalaData)
      when /python/i then self.extend(PythonData)
      when /go/i then self.extend(GoData)
      else Trollop::die "Language #{lang} not supported"
    end

    # Update the repo
    clone(ARGV[0], ARGV[1], true)

    walker = Rugged::Walker.new(git)
    walker.sorting(Rugged::SORT_DATE)
    walker.push(git.head.target)
    self.all_commits = walker.map do |commit|
      commit.oid[0..10]
    end
    log "#{all_commits.size} commits to process"

    # Get commits that close issues/pull requests
    # Index them by issue/pullreq id, as a sha might close multiple issues
    # see: https://help.github.com/articles/closing-issues-via-commit-messages
    q = <<-QUERY
    select c.sha
    from commits c, project_commits pc
    where pc.project_id = ?
    and pc.commit_id = c.id
    QUERY

    fixre = /(?:fixe[sd]?|close[sd]?|resolve[sd]?)(?:[^\/]*?|and)#([0-9]+)/mi

    log 'Calculating PRs closed by commits'
    commits_in_prs = db.fetch(q, repo_entry[:id]).all
    self.closed_by_commit =
        Parallel.map(commits_in_prs, :in_threads => THREADS) do |x|
          sha = x[:sha]
          result = {}
          mongo['commits'].find({:sha => sha},
                                {:fields => {'commit.message' => 1, '_id' => 0}}).map do |x|
            comment = x['commit']['message']

            comment.match(fixre) do |m|
              (1..(m.size - 1)).map do |y|
                result[m[y].to_i] = sha
              end
            end
          end
          result
        end.select { |x| !x.empty? }.reduce({}) { |acc, x| acc.merge(x) }
    log "#{closed_by_commit.size} PRs closed by commits"

    self.prs = pull_reqs(repo_entry)

    log "Calculating PR close reasons"
    self.close_reason = prs.reduce({}) do |acc, pr|
      mw = merged_with(pr)
      log "PR #{pr[:github_id]}, #{mw}"

      acc[pr[:github_id]] = mw
      acc
    end
    log "Close reasons: #{close_reason.group_by { |_, v| v }.reduce({}) { |acc, x| acc.merge({x[0] => x[1].size}) }}"

    # Process pull request list
    do_pr = Proc.new do |pr|
      begin
        r = process_pull_request(pr, language)
        log r
        r
      rescue StandardError => e
        log "Error processing pull_request #{pr[:github_id]}: #{e.message}"
        log e.backtrace
        #raise e
      end
    end

    results = Parallel.map(prs, :in_threads => THREADS) do |pr|
      if interrupted
        raise Parallel::Kill
      end
      do_pr.call(pr)
    end

    unless results.nil?
      puts results.select { |x| !x.nil? }.first.keys.map{|x| x.to_s}.join(',')
      results.select { |x| !x.nil? }.sort{|a,b| b[:github_id]<=>a[:github_id]}.each{|x| puts x.values.join(',')}
    end
  end

  # Get a list of pull requests for the processed project
  def pull_reqs(project, github_id = -1)
    q = <<-QUERY
    select u.login as login, p.name as project_name, pr.id, pr.pullreq_id as github_id,
           a.created_at as created_at, b.created_at as closed_at, c.sha as base_commit,
           c1.sha as head_commit,
			     ( select created_at
             from pull_request_history prh1
             where prh1.pull_request_id = pr.id
             and prh1.action='merged' limit 1) as merged_at,
           timestampdiff(minute, a.created_at, b.created_at) as lifetime_minutes,
			     timestampdiff(minute, a.created_at, (select created_at
                                           from pull_request_history prh1
                                           where prh1.pull_request_id = pr.id and prh1.action='merged' limit 1)) as mergetime_minutes
    from pull_requests pr, projects p, users u,
         pull_request_history a, pull_request_history b, commits c, commits c1
    where p.id = pr.base_repo_id
	    and a.pull_request_id = pr.id
      and a.pull_request_id = b.pull_request_id
      and a.action='opened' and b.action='closed'
	    and a.created_at < b.created_at
      and p.owner_id = u.id
      and c1.id = pr.head_commit_id
      and c.id = pr.base_commit_id
      and p.id = ?
    QUERY

    if github_id != -1
      q += " and pr.pullreq_id = #{github_id} "
    end
    q += 'group by pr.id order by pr.pullreq_id desc;'

    db.fetch(q, project[:id]).all
  end

  # Process a single pull request
  def process_pull_request(pr, lang)

    # Statistics across pull request commits
    stats = pr_stats(pr)
    stats_open = pr_stats(pr, true)

    # Test diff stats
    pr_commits = commit_entries(pr[:id], true).sort{|a,b| a['commit']['author']['date'] <=> b['commit']['author']['date']}
    test_diff_open = test_diff_stats(pr[:base_commit], pr_commits.last[:sha])

    pr_commits = commit_entries(pr[:id], false).sort{|a,b| a['commit']['author']['date'] <=> b['commit']['author']['date']}
    test_diff = test_diff_stats(pr[:base_commit], pr_commits.last[:sha])

    # Count number of src/comment lines
    src = src_lines(pr[:base_commit])

    if src == 0 then raise StandardError.new("Bad src lines: 0, pr: #{pr[:github_id]}, id: #{pr[:id]}") end

    months_back = 3
    commits_incl_prs = commits_last_x_months(pr, false, months_back)
    commits_incl_prs = 1 if commits_incl_prs == 0 # To avoid divsions by zero below

    prev_pull_reqs = prev_pull_requests(pr,'opened')

    # Create line for a pull request
    {
        # General stuff
        :pull_req_id              => pr[:id],
        :project_name             => "#{pr[:login]}/#{pr[:project_name]}",
        :lang                     => lang,
        :github_id                => pr[:github_id],

        # PR characteristics
        :created_at               => Time.at(pr[:created_at]).to_i,
        :merged_at                => merge_ts(pr),
        :closed_at                => Time.at(pr[:closed_at]).to_i,
        :lifetime_minutes         => pr[:lifetime_minutes],
        :mergetime_minutes        => merge_time_minutes(pr),
        :merged_using             => close_reason[pr[:github_id]],
        :conflict                 => conflict?(pr),
        :forward_links            => forward_links?(pr),
        :intra_branch             => if intra_branch?(pr) == 1 then true else false end,
        :description_length       => description_length(pr),
        :num_commits              => num_commits(pr),
        :num_commits_open         => num_commits_at_open(pr),
        :num_pr_comments          => num_pr_comments(pr),
        :num_issue_comments       => num_issue_comments(pr),
        :num_commit_comments      => num_commit_comments(pr),
        :num_comments             => num_pr_comments(pr) + num_issue_comments(pr) + num_commit_comments(pr),
        :num_commit_comments_open => num_commit_comments(pr, true),
        :num_participants         => num_participants(pr),
        :files_added_open         => stats_open[:files_added],
        :files_deleted_open       => stats_open[:files_removed],
        :files_modified_open      => stats_open[:files_modified],
        :files_changed_open       => stats_open[:files_added] + stats[:files_modified] + stats[:files_removed],
        :src_files_open           => stats_open[:src_files],
        :doc_files_open           => stats_open[:doc_files],
        :other_files_open         => stats_open[:other_files],
        :files_added              => stats[:files_added],
        :files_deleted            => stats[:files_removed],
        :files_modified           => stats[:files_modified],
        :files_changed            => stats[:files_added] + stats[:files_modified] + stats[:files_removed],
        :src_files                => stats[:src_files],
        :doc_files                => stats[:doc_files],
        :other_files              => stats[:other_files],
        :src_churn_open           => stats_open[:lines_added] + stats_open[:lines_deleted],
        :test_churn_open          => stats_open[:test_lines_added] + stats_open[:test_lines_deleted],
        :tests_added_open         => test_diff_open[:tests_added],
        :tests_deleted_open       => test_diff_open[:tests_deleted],
        :tests_added              => test_diff[:tests_added],
        :tests_deleted            => test_diff[:tests_deleted],
        :src_churn                => stats[:lines_added] + stats[:lines_deleted],
        :test_churn               => stats[:test_lines_added] + stats[:test_lines_deleted],
        :new_entropy              => new_entropy(pr),
        :entropy_diff             => (new_entropy(pr) / project_entropy(pr)) * 100,
        :commits_on_files_touched => commits_on_files_touched(pr, months_back),
        :commits_to_hottest_file  => commits_to_hottest_file(pr, months_back),
        :hotness                  => hotness(pr, months_back),
        :at_mentions_description  => at_mentions_description(pr),
        :at_mentions_comments     => at_mentions_comments(pr),

        # Project characteristics
        :perc_external_contribs   => commits_last_x_months(pr, true, months_back).to_f / commits_incl_prs.to_f,
        :sloc                     => src,
        :test_lines               => test_lines(pr[:base_commit]),
        :test_cases               => num_test_cases(pr[:base_commit]),
        :asserts                  => num_assertions(pr[:base_commit]),
        :stars                    => stars(pr),
        :team_size                => team_size(pr, months_back),
        :workload                 => workload(pr),
        :ci                       => ci(pr),

        # Contributor characteristics
        :requester                => requester(pr),
        :closer                   => closer(pr),
        :merger                   => merger(pr),
        :prev_pullreqs            => prev_pull_reqs,
        :requester_succ_rate      => if prev_pull_reqs > 0 then prev_pull_requests(pr, 'merged').to_f / prev_pull_reqs.to_f else 0 end,
        :followers                => followers(pr),
        :main_team_member         => main_team_member?(pr, months_back),
        :social_connection        => social_connection?(pr),

        # Project/contributor interaction characteristics
        :prior_interaction_issue_events    => prior_interaction_issue_events(pr, months_back),
        :prior_interaction_issue_comments  => prior_interaction_issue_comments(pr, months_back),
        :prior_interaction_pr_events       => prior_interaction_pr_events(pr, months_back),
        :prior_interaction_pr_comments     => prior_interaction_pr_comments(pr, months_back),
        :prior_interaction_commits         => prior_interaction_commits(pr, months_back),
        :prior_interaction_commit_comments => prior_interaction_commit_comments(pr, months_back),
        :first_response                    => first_response(pr)
    }
  end

  def merge_ts(pr)

    if not pr[:merged_at].nil?
      Time.at(pr[:merged_at]).to_i
    elsif close_reason[pr[:github_id]] == :commits_in_master
      Time.at(pr[:closed_at]).to_i
    else
      nil
    end
  end

  def merge_time_minutes(pr)
    if not pr[:merged_at].nil?
      Time.at(pr[:mergetime_minutes]).to_i
    elsif close_reason[pr[:github_id]] == :commits_in_master
      pr[:lifetime_minutes].to_i
    else
      nil
    end
  end

  # Checks how a merge occured
  def merged_with(pr)
    #0. Merged with Github?
    q = <<-QUERY
	  select prh.id as merge_id
    from pull_request_history prh
	  where prh.action = 'merged'
      and prh.pull_request_id = ?
    QUERY
    r = db.fetch(q, pr[:id]).first
    unless r.nil?
      return :merge_button
    end

    #1. Commits from the pull request appear in the project's main branch
    q = <<-QUERY
	  select c.sha
    from pull_request_commits prc, commits c
	  where prc.commit_id = c.id
      and prc.pull_request_id = ?
    QUERY
    db.fetch(q, pr[:id]).each do |x|
      unless all_commits.select { |y| x[:sha].start_with? y }.empty?
        return :commits_in_master
      end
    end

    #2. The PR was closed by a commit (using the Fixes: convention).
    # Check whether the commit that closes the PR is in the project's
    # master branch
    sha = closed_by_commit[pr[:github_id]]
    unless sha.nil?
      unless all_commits.include? sha
        return :fixes_in_commit
      end
    end

    comments = mongo['issue_comments'].find(
        {'owner' => owner, 'repo' => repo, 'issue_id' => pr[:github_id].to_i},
        {:projection => {'body' => 1, 'created_at' => 1, '_id' => 0},
         :sort => {'created_at' => 1}}
    ).map { |x| x }

    comments.reverse.take(3).map { |x| x['body'] }.uniq.each do |last|
      # 3. Last comment contains a commit number
      last.scan(/([0-9a-f]{6,40})/m).each do |x|
        # Commit is identified as merged
        if last.match(/merg(?:ing|ed)/i) or
            last.match(/appl(?:ying|ied)/i) or
            last.match(/pull[?:ing|ed]/i) or
            last.match(/push[?:ing|ed]/i) or
            last.match(/integrat[?:ing|ed]/i)
          return :commit_sha_in_comments
        else
          # Commit appears in master branch
          unless all_commits.select { |y| x[0].start_with? y }.empty?
            return :commit_sha_in_comments
          end
        end
      end

      # 4. Merg[ing|ed] or appl[ing|ed] as last comment of pull request
      if last.match(/merg(?:ing|ed)/i) or
          last.match(/appl(?:ying|ed)/i) or
          last.match(/pull[?:ing|ed]/i) or
          last.match(/push[?:ing|ed]/i) or
          last.match(/integrat[?:ing|ed]/i)
        return :merged_in_comments
      end
    end

    :unknown
  end

  def conflict?(pr)
    issue_comments(pr[:owner], pr[:project_name], pr[:id]).reduce(false) do |acc, x|
      acc || (not x['body'].match(/conflict/i).nil?)
    end
  end

  def forward_links?(pr)
    owner = pr[:login]
    repo = pr[:project_name]
    pr_id = pr[:github_id]
    issue_comments(owner, repo, pr_id).reduce(false) do |acc, x|
      # Try to find pull_requests numbers referenced in each comment
      a = x['body'].scan(/\#([0-9]+)/m).reduce(false) do |acc1, m|
        if m[0].to_i > pr_id.to_i
          # See if it is a pull request (if not the number is an issue)
          q = <<-QUERY
            select *
            from pull_requests pr, projects p, users u
            where u.id = p.owner_id
              and pr.base_repo_id = p.id
              and u.login = ?
              and p.name = ?
              and pr.pullreq_id = ?
          QUERY
          acc1 || db.fetch(q, owner, repo, m[0]).all.size > 0
        else
          acc1
        end
      end
      acc || a
    end
  end

  def num_commits_at_open(pr)
    q = <<-QUERY
    select count(*) as commit_count
    from pull_requests pr, pull_request_commits prc, commits c, pull_request_history prh
    where pr.id = prc.pull_request_id
      and pr.id=?
      and prc.commit_id = c.id
      and prh.action = 'opened'
      and prh.pull_request_id = pr.id
      and c.created_at <= prh.created_at
    group by prc.pull_request_id
    QUERY
    begin
      db.fetch(q, pr[:id]).first[:commit_count]
    rescue
      0
    end
  end

  # Number of commits in pull request
  def num_commits(pr)
    q = <<-QUERY
    select count(*) as commit_count
    from pull_requests pr, pull_request_commits prc
    where pr.id = prc.pull_request_id
      and pr.id=?
    group by prc.pull_request_id
    QUERY
    begin
      db.fetch(q, pr[:id]).first[:commit_count]
    rescue
      0
    end
  end

  # Number of pull request code review comments in pull request
  def num_pr_comments(pr)
    q = <<-QUERY
    select count(*) as comment_count
    from pull_request_comments prc
    where prc.pull_request_id = ?
    and prc.created_at < (
      select max(created_at)
      from pull_request_history
      where action = 'closed' and pull_request_id = ?)
    QUERY
    db.fetch(q, pr[:id], pr[:id]).first[:comment_count]
  end

  # Number of pull request discussion comments
  def num_issue_comments(pr)
    q = <<-QUERY
    select count(*) as issue_comment_count
    from pull_requests pr, issue_comments ic, issues i
    where ic.issue_id=i.id
    and i.issue_id=pr.pullreq_id
    and pr.base_repo_id = i.repo_id
    and pr.id = ?
    and ic.created_at < (
      select max(created_at)
      from pull_request_history
      where action = 'closed' and pull_request_id = ?)
    QUERY
    db.fetch(q, pr[:id], pr[:id]).first[:issue_comment_count]
  end

  # Number of commit comments on commits composing the pull request
  def num_commit_comments(pr, at_open = false)
    if at_open
      q = <<-QUERY
      select count(*) as commit_comment_count
      from pull_request_commits prc, commit_comments cc,
           pull_request_history prh
      where prc.commit_id = cc.commit_id
        and prh.action = 'opened'
        and cc.created_at <= prh.created_at
        and prh.pull_request_id = prc.pull_request_id
        and prc.pull_request_id = ?
      QUERY
    else
      q = <<-QUERY
      select count(*) as commit_comment_count
      from pull_request_commits prc, commit_comments cc
      where prc.commit_id = cc.commit_id
        and prc.pull_request_id = ?
      QUERY
    end
    db.fetch(q, pr[:id]).first[:commit_comment_count]
  end

  def num_participants(pr)
    q = <<-QUERY
    select count(distinct(user_id)) as participants from
      (select user_id
       from pull_request_comments
       where pull_request_id = ?
       union
       select user_id
       from issue_comments ic, issues i
       where i.id = ic.issue_id and i.pull_request_id = ?) as num_participants
    QUERY
    db.fetch(q, pr[:id], pr[:id]).first[:participants]
  end

  # Number of followers of the person that created the pull request
  def followers(pr)
    q = <<-QUERY
    select count(f.follower_id) as num_followers
    from pull_requests pr, followers f, pull_request_history prh
    where prh.actor_id = f.user_id
      and prh.pull_request_id = pr.id
      and prh.action = 'opened'
      and f.created_at < prh.created_at
      and pr.id = ?
    QUERY
    db.fetch(q, pr[:id]).first[:num_followers]
  end

  # Number of project watchers/stargazers at the time the pull request was made
  def stars(pr)
    q = <<-QUERY
    select count(w.user_id) as num_watchers
    from watchers w, pull_requests pr, pull_request_history prh
    where prh.pull_request_id = pr.id
      and w.created_at < prh.created_at
      and w.repo_id = pr.base_repo_id
      and prh.action='opened'
      and pr.id = ?
    QUERY
    db.fetch(q, pr[:id]).first[:num_watchers]
  end

  # Person that first closed the pull request
  def closer(pr)
    q = <<-QUERY
    select u.login as login
    from pull_request_history prh, users u
    where prh.pull_request_id = ?
      and prh.actor_id = u.id
      and prh.action = 'closed'
    QUERY
    closer = db.fetch(q, pr[:id]).first

    if closer.nil?
      q = <<-QUERY
      select u.login as login
      from issues i, issue_events ie, users u
      where i.pull_request_id = ?
        and ie.issue_id = i.id
        and (ie.action = 'closed' or ie.action = 'merged')
        and u.id = ie.actor_id
      QUERY
      closer = db.fetch(q, pr[:id]).first
    end

    unless closer.nil?
      closer[:login]
    else
      nil
    end
  end

  # Person that first merged the pull request
  def merger(pr)
    q = <<-QUERY
    select u.login as login
    from issues i, issue_events ie, users u
    where i.pull_request_id = ?
      and ie.issue_id = i.id
      and ie.action = 'merged'
      and u.id = ie.actor_id
    QUERY
    merger = db.fetch(q, pr[:id]).first

    if merger.nil?
      # If the PR was merged, then it is safe to assume that the
      # closer is also the merger
      if not close_reason[pr[:github_id]].nil? and close_reason[pr[:github_id]] != :unknown
        closer(pr)
      else
        nil
      end
    else
      merger[:login]
    end
  end

  # Number of followers of the person that created the pull request
  def requester(pr)
    q = <<-QUERY
    select u.login as login
    from users u, pull_request_history prh
    where prh.actor_id = u.id
      and action = 'opened'
      and prh.pull_request_id = ?
    QUERY
    db.fetch(q, pr[:id]).first[:login]
  end

  # Number of previous pull requests for the pull requester
  def prev_pull_requests(pr, action)

    if action == 'merged'
      q = <<-QUERY
      select pr.pullreq_id, prh.pull_request_id as num_pull_reqs
      from pull_request_history prh, pull_requests pr
      where prh.action = 'opened'
        and prh.created_at < (select min(created_at) from pull_request_history prh1 where prh1.pull_request_id = ? and prh1.action = 'opened')
        and prh.actor_id = (select min(actor_id) from pull_request_history prh1 where prh1.pull_request_id = ? and prh1.action = 'opened')
        and prh.pull_request_id = pr.id
        and pr.base_repo_id = (select pr1.base_repo_id from pull_requests pr1 where pr1.id = ?);
      QUERY

      pull_reqs = db.fetch(q, pr[:id], pr[:id], pr[:id]).all
      pull_reqs.reduce(0) do |acc, pull_req|
        if not close_reason[pull_req[:pullreq_id]].nil? and close_reason[pull_req[:pullreq_id]][1] != :unknown
          acc += 1
        end
        acc
      end
    else
      q = <<-QUERY
      select pr.pullreq_id, prh.pull_request_id as num_pull_reqs
      from pull_request_history prh, pull_requests pr
      where prh.action = ?
        and prh.created_at < (select min(created_at) from pull_request_history prh1 where prh1.pull_request_id = ?)
        and prh.actor_id = (select min(actor_id) from pull_request_history prh1 where prh1.pull_request_id = ? and action = ?)
        and prh.pull_request_id = pr.id
        and pr.base_repo_id = (select pr1.base_repo_id from pull_requests pr1 where pr1.id = ?);
      QUERY
      db.fetch(q, action, pr[:id], pr[:id], action, pr[:id]).all.size
    end
  end

  # Do the contributor and the person that closed the PR follow
  # each other?
  # Defined in: Tsay, Jason, Laura Dabbish, and James Herbsleb.
  # "Influence of social and technical factors for evaluating contribution in GitHub."
  # Proceedings of the ICSE 2014
  def social_connection?(pr)
    q = <<-QUERY
    select *
    from followers
    where user_id = (
      select min(prh.actor_id)
      from pull_request_history prh
      where prh.pull_request_id = ?
        and prh.action = 'closed'
        )
    and follower_id = (
      select min(prh.actor_id)
      from pull_request_history prh
      where prh.pull_request_id = ?
        and prh.action = 'opened'
        )
    and created_at < (
      select min(created_at)
        from pull_request_history
        where pull_request_id = ?
        and action = 'opened'
    )
    QUERY
    db.fetch(q, pr[:id], pr[:id], pr[:id]).all.size > 0
  end

  # People that merged (not necessarily through pull requests) up to months_back
  # from the time the built PR was created.
  def merger_team(pr, months_back)
    recently_merged = prs.find_all do |b|
      close_reason[b[:github_id]][1] != :unknown and
          b[:created_at].to_i > (pr[:created_at].to_i - months_back * 30 * 24 * 3600)
    end.map do |b|
      b[:github_id]
    end

    q = <<-QUERY
    select u1.login as merger
    from users u, projects p, pull_requests pr, pull_request_history prh, users u1
    where prh.action = 'closed'
      and prh.actor_id = u1.id
      and prh.pull_request_id = pr.id
      and pr.base_repo_id = p.id
      and p.owner_id = u.id
      and u.login = ?
      and p.name = ?
      and pr.pullreq_id = ?
    QUERY

    recently_merged.map do |pr_num|
      a = db.fetch(q, pr[:login], pr[:project_name], pr_num).first
      if not a.nil? then a[:merger] else nil end
    end.select {|x| not x.nil?}.uniq

  end

  # Number of integrators active during x months prior to pull request
  # creation.
  def team_size(pr, months_back)
    (committer_team(pr, months_back) + merger_team(pr, months_back)).uniq.size
  end

  # The number of events before a particular pull request that the user has
  # participated in for this project.
  # The following features originate in:
  # Yu, Y., Wang, H., Filkov, V., Devanbu, P., & Vasilescu, B.
  # Wait For It: Determinants of Pull Request Evaluation Latency on GitHub.
  # MSR 2015
  def prior_interaction_issue_events(pr, months_back)
    q = <<-QUERY
      select count(distinct(i.id)) as num_issue_events
      from issue_events ie, pull_request_history prh, pull_requests pr, issues i
      where ie.actor_id = prh.actor_id
        and i.repo_id = pr.base_repo_id
        and i.id = ie.issue_id
        and prh.pull_request_id = pr.id
        and prh.action = 'opened'
        and ie.created_at > DATE_SUB(prh.created_at, INTERVAL #{months_back} MONTH)
        and ie.created_at < prh.created_at
        and prh.pull_request_id = ?
    QUERY
    db.fetch(q, pr[:id]).first[:num_issue_events]
  end

  def prior_interaction_issue_comments(pr, months_back)
    q = <<-QUERY
    select count(distinct(ic.comment_id)) as issue_comment_count
    from pull_request_history prh, pull_requests pr, issues i, issue_comments ic
    where ic.user_id = prh.actor_id
      and i.repo_id = pr.base_repo_id
      and i.id = ic.issue_id
      and prh.pull_request_id = pr.id
      and prh.action = 'opened'
      and ic.created_at > DATE_SUB(prh.created_at, INTERVAL #{months_back} MONTH)
      and ic.created_at < prh.created_at
      and prh.pull_request_id = ?;
    QUERY
    db.fetch(q, pr[:id]).first[:issue_comment_count]
  end

  def prior_interaction_pr_events(pr, months_back)
    q = <<-QUERY
    select count(distinct(prh1.id)) as count_pr
    from  pull_request_history prh1, pull_request_history prh, pull_requests pr1, pull_requests pr
    where prh1.actor_id = prh.actor_id
      and pr1.base_repo_id = pr.base_repo_id
      and pr1.id = prh1.pull_request_id
      and pr.id = prh.pull_request_id
      and prh.action = 'opened'
      and prh1.created_at > DATE_SUB(prh.created_at, INTERVAL #{months_back} MONTH)
      and prh1.created_at < prh.created_at
      and prh.pull_request_id = ?
    QUERY
    db.fetch(q, pr[:id]).first[:count_pr]
  end

  def prior_interaction_pr_comments(pr, months_back)
    q = <<-QUERY
    select count(prc.comment_id) as count_pr_comments
    from pull_request_history prh, pull_requests pr1, pull_requests pr, pull_request_comments prc
    where prh.actor_id = prc.user_id
      and pr1.base_repo_id = pr.base_repo_id
      and pr1.id = prh.pull_request_id
      and pr.id = prc.pull_request_id
      and prh.action = 'opened'
      and prc.created_at > DATE_SUB(prh.created_at, INTERVAL #{months_back} MONTH)
      and prc.created_at < prh.created_at
      and prh.pull_request_id = ?
    QUERY
    db.fetch(q, pr[:id]).first[:count_pr_comments]
  end

  def prior_interaction_commits(pr, months_back)
    q = <<-QUERY
    select count(distinct(c.id)) as count_commits
    from pull_request_history prh, pull_requests pr, commits c, project_commits pc
    where (c.author_id = prh.actor_id or c.committer_id = prh.actor_id)
      and pc.project_id = pr.base_repo_id
      and c.id = pc.commit_id
      and prh.pull_request_id = pr.id
      and prh.action = 'opened'
      and c.created_at > DATE_SUB(prh.created_at, INTERVAL #{months_back} MONTH)
      and c.created_at < prh.created_at
      and prh.pull_request_id = ?;
    QUERY
    db.fetch(q, pr[:id]).first[:count_commits]
  end

  def prior_interaction_commit_comments(pr, months_back)
    q = <<-QUERY
    select count(distinct(cc.id)) as count_commits
    from pull_request_history prh, pull_requests pr, commits c, project_commits pc, commit_comments cc
    where cc.commit_id = c.id
      and cc.user_id = prh.actor_id
      and pc.project_id = pr.base_repo_id
      and c.id = pc.commit_id
      and prh.pull_request_id = pr.id
      and prh.action = 'opened'
      and cc.created_at > DATE_SUB(prh.created_at, INTERVAL #{months_back} MONTH)
      and cc.created_at < prh.created_at
      and prh.pull_request_id = ?;

    QUERY
    db.fetch(q, pr[:id]).first[:count_commits]
  end

  # Median number of commits to files touched by the pull request relative to
  # all (including those coming from PRs) project commits during the last three months
  def hotness(pr, months_back)
    commits_per_file = commits_on_pr_files(pr, months_back).map{|x| x[1].size}.sort
    med = commits_per_file[commits_per_file.size/2]
    med = 0 if med.nil?
    all_commits = commits_last_x_months(pr, false, months_back)
    all_commits = 1 if all_commits == 0
    med / all_commits.to_f
  end

  # People that committed (not through pull requests) up to months_back
  # from the time the PR was created.
  def committer_team(pr, months_back)
    q = <<-QUERY
    select distinct(u.login) as committer
    from commits c, project_commits pc, pull_requests pr, users u, pull_request_history prh
    where pr.base_repo_id = pc.project_id
      and not exists (select * from pull_request_commits where commit_id = c.id)
      and pc.commit_id = c.id
      and pr.id = ?
      and u.id = c.committer_id
      and u.fake is false
      and prh.pull_request_id = pr.id
      and prh.action = 'opened'
      and c.created_at > DATE_SUB(prh.created_at, INTERVAL #{months_back} MONTH)
      and c.created_at < prh.created_at;
    QUERY
    db.fetch(q, pr[:id]).all.map{|x| x[:committer]}
  end

  # Time interval in minutes from pull request creation to first response
  # by reviewers
  def first_response(pr)
    q = <<-QUERY
      select min(created) as first_resp from (
        select min(prc.created_at) as created
        from pull_request_comments prc, users u
        where prc.pull_request_id = ?
          and u.id = prc.user_id
          and u.login not in ('travis-ci', 'cloudbees')
          and prc.created_at < (
            select max(created_at)
            from pull_request_history
            where action = 'closed' and pull_request_id = ?)
        union
        select min(ic.created_at) as created
        from issues i, issue_comments ic, users u
        where i.pull_request_id = ?
          and i.id = ic.issue_id
          and u.id = ic.user_id
          and u.login not in ('travis-ci', 'cloudbees')
          and ic.created_at < (
            select max(created_at)
            from pull_request_history
            where action = 'closed' and pull_request_id = ?)
      ) as a;
    QUERY
    resp = db.fetch(q, pr[:id], pr[:id], pr[:id], pr[:id]).first[:first_resp]
    unless resp.nil?
      (resp - pr[:created_at]).to_i / 60
    else
      -1
    end
  end

  # Number of commits to the hottest file between the time the PR was created
  # and `months_back`
  def commits_to_hottest_file(pr, months_back)
    a = commits_on_pr_files(pr, months_back).map{|x| x}.sort_by { |x| x[1].size}
    unless a.empty?
      a.last[1].size
    else
      0
    end
  end

  CIBADGES = {
      /https:\/\/.*.cloudbees.com\/buildStatus\/icon/    => :cloudbees,
      /https:\/\/circleci.com\/gh\/.*\.(png|svg)/        => :circleci,
      /https:\/\/travis-ci.org\/.*\.(svg|png)/           => :travis,
      /https:\/\/app.wercker.com\/status\/.*\/m/         => :wrecker,
      /https:\/\/api.shippable.com\/projects\/.*\/badge/ => :shippable,
      /https:\/\/codeship.com\/projects\/.*\/status/     => :codeship,
      /https:\/\/semaphoreapp.com\/vast/                 => :semaphoreapp,
      /https:\/\/snap-ci.com\/.*\/branch/                => :snapci
  }

  CICONFIGS = {
      /.travis.y[a]?ml/   => :travis,
      /circle.y[a]?ml/    => :circleci,
      /shippable.y[a]?ml/ => :shippable,
      /wercker.y[a]?ml/   => :wercker
  }

  def ci(pr)
    # Check whether a CI configuration file exists in the root directory
    root_files = files_at_commit(pr[:base_commit], lambda{|f| f[:path].count('/') == 1})
    root_files.each do |f|
      CICONFIGS.keys.each do |ci|
        return CICONFIGS[ci] unless f[:path].match(ci).nil?
      end
    end

    # Check whether a README file contains a CI badge
    readmes = root_files.find{|f| f[:path].match(/\/README/)}
    return :unknown if readmes.nil? or readmes.empty?
    return :unknown if readmes[0].nil?

    readme = git.read(readmes[0][:oid]).data
    CIBADGES.keys.each do |badge|
      if readme.match(badge)
        return CIBADGES[badge]
      end
    end

    return :unknown
  end

  # Total number of words in the pull request title and description
  def description_length(pr)
    pull_req = pull_req_entry(pr)
    title = unless pull_req['title'].nil? then pull_req['title'] else ' ' end
    body = unless pull_req['body'].nil? then pull_req['body'] else ' ' end
    (title + ' ' + body).gsub(/[\n\r]\s+/, ' ').split(/\s+/).size
  end

  # Total number of pull requests still open in each project at pull
  # request creation time.
  def workload(pr)
    q = <<-QUERY
    select count(distinct(prh.pull_request_id)) as num_open
    from pull_request_history prh, pull_requests pr, pull_request_history prh3
    where prh.created_at <  prh3.created_at
    and prh.action = 'opened'
    and pr.id = prh.pull_request_id
    and prh3.pull_request_id = ?
    and (exists (select * from pull_request_history prh1
                where prh1.action = 'closed'
          and prh1.pull_request_id = prh.pull_request_id
          and prh1.created_at > prh3.created_at)
      or not exists (select * from pull_request_history prh1
               where prh1.action = 'closed'
               and prh1.pull_request_id = prh.pull_request_id)
    )
    and pr.base_repo_id = (select pr3.base_repo_id from pull_requests pr3 where pr3.id = ?)
    QUERY
    db.fetch(q, pr[:id], pr[:id]).first[:num_open]
  end

  # Check if the pull request is intra_branch
  def intra_branch?(pr)
    q = <<-QUERY
    select IF(base_repo_id = head_repo_id, true, false) as intra_branch
    from pull_requests where id = ?
    QUERY
    db.fetch(q, pr[:id]).first[:intra_branch]
  end

  # Check if the requester is part of the project's main team
  def main_team_member?(pr, months_back)
    (committer_team(pr, months_back) + merger_team(pr, months_back)).uniq.include? requester(pr)
  end

  # Various statistics for the pull request. Returned as Hash with the following
  # keys: :lines_added, :lines_deleted, :files_added, :files_removed,
  # :files_modified, :files_touched, :src_files, :doc_files, :other_files.
  def pr_stats(pr, at_open = false)
    pr_id = pr[:id]
    raw_commits = commit_entries(pr_id, at_open)
    result = Hash.new(0)

    def file_count(commits, status)
      commits.map do |c|
        unless c['files'].nil?
          c['files'].reduce(Array.new) do |acc, y|
            if y['status'] == status then acc << y['filename'] else acc end
          end
        else
          []
        end
      end.flatten.uniq.size
    end

    def files_touched(commits)
      commits.map do |c|
        unless c['files'].nil?
          c['files'].map do |y|
            y['filename']
          end
        else
          []
        end
      end.flatten.uniq.size
    end

    def file_type(f)
      lang = Linguist::Language.find_by_filename(f)
      if lang.empty? then :data else lang[0].type end
    end

    def file_type_count(commits, type)
      commits.map do |c|
        unless c['files'].nil?
          c['files'].reduce(Array.new) do |acc, y|
            if file_type(y['filename']) == type then acc << y['filename'] else acc end
          end
        else
          []
        end
      end.flatten.uniq.size
    end

    def lines(commit, type, action)
      return 0 if commit['files'].nil?
      commit['files'].select do |x|
        next unless file_type(x['filename']) == :programming

        case type
          when :test
            true if test_file_filter.call(x['filename'])
          when :src
            true unless test_file_filter.call(x['filename'])
          else
            false
        end
      end.reduce(0) do |acc, y|
        diff_start = case action
                       when :added
                         "+"
                       when :deleted
                         "-"
                     end

        acc += unless y['patch'].nil?
                 y['patch'].lines.select{|x| x.start_with?(diff_start)}.size
               else
                 0
               end
        acc
      end
    end

    raw_commits.each{ |x|
      next if x.nil?
      result[:lines_added] += lines(x, :src, :added)
      result[:lines_deleted] += lines(x, :src, :deleted)
      result[:test_lines_added] += lines(x, :test, :added)
      result[:test_lines_deleted] += lines(x, :test, :deleted)
    }

    result[:files_added] += file_count(raw_commits, "added")
    result[:files_removed] += file_count(raw_commits, "removed")
    result[:files_modified] += file_count(raw_commits, "modified")
    result[:files_touched] += files_touched(raw_commits)

    result[:src_files] += file_type_count(raw_commits, :programming)
    result[:doc_files] += file_type_count(raw_commits, :markup)
    result[:other_files] += file_type_count(raw_commits, :data)

    result
  end

  def test_diff_stats(from_sha, to_sha)

    from = git.lookup(from_sha)
    to = git.lookup(to_sha)

    diff = to.diff(from)

    added = deleted = 0
    state = :none
    diff.patch.lines.each do |line|
      if line.start_with? '---'
        file_path = line.strip.split(/---/)[1]
        next if file_path.nil?

        file_path = file_path[2..-1]
        next if file_path.nil?

        if test_file_filter.call(file_path)
          state = :in_test
        end
      end

      if line.start_with? '- ' and state == :in_test
        if test_case_filter.call(line)
          deleted += 1
        end
      end

      if line.start_with? '+ ' and state == :in_test
        if test_case_filter.call(line)
          added += 1
        end
      end

      if line.start_with? 'diff --'
        state = :none
      end
    end

    {:tests_added => added, :tests_deleted => deleted}
  end

  # Return a hash of file names and commits on those files in the
  # period between pull request open and months_back. The returned
  # results do not include the commits coming from the PR.
  def commits_on_pr_files(pr, months_back)

    oldest = Time.at(Time.at(pr[:created_at]).to_i - 3600 * 24 * 30 * months_back)
    pr_against = pull_req_entry(pr)['base']['sha']
    commits = commit_entries(pr[:id], at_open = true)

    commits_per_file = commits.flat_map { |c|
      unless c['files'].nil?
        c['files'].map { |f|
          [c['sha'], f['filename']]
        }
      else
        []
      end
    }.select{|x| x.size > 1}.group_by {|c|
      c[1]
    }

    commits_per_file.keys.reduce({}) do |acc, filename|
      commits_in_pr = commits_per_file[filename].map{|x| x[0]}

      walker = Rugged::Walker.new(git)
      walker.sorting(Rugged::SORT_DATE)
      walker.push(pr_against)

      commit_list = walker.take_while do |c|
        c.time > oldest
      end.reduce([]) do |acc1, c|
        if c.diff(paths: [filename.to_s]).size > 0 and
            not commits_in_pr.include? c.oid
          acc1 << c.oid
        end
        acc1
      end
      acc.merge({filename => commit_list})
    end
  end

  # Number of unique commits on the files changed by the pull request
  # between the time the PR was created and `months_back`
  # excluding those created by the PR
  def commits_on_files_touched(pr, months_back)
    commits_on_pr_files(pr, months_back).reduce([]) do |acc, commit_list|
      acc + commit_list[1]
    end.flatten.uniq.size
  end

  # Total number of commits on the project in the period up to `months` before
  # the pull request was opened. `exclude_pull_req` controls whether commits
  # from pull requests should be accounted for.
  def commits_last_x_months(pr, exclude_pull_req, months_back)
    q = <<-QUERY
    select count(c.id) as num_commits
    from projects p, commits c, project_commits pc, pull_requests pr,
         pull_request_history prh
    where p.id = pc.project_id
      and pc.commit_id = c.id
      and p.id = pr.base_repo_id
      and prh.pull_request_id = pr.id
      and prh.action = 'opened'
      and c.created_at < prh.created_at
      and c.created_at > DATE_SUB(prh.created_at, INTERVAL #{months_back} MONTH)
      and pr.id=?
    QUERY

    if exclude_pull_req
      q << ' and not exists (select * from pull_request_commits prc1 where prc1.commit_id = c.id)'
    end

    db.fetch(q, pr[:id]).first[:num_commits]
  end

  # Total entropy introduced by PR
  def new_entropy(pr)
    files = commit_entries(pr[:id], at_open = true).flat_map{|x| x['files']}

    entropy_diffs = files.\
      select{ |f| ['modified', 'added'].include? f['status']}.\
      map{|x| unless x['patch'].nil? then entropy(x['patch'].gsub(/@@.*@@/,'')) else 0 end}

    # A2 Calc entropy for new versions of existing files
    del_entropies = files.\
      select{|f| f['status'] == 'deleted'}.\
      map{|x| entropy(x['patch'].gsub(/@@.*@@/,''))}

    (entropy_diffs - del_entropies).reduce(0){|acc, x| acc + x}
  end

  def project_entropy(pr)
    lslr(git.lookup(pr[:base_commit]).tree).\
      select{|f| f[:type] == :blob}.\
      map {|f| entropy(git.read(f[:oid]).data)}.\
      reduce(0){|acc, x| acc + x}
  end

  # Num of @uname mentions in the description
  # Modelling the results of: An Exploratory Study of @-mention in GitHub's Pull-requests
  # DOI: 10.1109/APSEC.2014.58
  def at_mentions_description(pr)
    pull_req = pull_req_entry(pr)
    unless pull_req['body'].nil?
      pull_req['body'].\
        gsub(/`.*?`/, '').\
        gsub(/[\w]*@[\w]+\.[\w]+/, '').\
        scan(/(@[a-zA-Z0-9]+)/).size
    else
      0
    end
  end

  # Num of @uname mentions in comments
  def at_mentions_comments(pr)
    issue_comments(pr[:login], pr[:project_name], pr[:github_id]).map do |ic|
      # Remove stuff between backticks (they may be code)
      # e.g. see comments in https://github.com/ReactiveX/RxScala/pull/166
      unless ic['body'].nil?
        ic['body'].\
            gsub(/`.*?`/, '').\
            gsub(/[\w]*@[\w]+\.[\w]+/, '')
      else
        0
      end
    end.map do |ic|
      ic.scan(/(@[a-zA-Z0-9]+)/).size
    end.reduce(0) do |acc, x|
      acc + x
    end
  end

  private

  def entropy(s)
    counts = Hash.new(0.0)
    s.each_char { |c| counts[c] += 1 }
    leng = s.length

    counts.values.reduce(0) do |entropy, count|
      freq = count / leng
      entropy - freq * Math.log2(freq)
    end
  end

  def pull_req_entry(pr)
    mongo['pull_requests'].find({:owner => pr[:login],
                                 :repo => pr[:project_name],
                                 :number => pr[:github_id]}).limit(1).first
  end

  # JSON objects for the commits included in the pull request
  def commit_entries(pr_id, at_open = false)
    if at_open
      q = <<-QUERY
        select c.sha as sha
        from pull_requests pr, pull_request_commits prc,
             commits c, pull_request_history prh
        where pr.id = prc.pull_request_id
        and prc.commit_id = c.id
        and prh.action = 'opened'
        and prh.pull_request_id = pr.id
        and c.created_at <= prh.created_at
        and pr.id = ?
      QUERY
    else
      q = <<-QUERY
        select c.sha as sha
        from pull_requests pr, pull_request_commits prc, commits c
        where pr.id = prc.pull_request_id
        and prc.commit_id = c.id
        and pr.id = ?
      QUERY
    end

    commits = db.fetch(q, pr_id).all

    commits.reduce([]){ |acc, x|
      a = mongo['commits'].find({:sha => x[:sha]}).limit(1).first

      if a.nil?
        a = github_commit(owner, repo, x)
      end

      acc << a unless a.nil?
      acc
    }.select{|c| c['parents'].size <= 1}
  end

  # Returns all comments for the issue sorted by creation date ascending
  def issue_comments(owner, repo, pr_id)
    mongo['issue_comments'].find(
        {'owner' => owner, 'repo' => repo, 'issue_id' => pr_id.to_i},
        {:fields => {'body' => 1, 'created_at' => 1, '_id' => 0},
         :sort   => {'created_at' => 1}}
    ).map { |x| x }

  end

  # Recursively get information from all files given a rugged Git tree
  def lslr(tree, path = '')
    all_files = []
    for f in tree.map { |x| x }
      f[:path] = path + '/' + f[:name]
      if f[:type] == :tree
        begin
          all_files << lslr(git.lookup(f[:oid]), f[:path])
        rescue StandardError => e
          log e
          all_files
        end
      else
        all_files << f
      end
    end
    all_files.flatten
  end

  # List of files in a project checkout. Filter is an optional binary function
  # that takes a file entry and decides whether to include it in the result.
  def files_at_commit(sha, filter = lambda { true })

    begin
      files = lslr(git.lookup(sha).tree)
      if files.size <= 0
        log "No files for commit #{sha}"
      end
      files.select { |x| filter.call(x) }
    rescue StandardError => e
      log "Cannot find commit #{sha} in base repo"
      []
    end
  end

  def count_lines(files, include_filter = lambda{|x| true})
    a = files.map do |f|
      stripped(f).lines.select do |x|
        not x.strip.empty?
      end.select do |x|
        include_filter.call(x)
      end.size
    end
    a.reduce(0){|acc,x| acc + x}
  end

  # Clone or update, if already cloned, a git repository
  def clone(user, repo, update = false)

    def spawn(cmd)
      proc = IO.popen(cmd, 'r')

      proc_out = Thread.new {
        while !proc.eof
          log "GIT: #{proc.gets}"
        end
      }

      proc_out.join
    end

    checkout_dir = File.join('repos', user, repo)

    begin
      repo = Rugged::Repository.new(checkout_dir)
      if update
        spawn("cd #{checkout_dir} && git pull")
      end
      repo
    rescue
      spawn("git clone git://github.com/#{user}/#{repo}.git #{checkout_dir}")
      Rugged::Repository.new(checkout_dir)
    end
  end

  # Load a commit from Github. Will return an empty hash if the commit does not exist.
  def github_commit(owner, repo, sha)
    parent_dir = File.join('commits', "#{owner}@#{repo}")
    commit_json = File.join(parent_dir, "#{sha}.json")
    FileUtils::mkdir_p(parent_dir)

    r = nil
    if File.exists? commit_json
      r = begin
        JSON.parse File.open(commit_json).read
      rescue
        # This means that the retrieval operation resulted in no commit being retrieved
        {}
      end
      return r
    end

    url = "https://api.github.com/repos/#{owner}/#{repo}/commits/#{sha}"
    log("Requesting #{url} (#{@remaining} remaining)")

    contents = nil
    begin
      r = open(url, 'User-Agent' => 'ghtorrent', 'Authorization' => "token #{token}")
      @remaining = r.meta['x-ratelimit-remaining'].to_i
      @reset = r.meta['x-ratelimit-reset'].to_i
      contents = r.read
      JSON.parse contents
    rescue OpenURI::HTTPError => e
      @remaining = e.io.meta['x-ratelimit-remaining'].to_i
      @reset = e.io.meta['x-ratelimit-reset'].to_i
      log "Cannot get #{url}. Error #{e.io.status[0].to_i}"
      {}
    rescue StandardError => e
      log "Cannot get #{url}. General error: #{e.message}"
      {}
    ensure
      File.open(commit_json, 'w') do |f|
        f.write contents unless r.nil?
        f.write '' if r.nil?
      end

      if 5000 - @remaining >= REQ_LIMIT
        to_sleep = @reset - Time.now.to_i + 2
        log "Request limit reached, sleeping for #{to_sleep} secs"
        sleep(to_sleep)
      end
    end
  end

  def src_files(sha)
    files_at_commit(sha, src_file_filter)
  end

  def src_lines(sha)
    count_lines(src_files(sha))
  end

  def test_files(sha)
    files_at_commit(sha, test_file_filter)
  end

  def test_lines(sha)
    count_lines(test_files(sha))
  end

  def num_test_cases(sha)
    count_lines(test_files(sha), test_case_filter)
  end

  def num_assertions(sha)
    count_lines(test_files(sha), assertion_filter)
  end

  # Return a f: filename -> Boolean, that determines whether a
  # filename is a test file
  def test_file_filter
    raise Exception.new("Unimplemented")
  end

  # Return a f: filename -> Boolean, that determines whether a
  # filename is a src file
  def src_file_filter
    raise Exception.new("Unimplemented")
  end

  # Return a f: buff -> Boolean, that determines whether a
  # line represents a test case declaration
  def test_case_filter
    raise Exception.new("Unimplemented")
  end

  # Return a f: buff -> Boolean, that determines whether a
  # line represents an assertion
  def assertion_filter
    raise Exception.new("Unimplemented")
  end

  def strip_comments(buff)
    raise Exception.new("Unimplemented")
  end

end

PullReqDataExtraction.run
#vim: set filetype=ruby expandtab tabstop=2 shiftwidth=2 autoindent smartindent:


text:
.cbg-RasterPanel {
	border: 1px solid black;
    cursor: pointer;
	position: relative;
}

.cbg-RasterPanel-panel {
	position: absolute;
	top: 0px;
	right: 0px;
	bottom: 0px;
	left: 0px;
}

.cbg-RasterPixel {
	position: absolute;

	background-color: wheat;
	border-right: 1px solid #ccc;
	border-bottom: 1px solid #ccc;
}

.cbg-RasterPixel-engaged {
	background-color: red;
}


text:
<!DOCTYPE html>

  <link href="http://gmpg.org/xfn/11" rel="profile">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta http-equiv="content-type" content="text/html; charset=utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">

  <title>

      Pork Carnitas · Thinking .·. Computationally

  </title>

  <link rel="stylesheet" href="/public/css/poole.css">
  <link rel="stylesheet" href="/public/css/syntax.css">
  <link rel="stylesheet" href="/public/css/lanyon.css">
  <link rel="stylesheet" href="/public/font-awesome/css/font-awesome.min.css">
  <link href='https://fonts.googleapis.com/css?family=Pacifico|Philosopher' rel='stylesheet' type='text/css'>

  <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/public/apple-touch-icon-precomposed.png">
  <link rel="shortcut icon" href="/public/favicon.ico">

  <link rel="alternate" type="application/rss+xml" title="RSS" href="/atom.xml">

<input type="checkbox" class="sidebar-checkbox" id="sidebar-checkbox">

a blog for my thoughts, musings, and ramblings; updated infrequently but passionately; may not be suitable for those unwilling to be mentally challenged

    Home

          About

      Archive
      Culinary Adventures
      Recipe Archive

      © 2018. All rights reserved.

            Thinking .·. Computationally
            thoughts, musings, and ramblings

Pork Carnitas

  12 Dec 2016

pork

mexican

  Active: 30 minutesTotal: 2 - 4 hoursMakes: 5 - 6 lb. carnitas

A great start to wonderful Mexican cuisine.

Original source: Allrecipies

Ingredients

6 - 8 lb. pork shoulder (Boston butt roast), cut into 2-3 in. pieces

2 onions, chopped

2 cloves garlic, crushed

2 tbsp. olive oil

2 32 oz. containers chicken broth

1/4 cup lime juice

seasonings:

salt & pepper

cumin

chili powder

oregano

thyme

dried yellow mustard

Equipment

large skillet

dutch oven

cutting board & knife

Setup

none

Process

Heat oil in skillet and brown all sides of each piece of meat.

Combine all ingredients except broth in dutch oven. I usually do 1 tbsp. chili powder and cumin to 1 tsp. other seasonings

Add broth until ingredients are mostly covered.

Heat to boiling, then simmer for up to 3 hours.

Remove from pan and place on cutting board. Shred pork between two forks.

Optional: Can bake in 400°F oven for 20-30 minutes until browned further.

Notes

2016-12-12 - Made really delicious burritos and nachos for Monday Night. I saved the broth to use as a chili base later this winter


text:
template <> class Packet <PACKET_SERVER_MESSAGE>
{
    public:
        static void onReceive(const ENetEvent &event);
};

#endif


text:
import { Pipe, PipeTransform } from '@angular/core';
import {Player} from "../models/player.model";

@Pipe({name: 'orderByName'})
export class OrderByNamePipe implements PipeTransform {
   transform(players: Player[]): Player[] {
      players.sort(
         (p1, p2) => {
            if(p1.name.toLowerCase() < p2.name.toLowerCase()){
               return -1;
            }else if(p1.name.toLowerCase() > p2.name.toLowerCase()){
               return 1;
            }else{
               return 0
            }
         }
      )
      return players;
   }
}


text:
.. _example_json-importer:

Importing from JSON
===================

In this example, we will use the same schema defined in the
:ref:`previous example <example_json-exporter>` to build an importer that
re-constructs a register model from a JSON file.

We will use Python's built-in `JSON library <https://docs.python.org/3/library/json.html>`_
to read the input file, as well as the :class:`~systemrdl.importer.RDLImporter`
helper class to help construct RDL components.

The full example code can be found in the ``systemrdl-compiler`` repository at:
``examples/import_json.py``

Walkthrough
-----------

Start by creating a JSON importer class extended from :class:`~systemrdl.importer.RDLImporter`.

.. literalinclude:: ../../examples/import_json.py
    :lines: 5, 8-9

Just like the :ref:`JSON exporter example <example_json-exporter>`, we will
define a function that converts each component type.
This time, Python's JSON library will read the input and present each component
as a dictionary of keys:value pairs that represents its description.

Per-component conversion functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

When developing your importer, it is important to always validate inputs, and
create human-friendly error messages or warnings whenever appropriate.
Prior to decoding any component, we start by checking the validity of the JSON
``dict`` object. Starting with the function to decode fields:

.. literalinclude:: ../../examples/import_json.py
    :lines: 33-44

Next, we use some methods provided by the :class:`~systemrdl.importer.RDLImporter`
to:

* Create an anonymous definition of a field component
* Assign some properties
* Instantiate it

Note that the field instance is not fully instantiated yet. It still needs to be
attached to a parent component. This will be done later outside of this function.

.. literalinclude:: ../../examples/import_json.py
    :lines: 46-65

Next is the function that constructs the enclosing register component. The reg
component is constructed in nearly the same way as before, except that here
we iterate over all the child fields and attach them to the parent reg definition.

.. literalinclude:: ../../examples/import_json.py
    :lines: 68-99
    :emphasize-lines: 13,22-24

Decoding a regfile is nearly the same. Here, children can be multiple different
types, so we call the appropriate decode function based on the 'type' key:

.. literalinclude:: ../../examples/import_json.py
    :lines: 102-130
    :emphasize-lines: 11-16,22

The addrmap decode function is nearly identical, however we need the
option to produce a named definition instead of an anonymous component
instantiation. This is because we want to be able to register the top-level
addrmap in the root type namespace. The type namespace can only contain
component definitions, not instances.

.. literalinclude:: ../../examples/import_json.py
    :lines: 133-179
    :emphasize-lines: 1,10-13,37-39

Loading JSON and decoding
^^^^^^^^^^^^^^^^^^^^^^^^^

Now that we have our decoding utility functions completed, we are ready to
implement the importer's :meth:`~systemrdl.importer.RDLImporter.import_file()`
entry function.

First, call the superclass. This ensures that per-component error message context
works properly later.

.. literalinclude:: ../../examples/import_json.py
    :lines: 11-12

Next, load the JSON file. For this importer, we'll be assuming that the top-level
component is always an addrmap. Any time an assumption about the input is made,
you should validate it to ensure it is true:

.. literalinclude:: ../../examples/import_json.py
    :lines: 14-23

Finally, call our decode function and register the resulting top-level component
definition with the root namespace:

.. literalinclude:: ../../examples/import_json.py
    :lines: 25-30

Using our new importer
----------------------

Importing data into the SystemRDL compiler is similar to compiling a file
normally. You can even intermingle compiling RDL files with importing custom
formats.

* Create a :class:`~systemrdl.RDLCompiler` instance
* Bind any custom importers
* Compile RDL inputs and/or import custom file formats
* Run elaboration

Here we detect the file type based on its extension:

.. literalinclude:: ../../examples/import_json.py
    :lines: 191-213
    :emphasize-lines: 3,14
    :dedent: 4

Equivalence check
-----------------

Let's see if our importer is working properly.
We can use the model printing listener from :ref:`the first example <example_print-hierarchy>`
to dump the register model:

.. literalinclude:: ../../examples/import_json.py
    :lines: 216-219
    :dedent: 4

Running the example code on ``tiny.rdl`` and its JSON counterpart we exported
in the previous example, ``tiny.json``, we should see identical output:

.. code-block:: text

    $ ./import_json.py tiny.json
    tiny
            r1
                    [7:0] f1 sw=rw
                    [15:8] f2 sw=r
    $ ./import_json.py tiny.rdl
    tiny
            r1
                    [7:0] f1 sw=rw
                    [15:8] f2 sw=r


text:
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Man. cult. trees & shrubs 859. 1927

#### Original name
null

### Remarks
null


text:
import Vue from 'vue'
import Button from '../src/Button'
import { BUTTON_VARIANTS } from '../src/misc/constants'

describe('Button', () => {
    // XXX: remove warning from console
    // '[Vue warn]: options "name" can only be used as a component definition option, not during instance creation.'
    delete Button.name;

    it('render with standard props', () => {
        // define button
        const Btn = Object.assign(
            { propsData: { } },
            Button
        )
        // create view-model and mount it
        const vm = new Vue(Btn)
        vm.$mount()
        // size checks
        expect(vm.size).toBe('md')
        expect(!vm.$el.classList.contains('btn-md')).toBe(true)
        // tag check
        expect(vm.tag).toBe('button')
        expect(vm.$el.tagName).toBe('BUTTON')
        // type check
        expect(vm.type).toBe('button')
        expect(vm.$el.type).toBe('button')
        // variant check
        expect(vm.variant).toBe('secondary')
        expect(vm.$el.classList.contains('btn-secondary')).toBe(true)
    })

    it('render with proper size\'s class', () => {
        // define all sizes
        const SIZES = [
            { value: 'sm', result: true },
            { value: 'md', result: false },
            { value: 'lg', result: true }
        ];
        // automatic test
        SIZES.forEach(({ value, result }) => {
            // define SM button
            const btn = Object.assign(
                { propsData: { size: value } },
                Button
            )
            // create view-model and mount it
            const vm = new Vue(btn)
            vm.$mount()
            // size checks
            expect(vm.size).toBe(value)
            expect(vm.$el.classList.contains(`btn-${value}`)).toBe(result)
        })
    })

    it('render with proper variant\'s class', () => {
        // define all sizes
        const VARIANTS = BUTTON_VARIANTS.map(
            value => ({ value, result: true })
        )
        // automatic test
        VARIANTS.forEach(({ value, result }) => {
            // define SM button
            const btn = Object.assign(
                { propsData: { variant: value } },
                Button
            )
            // create view-model and mount it
            const vm = new Vue(btn)
            vm.$mount()
            // size checks
            expect(vm.variant).toBe(value)
            expect(vm.$el.classList.contains(`btn-${value}`)).toBe(result)
        })
    })

    it('render with `btn-block` when `block` property is true', () => {
        // define SM button
        const btn = Object.assign(
            { propsData: {  } },
            Button
        )
        const btnBlock = Object.assign(
            { propsData: { block: true } },
            Button
        )
        // create view-model and mount it
        const vm = new Vue(btn)
        const vmBlock = new Vue(btnBlock)
        vm.$mount()
        vmBlock.$mount()
        // property check
        expect(vm.block).toBe(false)
        expect(vmBlock.block).toBe(true)
        // $el class check
        expect(vm.$el.classList.contains('btn-block')).toBe(false)
        expect(vmBlock.$el.classList.contains('btn-block')).toBe(true)
    })

    it('render with `disabled` property having priority over `active` one', () => {
        const STATUS = [
            { propsData: { active: true, disabled: true }, result: { active: false, disabled: true } },
            { propsData: { active: true, disabled: false }, result: { active: true, disabled: false } }
        ]
        STATUS.forEach(({ propsData, result }) => {
            // define SM button
            const btn = Object.assign(
                { propsData },
                Button
            )
            // create view-model and mount it
            const vm = new Vue(btn)
            vm.$mount()
            // $el class check
            expect(vm.$el.classList.contains('active')).toBe(result.active)
            expect(vm.$el.classList.contains('disabled')).toBe(result.disabled)
            expect(vm.$el.disabled).toBe(result.disabled)
        })
    })

    it('render with `a` tag when specified', () => {
        // define button
        const Btn = Object.assign(
            { propsData: { tag: 'a' } },
            Button
        )
        // create view-model and mount it
        const vm = new Vue(Btn)
        vm.$mount()
        // tag check
        expect(vm.tag).toBe('a')
        expect(vm.$el.tagName).toBe('A')
    })

    it('render only <a>\'s properties when `a` tag is specified', () => {
        // define constants
        const href = 'https://ddg.gg/'
        const target = '_blank'
        const type = 'submit'
        // define button
        const Link = Object.assign(
            { propsData: { tag: 'a', href, target, type } },
            Button
        )
        // define button
        const Btn = Object.assign(
            { propsData: { href, target, type } },
            Button
        )
        // create view-models and mount them
        const vmLink = new Vue(Link)
        const vmBtn = new Vue(Btn)
        vmLink.$mount()
        vmBtn.$mount()
        // href check
        expect(vmLink.$el.href).toBe(href)
        expect(!vmBtn.$el.href).toBe(true)
        // target check
        expect(vmLink.$el.target).toBe(target)
        expect(!vmBtn.$el.target).toBe(true)
        // type check
        expect(!vmLink.$el.type).toBe(true)
        expect(vmBtn.$el.type).toBe(type)
    })

    // TODO: to test to check how is better
    it('react at click event', () => {
        // define button
        const Btn = Object.assign(
            { propsData: { } },
            Button
        )
        // create view-models and mount them
        const vm = new Vue(Btn)
        vm.$mount()
        vm.$on('click', (ev) => {
            expect(ev instanceof MouseEvent).toBe(true)
        })
        // create and dispatchEvent
        const event = new MouseEvent('click', {
            view: window,
            bubbles: true,
            cancelable: true
        })
        vm.$el.dispatchEvent(event)
    })
})


text:
<TITLE>Review for American Pie (1999)</TITLE>
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/ramr.css">

American Pie (1999)

reviewed by
Bill Chambers

AMERICAN PIE *** (out of four)
-a review by Bill Chambers (pie@filmfreakcentral.net)

(For more purple prose, visit:
Film Freak Central - http://filmfreakcentral.net
Bring a date.)

starring Jason Biggs, Thomas Ian Nicholas, Chris Klein, Tara Reid
screenplay by Adam Herz
directed by Paul Weitz

American Pie acknowledges a cold, hard fact that most movies don't: it
is very difficult to get laid. Its four virgin heroes are Jim (Biggs),
a chronic masturbator, Kev (Nicholas), who desperately wants to
deflower his girlfriend (Reid), Oz (Klein), a lacrosse player whose
approach requires some fine tuning, and Finch (Eddie Kaye Thomas), a
germphobe (his crass nickname is hilarious, but I won't spoil it here)
who pays a classmate to spread rumours about the size of his member.

Jim, Kev, Oz and Finch attend a high school in suburban Michigan full
of so many impossibly beautiful women it's no wonder they're horny all
the time. After a party at their studly friend Stifler's (Seann
William Scott, in the film's sharpest performance) house leaves them
sexually unsatisfied, the quartet make a pact: to "lose it" by
graduation-specifically, prom night, which is only a few weeks away.

American Pie is in the tradition of Bachelor Party or Revenge of the
Nerds. Almost every conversation these characters have revolves around
makin' whoopee. All women are there to be ogled. (Alyson Hannigan's
perky music student is the only memorable female of the bunch.)
Situations abound that defy logic only to arouse and/or amuse its core
audience, adolescent boys. (To arouse: Nadia's (Shannon Elizabeth)
Internet striptease-an unexpectedly raucous (and guiltily pleasurable)
sequence. To amuse: Jim's lusty encounter with a hot apple pie.)

What differentiates American Pie from those dirty eighties comedies,
aside from a very nineties obsession with bodily fluids*, is a cast
that's light years more appealing than that of, say, Just One of the
Guys. Two more standouts: Klein and "SCTV"'s Eugene Levy. Klein plays
a kind-hearted athlete for the second time in a row, after Alexander
Payne's underappreciated Election. I hope to see more of this warm
actor with the disarmingly honest face very soon. Levy's is the most
crowd-pleasing performance, and indeed, it's nice to see him back on
the big screen in a role that makes wonderful use of that expressive
brow.

American Pie also wants to emulate the teen flicks your parents
_would_ let you watch growing up. It skillfully employs a broad mix of
pop tunes, much like John Hughes' movies did, and even pays homage to
The Breakfast Club a couple of times, most evidently when the prom
band covers Simple Minds' "Don't You (Forget About Me)."

The picture ultimately has a healthy, if obligatory, attitude towards
safe sex-even at their most libidinous, American Pie's protagonists
first whip out a condom. The filmmakers prove that socially
responsible raunch is possible.

For its familiarity and for its charming leads, I recommend American
Pie, but the buzz on this film had me expecting something...fresher.
As far as the New Teen Cinema goes, it's at the top of the heap.

*Don't say I didn't warn you about the party scene.

                                      -July, 1999

The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).

The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.

Please direct comments/criticisms of the review to relevant newsgroups.

Broken URLs inthe reviews are the responsibility of the author.

The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.

Related links: index of all rec.arts.movies.reviews reviews


text:
// ask for the latest POSIX, just in case
#define _POSIX_C_SOURCE 200809L

#include "qelapsedtimer.h"
#include <sys/time.h>
#include <time.h>
#include <unistd.h>

#include <mach/mach_time.h>
#include <private/qcore_unix_p.h>

QT_BEGIN_NAMESPACE

QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW
{
    return MachAbsoluteTime;
}

bool QElapsedTimer::isMonotonic() Q_DECL_NOTHROW
{
    return true;
}

static mach_timebase_info_data_t info = {0,0};
static qint64 absoluteToNSecs(qint64 cpuTime)
{
    if (info.denom == 0)
        mach_timebase_info(&info);
    qint64 nsecs = cpuTime * info.numer / info.denom;
    return nsecs;
}

static qint64 absoluteToMSecs(qint64 cpuTime)
{
    return absoluteToNSecs(cpuTime) / 1000000;
}

timespec qt_gettime() Q_DECL_NOTHROW
{
    timespec tv;

    uint64_t cpu_time = mach_absolute_time();
    uint64_t nsecs = absoluteToNSecs(cpu_time);
    tv.tv_sec = nsecs / 1000000000ull;
    tv.tv_nsec = nsecs - (tv.tv_sec * 1000000000ull);
    return tv;
}

void qt_nanosleep(timespec amount)
{
    // Mac doesn't have clock_nanosleep, but it does have nanosleep.
    // nanosleep is POSIX.1-1993

    int r;
    EINTR_LOOP(r, nanosleep(&amount, &amount));
}

void QElapsedTimer::start() Q_DECL_NOTHROW
{
    t1 = mach_absolute_time();
    t2 = 0;
}

qint64 QElapsedTimer::restart() Q_DECL_NOTHROW
{
    qint64 old = t1;
    t1 = mach_absolute_time();
    t2 = 0;

    return absoluteToMSecs(t1 - old);
}

qint64 QElapsedTimer::nsecsElapsed() const Q_DECL_NOTHROW
{
    uint64_t cpu_time = mach_absolute_time();
    return absoluteToNSecs(cpu_time - t1);
}

qint64 QElapsedTimer::elapsed() const Q_DECL_NOTHROW
{
    uint64_t cpu_time = mach_absolute_time();
    return absoluteToMSecs(cpu_time - t1);
}

qint64 QElapsedTimer::msecsSinceReference() const Q_DECL_NOTHROW
{
    return absoluteToMSecs(t1);
}

qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW
{
    return absoluteToMSecs(other.t1 - t1);
}

qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const Q_DECL_NOTHROW
{
    return msecsTo(other) / 1000;
}

bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW
{
    return v1.t1 < v2.t1;
}

QT_END_NAMESPACE


text:
<!--
  The Ohio State University Research Foundation, Emory University,
  the University of Minnesota Supercomputing Institute

  Distributed under the OSI-approved BSD 3-Clause License.
  See http://ncip.github.com/cagrid-grid-incubation/LICENSE.txt for details.
-->
<!--
-->
<ns1:ServiceDescription introduceVersion="1.2" xmlns:ns1="gme://gov.nih.nci.cagrid/1/Introduce">
 <ns2:Namespaces xsi:type="ns2:NamespacesType" xmlns:ns2="gme://gov.nih.nci.cagrid.introduce/1/Namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ns2:Namespace namespace="http://www.w3.org/2001/XMLSchema" xsi:type="ns2:NamespaceType">
   <ns2:SchemaElement type="anySimpleType" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="anyType" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="anyURI" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="base64Binary" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="boolean" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="byte" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="date" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="dateTime" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="decimal" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="double" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="duration" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="ENTITIES" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="ENTITY" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="float" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="gDay" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="gMonth" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="gMonthDay" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="gYear" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="gYearMonth" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="hexBinary" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="ID" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="IDREF" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="IDREFS" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="int" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="integer" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="language" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="long" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="Name" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="NCName" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="negativeInteger" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="NMTOKEN" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="NMTOKENS" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="nonNegativeInteger" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="nonPositiveInteger" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="normalizedString" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="NOTATION" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="positiveInteger" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="QName" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="short" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="string" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="time" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="token" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="unsignedByte" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="unsignedInt" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="unsignedLong" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="unsignedShort" xsi:type="ns2:SchemaElementType"/>
  </ns2:Namespace>
  <ns2:Namespace location="./BpelConsoleTypes.xsd" namespace="http://console.bpel.workflow.cagrid.org/BpelConsole/types" packageName="org.cagrid.workflow.bpel.console.stubs.types" xsi:type="ns2:NamespaceType">
   <ns2:SchemaElement type="BpelConsoleReference" xsi:type="ns2:SchemaElementType"/>
  </ns2:Namespace>
  <ns2:Namespace generateStubs="false" location="./xsd/cagrid/types/security/security.xsd" namespace="gme://caGrid.caBIG/1.0/gov.nih.nci.cagrid.metadata.security" packageName="gov.nih.nci.cagrid.metadata.security" xsi:type="ns2:NamespaceType">
   <ns2:SchemaElement type="CommunicationMechanism" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="CommunicationStyle" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="GSISecureConversation" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="GSISecureMessage" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="GSITransport" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="None" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="Operation" xsi:type="ns2:SchemaElementType"/>
   <ns2:SchemaElement type="ServiceSecurityMetadata" xsi:type="ns2:SchemaElementType"/>
  </ns2:Namespace>
 </ns2:Namespaces>
 <ns3:Services xsi:type="ns3:ServicesType" xmlns:ns3="gme://gov.nih.nci.cagrid.introduce/1/Services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ns3:Service name="BpelConsole" namespace="http://console.bpel.workflow.cagrid.org/BpelConsole" packageName="org.cagrid.workflow.bpel.console" xsi:type="ns3:ServiceType">
   <ns4:Methods xsi:type="ns4:MethodsType" xmlns:ns4="gme://gov.nih.nci.cagrid.introduce/1/Methods">
    <ns4:Method isImported="true" isProvided="true" name="GetMultipleResourceProperties" xsi:type="ns4:MethodType">
     <ns4:Output qName="void" isArray="false"/>
     <ns4:ImportInformation fromIntroduce="false" inputMessage="ns5:GetMultipleResourcePropertiesRequest" namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl" outputMessage="ns5:GetMultipleResourcePropertiesResponse" packageName="org.oasis.wsrf.properties" portTypeName="GetMultipleResourceProperties" wsdlFile="../wsrf/properties/WS-ResourceProperties.wsdl" xmlns:ns5="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl"/>
     <ns4:ProviderInformation providerClass="GetMRPProvider"/>
    </ns4:Method>
    <ns4:Method isImported="true" isProvided="true" name="GetResourceProperty" xsi:type="ns4:MethodType">
     <ns4:Output qName="void" isArray="false"/>
     <ns4:ImportInformation fromIntroduce="false" inputMessage="ns6:GetResourcePropertyRequest" namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl" outputMessage="ns6:GetResourcePropertyResponse" packageName="org.oasis.wsrf.properties" portTypeName="GetResourceProperty" wsdlFile="../wsrf/properties/WS-ResourceProperties.wsdl" xmlns:ns6="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl"/>
     <ns4:ProviderInformation providerClass="GetRPProvider"/>
    </ns4:Method>
    <ns4:Method isImported="true" isProvided="true" name="QueryResourceProperties" xsi:type="ns4:MethodType">
     <ns4:Output qName="void" isArray="false"/>
     <ns4:ImportInformation fromIntroduce="false" inputMessage="ns7:QueryResourcePropertiesRequest" namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl" outputMessage="ns7:QueryResourcePropertiesResponse" packageName="org.oasis.wsrf.properties" portTypeName="QueryResourceProperties" wsdlFile="../wsrf/properties/WS-ResourceProperties.wsdl" xmlns:ns7="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl"/>
     <ns4:ProviderInformation providerClass="QueryRPProvider"/>
    </ns4:Method>
    <ns4:Method isImported="true" isProvided="true" name="getServiceSecurityMetadata" xsi:type="ns4:MethodType">
     <ns4:Output qName="ns8:ServiceSecurityMetadata" isArray="false" isClientHandle="false" xmlns:ns8="gme://caGrid.caBIG/1.0/gov.nih.nci.cagrid.metadata.security"/>
     <ns9:MethodSecurity xsi:type="ns9:MethodSecurity" xmlns:ns9="gme://gov.nih.nci.cagrid.introduce/1/Security">
      <ns9:SecuritySetting xsi:type="ns9:SecuritySetting">None</ns9:SecuritySetting>
      <ns9:MethodAuthorization xsi:type="ns9:MethodAuthorization">
       <ns9:NoAuthorization xsi:type="ns9:NoAuthorization"/>
      </ns9:MethodAuthorization>
     </ns9:MethodSecurity>
     <ns4:ImportInformation namespace="http://security.introduce.cagrid.nci.nih.gov/ServiceSecurity" packageName="gov.nih.nci.cagrid.introduce.security.stubs" portTypeName="ServiceSecurityPortType" wsdlFile="ServiceSecurity.wsdl"/>
     <ns4:ProviderInformation providerClass="gov.nih.nci.cagrid.introduce.security.service.globus.ServiceSecurityProviderImpl"/>
    </ns4:Method>
   </ns4:Methods>
   <ns3:ResourceFrameworkOptions xsi:type="ns3:ResourceFrameworkOptions">
    <ns3:Main xsi:type="ns3:Main"/>
    <ns3:Singleton xsi:type="ns3:Singleton"/>
    <ns3:Identifiable xsi:type="ns3:Identifiable"/>
    <ns3:ResourcePropertyManagement xsi:type="ns3:ResourcePropertyManagement"/>
   </ns3:ResourceFrameworkOptions>
  </ns3:Service>
 </ns3:Services>
 <ns10:Extensions xsi:type="ns10:ExtensionsType" xmlns:ns10="gme://gov.nih.nci.cagrid.introduce/1/Extension" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</ns1:ServiceDescription>


text:
package org.apache.geode.cache30;

import java.util.Properties;

import org.apache.geode.cache.wan.GatewayEventFilter;
import org.apache.geode.cache.wan.GatewayQueueEvent;
import org.apache.geode.internal.cache.xmlcache.Declarable2;

public class MyGatewayEventFilter1 implements GatewayEventFilter, Declarable2 {

  private final Properties resolveProps;

  public MyGatewayEventFilter1() {
    resolveProps = new Properties();
  }

  @Override
  public void close() {

  }

  @Override
  public Properties getConfig() {
    return resolveProps;
  }

  @Override
  public void init(Properties props) {
    resolveProps.putAll(props);
  }

  @Override
  public boolean beforeEnqueue(GatewayQueueEvent event) {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public boolean beforeTransmit(GatewayQueueEvent event) {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public void afterAcknowledgement(GatewayQueueEvent event) {
    // TODO Auto-generated method stub

  }
}


text:
package org.apache.shardingsphere.data.pipeline.mysql.ingest.binlog.event;

import lombok.Getter;
import lombok.Setter;

/**
 * Abstract binlog event.
 */
@Getter
@Setter
public abstract class AbstractBinlogEvent {

    private long serverId;

    private String fileName;

    private long position;

    private long timestamp;
}


text:
Info

What this module does not do

		This module was created to show you an example of how you could integrate Sentry into your own Kohana application.

		However, there are a few areas in this module that are lacking when it's normal to send out information through mail.

		Therefore no user activation code is sent when registering, or a confirmation code when resetting your password, it will just be displayed.

These parts have been marked with @todo in the code.

		Next to that, other parts have also been marked with @todo where it would make sense to take a different approach when you're not in a development environment.

Sentry config file

			Next to handling features implemented in this S4K module it also offers you some options for initiating Sentry.

			All the Throttle features are specific to this module, Sentry itself requires options for:

  A session driver (more info)

  A session key identifier

  A cookie key identifier

  A hasher:

      Bcrypt

      Native

      Sha256