text:
package org.optaplanner.core.api.score;

import java.util.Map;

import org.optaplanner.core.api.domain.entity.PlanningEntity;
import org.optaplanner.core.api.domain.solution.PlanningSolution;
import org.optaplanner.core.api.domain.solution.ProblemFactCollectionProperty;
import org.optaplanner.core.api.score.constraint.ConstraintMatch;
import org.optaplanner.core.api.score.constraint.ConstraintMatchTotal;
import org.optaplanner.core.api.score.constraint.Indictment;
import org.optaplanner.core.api.score.stream.Constraint;

/**
 * Build by {@link ScoreManager#explainScore(Object)} to hold {@link ConstraintMatchTotal}s and {@link Indictment}s
 * necessary to explain the quality of a particular {@link Score}.
 *
 * @param <Solution_> the solution type, the class with the {@link PlanningSolution} annotation
 * @param <Score_> the actual score type
 */
public interface ScoreExplanation<Solution_, Score_ extends Score<Score_>> {

    /**
     * Retrieve the {@link PlanningSolution} that the score being explained comes from.
     *
     * @return never null
     */
    Solution_ getSolution();

    /**
     * Return the {@link Score} being explained.
     * If the specific {@link Score} type used by the {@link PlanningSolution} is required,
     * call {@link #getSolution()} and retrieve it from there.
     *
     * @return never null
     */
    Score_ getScore();

    /**
     * Returns a diagnostic text that explains the {@link Score} through the {@link ConstraintMatch} API
     * to identify which constraints or planning entities cause that score quality.
     * In case of an {@link Score#isFeasible() infeasible} solution,
     * this can help diagnose the cause of that.
     *

     * Do not parse this string.
     * Instead, to provide this information in a UI or a service,
     * use {@link #getConstraintMatchTotalMap()} and {@link #getIndictmentMap()}
     * and convert those into a domain specific API.
     *
     * @return never null
     */
    String getSummary();

    /**
     * Explains the {@link Score} of {@link #getScore()} ()} by splitting it up per {@link Constraint}.
     *

     * The sum of {@link ConstraintMatchTotal#getScore()} equals {@link #getScore()} ()}.
     *
     * @return never null, the key is the {@link ConstraintMatchTotal#getConstraintId() constraintId}
     *         (to create one, use {@link ConstraintMatchTotal#composeConstraintId(String, String)}).
     * @see #getIndictmentMap()
     */
    Map<String, ConstraintMatchTotal<Score_>> getConstraintMatchTotalMap();

    /**
     * Explains the impact of each planning entity or problem fact on the {@link Score}.
     * An {@link Indictment} is basically the inverse of a {@link ConstraintMatchTotal}:
     * it is a {@link Score} total for each justification {@link Object}
     * in {@link ConstraintMatch#getJustificationList()}.
     *

     * The sum of {@link ConstraintMatchTotal#getScore()} differs from {@link #getScore()} ()}
     * because each {@link ConstraintMatch#getScore()} is counted
     * for each justification in {@link ConstraintMatch#getJustificationList()}.
     *
     * @return never null, the key is a {@link ProblemFactCollectionProperty problem fact} or a
     *         {@link PlanningEntity planning entity}
     * @see #getConstraintMatchTotalMap()
     */
    Map<Object, Indictment<Score_>> getIndictmentMap();

}


text:
require_relative './test_helper'

class TestNodeEdit < Minitest::Test
  def setup
    xp = LibXML::XML::Parser.string('<test><num>one</num><num>two</num><num>three</num></test>')
    @doc = xp.parse
  end

  def teardown
    @doc = nil
  end

  def first_node
    @doc.root.child
  end

  def second_node
    first_node.next
  end

  def third_node
    second_node.next
  end

  def test_add_next_01
    first_node.next = LibXML::XML::Node.new('num', 'one-and-a-half')
    assert_equal('<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
                 @doc.root.to_s.gsub(/\n\s*/,''))
  end

  def test_add_next_02
    second_node.next = LibXML::XML::Node.new('num', 'two-and-a-half')
    assert_equal('<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
                 @doc.root.to_s.gsub(/\n\s*/,''))
  end

  def test_add_next_03
    third_node.next = LibXML::XML::Node.new('num', 'four')
    assert_equal '<test><num>one</num><num>two</num><num>three</num><num>four</num></test>',
      @doc.root.to_s.gsub(/\n\s*/,'')
  end

  def test_add_prev_01
    first_node.prev = LibXML::XML::Node.new('num', 'half')
    assert_equal '<test><num>half</num><num>one</num><num>two</num><num>three</num></test>',
      @doc.root.to_s.gsub(/\n\s*/,'')
  end

  def test_add_prev_02
    second_node.prev = LibXML::XML::Node.new('num', 'one-and-a-half')
    assert_equal '<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
      @doc.root.to_s.gsub(/\n\s*/,'')
  end

  def test_add_prev_03
    third_node.prev = LibXML::XML::Node.new('num', 'two-and-a-half')
    assert_equal '<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
      @doc.root.to_s.gsub(/\n\s*/,'')
  end

  def test_remove_node
    first_node.remove!
    assert_equal('<test><num>two</num><num>three</num></test>',
                 @doc.root.to_s.gsub(/\n\s*/,''))
  end

  def test_remove_node_gc
    xp = LibXML::XML::Parser.string('<test><num>one</num><num>two</num><num>three</num></test>')
    doc = xp.parse
    doc.root.child.remove!
    GC.start
    refute_nil(doc)
  end

  def test_remove_node_iteration
    nodes = Array.new
    @doc.root.each_element do |node|
      if node.name == 'num'
        nodes << node
        node.remove!
      end
    end
    assert_equal(3, nodes.length)
  end

  def test_reuse_removed_node
    # Remove the node
    node = @doc.root.first.remove!
    refute_nil(node)

    # Add it to the end of the document
    @doc.root.last.next = node

    assert_equal('<test><num>two</num><num>three</num><num>one</num></test>',
                 @doc.root.to_s.gsub(/\n\s*/,''))
  end

  def test_append_existing_node
    doc = LibXML::XML::Parser.string('<top>a<bottom>b<one>first</one><two>second</two>c</bottom>d</top>').parse
    node1 = doc.find_first('//two')

    doc.root << node1
    assert_equal('<top>a<bottom>b<one>first</one>c</bottom>d<two>second</two></top>',
                 doc.root.to_s)
  end

  def test_wrong_doc
    doc1 = LibXML::XML::Parser.string('<nums><one></one></nums>').parse
    doc2 = LibXML::XML::Parser.string('<nums><two></two></nums>').parse

    node = doc1.root.child

    error = assert_raises(LibXML::XML::Error) do
      doc2.root << node
    end

    GC.start
    assert_equal(' Nodes belong to different documents.  You must first import the node by calling LibXML::XML::Document.import.',
                 error.to_s)
  end

  # This test is to verify that an earlier reported bug has been fixed
  def test_merge
    documents = []

    # Read in 500 documents
    500.times do
      documents << LibXML::XML::Parser.string(File.read(File.join(File.dirname(__FILE__), 'model', 'merge_bug_data.xml'))).parse
    end

    master_doc = documents.shift

    documents.each do |child_doc|
      master_body = master_doc.find("//body").first
      child_body = child_doc.find("//body").first

      child_element = child_body.detect do |node|
        node.element?
      end

      master_body << child_element.copy(true)
    end
  end

  def test_append_chain
    node = LibXML::XML::Node.new('foo') << LibXML::XML::Node.new('bar') << "bars contents"
    assert_equal('<foo><bar/>bars contents</foo>',
                 node.to_s)
  end

  def test_set_base
    @doc.root.base_uri = 'http://www.rubynet.org/'
    assert_equal("<test xml:base=\"http://www.rubynet.org/\">\n  <num>one</num>\n  <num>two</num>\n  <num>three</num>\n</test>",
                 @doc.root.to_s)
  end
end

redpajama_set_name: RedPajamaGithub


text:
#ifndef __BTRFS_EXTENT_IO_H__
#define __BTRFS_EXTENT_IO_H__

#if BTRFS_FLAT_INCLUDES
#include "kerncompat.h"
#include "extent-cache.h"
#include "list.h"
#else
#include <btrfs/kerncompat.h>
#include <btrfs/extent-cache.h>
#include <btrfs/list.h>
#endif /* BTRFS_FLAT_INCLUDES */

#define EXTENT_DIRTY		(1U << 0)
#define EXTENT_WRITEBACK	(1U << 1)
#define EXTENT_UPTODATE		(1U << 2)
#define EXTENT_LOCKED		(1U << 3)
#define EXTENT_NEW		(1U << 4)
#define EXTENT_DELALLOC		(1U << 5)
#define EXTENT_DEFRAG		(1U << 6)
#define EXTENT_DEFRAG_DONE	(1U << 7)
#define EXTENT_BUFFER_FILLED	(1U << 8)
#define EXTENT_CSUM		(1U << 9)
#define EXTENT_BAD_TRANSID	(1U << 10)
#define EXTENT_BUFFER_DUMMY	(1U << 11)
#define EXTENT_IOBITS (EXTENT_LOCKED | EXTENT_WRITEBACK)

#define BLOCK_GROUP_DATA	(1U << 1)
#define BLOCK_GROUP_METADATA	(1U << 2)
#define BLOCK_GROUP_SYSTEM	(1U << 4)

#define BLOCK_GROUP_DIRTY 	(1U)

/*
 * The extent buffer bitmap operations are done with byte granularity instead of
 * word granularity for two reasons:
 * 1. The bitmaps must be little-endian on disk.
 * 2. Bitmap items are not guaranteed to be aligned to a word and therefore a
 *    single word in a bitmap may straddle two pages in the extent buffer.
 */
#define BIT_BYTE(nr) ((nr) / BITS_PER_BYTE)
#define BYTE_MASK ((1 << BITS_PER_BYTE) - 1)
#define BITMAP_FIRST_BYTE_MASK(start) \
	((BYTE_MASK << ((start) & (BITS_PER_BYTE - 1))) & BYTE_MASK)
#define BITMAP_LAST_BYTE_MASK(nbits) \
	(BYTE_MASK >> (-(nbits) & (BITS_PER_BYTE - 1)))

static inline int le_test_bit(int nr, const u8 *addr)
{
	return 1U & (addr[BIT_BYTE(nr)] >> (nr & (BITS_PER_BYTE-1)));
}

struct btrfs_fs_info;

struct extent_io_tree {
	struct cache_tree state;
	struct cache_tree cache;
	struct list_head lru;
	u64 cache_size;
	u64 max_cache_size;
};

struct extent_state {
	struct cache_extent cache_node;
	u64 start;
	u64 end;
	int refs;
	unsigned long state;
	u64 xprivate;
};

struct extent_buffer {
	struct cache_extent cache_node;
	u64 start;
	u64 dev_bytenr;
	struct extent_io_tree *tree;
	struct list_head lru;
	struct list_head recow;
	u32 len;
	int refs;
	u32 flags;
	int fd;
	struct btrfs_fs_info *fs_info;
	char data[] __attribute__((aligned(8)));
};

static inline void extent_buffer_get(struct extent_buffer *eb)
{
	eb->refs++;
}

void extent_io_tree_init(struct extent_io_tree *tree);
void extent_io_tree_init_cache_max(struct extent_io_tree *tree,
				   u64 max_cache_size);
void extent_io_tree_cleanup(struct extent_io_tree *tree);
int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits);
int clear_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits);
int find_first_extent_bit(struct extent_io_tree *tree, u64 start,
			  u64 *start_ret, u64 *end_ret, int bits);
int test_range_bit(struct extent_io_tree *tree, u64 start, u64 end,
		   int bits, int filled);
int set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end);
int clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end);
static inline int set_extent_buffer_uptodate(struct extent_buffer *eb)
{
	eb->flags |= EXTENT_UPTODATE;
	return 0;
}

static inline int clear_extent_buffer_uptodate(struct extent_buffer *eb)
{
	eb->flags &= ~EXTENT_UPTODATE;
	return 0;
}

static inline int extent_buffer_uptodate(struct extent_buffer *eb)
{
	if (!eb || IS_ERR(eb))
		return 0;
	if (eb->flags & EXTENT_UPTODATE)
		return 1;
	return 0;
}

int set_state_private(struct extent_io_tree *tree, u64 start, u64 xprivate);
int get_state_private(struct extent_io_tree *tree, u64 start, u64 *xprivate);
struct extent_buffer *find_extent_buffer(struct extent_io_tree *tree,
					 u64 bytenr, u32 blocksize);
struct extent_buffer *find_first_extent_buffer(struct extent_io_tree *tree,
					       u64 start);
struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
					  u64 bytenr, u32 blocksize);
struct extent_buffer *btrfs_clone_extent_buffer(struct extent_buffer *src);
void free_extent_buffer(struct extent_buffer *eb);
void free_extent_buffer_nocache(struct extent_buffer *eb);
int read_extent_from_disk(struct extent_buffer *eb,
			  unsigned long offset, unsigned long len);
int write_extent_to_disk(struct extent_buffer *eb);
int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv,
			 unsigned long start, unsigned long len);
void read_extent_buffer(struct extent_buffer *eb, void *dst,
			unsigned long start, unsigned long len);
void write_extent_buffer(struct extent_buffer *eb, const void *src,
			 unsigned long start, unsigned long len);
void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src,
			unsigned long dst_offset, unsigned long src_offset,
			unsigned long len);
void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
			   unsigned long src_offset, unsigned long len);
void memset_extent_buffer(struct extent_buffer *eb, char c,
			  unsigned long start, unsigned long len);
int extent_buffer_test_bit(struct extent_buffer *eb, unsigned long start,
			   unsigned long nr);
int set_extent_buffer_dirty(struct extent_buffer *eb);
int clear_extent_buffer_dirty(struct extent_buffer *eb);
int read_data_from_disk(struct btrfs_fs_info *info, void *buf, u64 offset,
			u64 bytes, int mirror);
int write_data_to_disk(struct btrfs_fs_info *info, void *buf, u64 offset,
		       u64 bytes, int mirror);
#endif


text:
/**
 * Created by along on 16/6/23.
 */
var agent = require('superagent');
var SSO_BASE_URL = 'https://oapi.dingtalk.com';

var Api = function(conf) {
    this.SSOSecret = conf.SSOSecret;
    this.corpid = conf.corpid;
}

Api.prototype.getSSOToken = function() {
    var self = this;
    return new Promise(function (reslove, reject) {
        agent.get(SSO_BASE_URL + '/sso/gettoken').query({
            corpid: self.corpid,
            corpsecret: self.SSOSecret
        }).end(wrapper(reslove, reject));
    })
};

//登录
Api.prototype.getSSOUserInfoByCode = function(code) {
    var self = this;
    return new Promise(function (reslove, reject) {
        self.getSSOToken().then(function (token) {
            agent.get(SSO_BASE_URL + '/sso/getuserinfo')
                .query({
                    code: code,
                    access_token: token.access_token
                })
                .end(wrapper(reslove, reject));
        });
    })
};

//生成授权链接
Api.prototype.generateAuthUrl = function(redirect_url) {
    return 'https://oa.dingtalk.com/omp/api/micro_app/admin/landing?corpid=' + this.corpid + '&redirect_url=' + redirect_url;
};

//对返回结果的一层封装,如果遇见微信返回的错误,将返回一个错误
function wrapper (resolve,reject) {
    return function (err, data) {
        if (err) {
            err.name = 'DingTalkAPI' + err.name;
            return reject(err);
        }
        data = data.body;
        if (data.errcode) {
            err = new Error(data.errmsg);
            err.name = 'DingTalkAPIError';
            err.code = data.errcode;
            return reject(err, data);
        }
        resolve(data);
    };
};

module.exports = Api;


text:
from sleepy.conf.base import *

DEBUG = True
TEMPLATE_DEBUG = True

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'sleepy_dev',
    }
}

SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''  # noqa
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''

SOCIAL_AUTH_TWITTER_KEY = ''
SOCIAL_AUTH_TWITTER_SECRET = ''

SOCIAL_AUTH_FACEBOOK_KEY = ''
SOCIAL_AUTH_FACEBOOK_SECRET = ''
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']

SOCIAL_AUTH_GITHUB_KEY = ''
SOCIAL_AUTH_GITHUB_SECRET = ''

LOGGING['loggers']['root']['level'] = 'DEBUG'
LOGGING['loggers']['celery']['level'] = 'DEBUG'
LOGGING['loggers']['sleepy']['level'] = 'DEBUG'

SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False


text:
<?php namespace Tricks\Repositories\Eloquent;

use Tricks\Board;
use Tricks\User;
use Tricks\Repositories\BoardRepositoryInterface;
use Tricks\Services\Forms\BoardForm;

use Illuminate\Support\Facades\Log;

class BoardRepository extends AbstractRepository implements BoardRepositoryInterface {

	protected $board;

	public function __construct(Board $board) {
		$this->model = $board;
	}

	/**
	 * Create a new board in the database.
	 *
	 * @param  array $data
	 * @return \Tricks\Board
	 */
	public function create(array $data)
	{
		$board = $this->getNew();

		$board->board_name        = e($data['board_name']);
		$board->user_id     = $data['user_id'];
		$board->save();

		return $board;
	}

	/**
	 * Create a new board in the database.
	 *
	 * @param  array $data
	 * @return \Tricks\Board
	 */
	public function findById($id)
	{
		return $this->model->whereId($id)->first();

	}

	/**
	 * Get the board creation form service.
	 *
	 * @return \Tricks\Services\Forms\BoardForm
	 */
	public function getCreationForm()
	{
		return new BoardForm;
	}

	public function update($id, array $data) {
		//TODO
	}

	/**
	 * Delete the specified Board from the database.
	 *
	 * @param  mixed $id
	 * @return void
	*/
	public function delete($id) {
		//TODO
	}

	/**
	 * Get an array of key-value paris of all boards
	 *
	 * @return Array
	 */
	public function listAll() {
		$boards = $this->model->lists('board_name', 'id');
		return $boards;
	}

	/**
	 * Find all the boards for the given user.
	 *
	 * @param  \Tricks\User $user
	 */
	public function findAllForUser(User $user)
	{
		Log::info($user->username);
		$boards = $user->boards()->orderBy('created_at', 'DESC')->lists('board_name', 'id');
		return $boards;
	}

	/**
	 * Find all the boards for the given user.
	 *
	 * @param  \Tricks\User $user
	 */
	public function findAllForUser2(User $user)
	{
		Log::info($user->username);
		$boards = $user->boards()->orderBy('created_at', 'DESC')->paginate(10);
		return $boards;
	}

	/**
	 * Find all the boards for the given user.
	 *
	 * @param  \Tricks\User $user
	 */
	public function findAllForUserId($id)
	{
		$user = User::find($id);
		$boards = $user->boards()->orderBy('created_at', 'DESC')->get();

		return $boards;
	}

}


text:
package com.google.checkstyle.test.chapter4formatting.rule451wheretobreack;

public class SeparatorWrapInput {
    public void goodCase()
    {
        int i = 0;
        String s = "ffffooooString";
        s
            .isEmpty(); //ok
        s.isEmpty();

        foo(i,
                s); //ok
    }
    public static void foo(int i, String s)
    {

    }
}

class badCase {

    public void goodCase(int... aFoo)
    {
        int i = 0;

        String s = "ffffooooString";
        /*warn*/boolean b = s.
            isEmpty();
        foo(i
                ,s);
        int[] j;
    }
    public static String foo(int i, String s)
    {
        String maxLength = "123";
        int truncationLength = 1;
        CharSequence seq = null;
        Object truncationIndicator = null;
        return new StringBuilder(maxLength )
        .append(seq, 0, truncationLength )
        .append(truncationIndicator)
        .toString();
    }
}