text:
import os
import gzip
import logging
import click

import paddle.v2 as paddle
import reader
from paddle.v2.layer import parse_network
from network_conf import encoder_decoder_network

logger = logging.getLogger("paddle")
logger.setLevel(logging.INFO)

def save_model(trainer, save_path, parameters):
    with gzip.open(save_path, "w") as f:
        trainer.save_parameter_to_tar(f)

def load_initial_model(model_path, parameters):
    with gzip.open(model_path, "rb") as f:
        parameters.init_from_tar(f)

@click.command("train")
@click.option(
    "--num_passes", default=10, help="Number of passes for the training task.")
@click.option(
    "--batch_size",
    default=16,
    help="The number of training examples in one forward/backward pass.")
@click.option(
    "--use_gpu", default=False, help="Whether to use gpu to train the model.")
@click.option(
    "--trainer_count", default=1, help="The thread number used in training.")
@click.option(
    "--save_dir_path",
    default="models",
    help="The path to saved the trained models.")
@click.option(
    "--encoder_depth",
    default=3,
    help="The number of stacked LSTM layers in encoder.")
@click.option(
    "--decoder_depth",
    default=3,
    help="The number of stacked LSTM layers in decoder.")
@click.option(
    "--train_data_path", required=True, help="The path of trainning data.")
@click.option(
    "--word_dict_path", required=True, help="The path of word dictionary.")
@click.option(
    "--init_model_path",
    default="",
    help=("The path of a trained model used to initialized all "
          "the model parameters."))
def train(num_passes,
          batch_size,
          use_gpu,
          trainer_count,
          save_dir_path,
          encoder_depth,
          decoder_depth,
          train_data_path,
          word_dict_path,
          init_model_path=""):
    if not os.path.exists(save_dir_path):
        os.mkdir(save_dir_path)
    assert os.path.exists(
        word_dict_path), "The given word dictionary does not exist."
    assert os.path.exists(
        train_data_path), "The given training data does not exist."

    # initialize PaddlePaddle
    paddle.init(use_gpu=use_gpu, trainer_count=trainer_count)

    # define optimization method and the trainer instance
    optimizer = paddle.optimizer.Adam(
        learning_rate=1e-4,
        regularization=paddle.optimizer.L2Regularization(rate=1e-5),
        model_average=paddle.optimizer.ModelAverage(
            average_window=0.5, max_average_window=2500))

    cost = encoder_decoder_network(
        word_count=len(open(word_dict_path, "r").readlines()),
        emb_dim=512,
        encoder_depth=encoder_depth,
        encoder_hidden_dim=512,
        decoder_depth=decoder_depth,
        decoder_hidden_dim=512,
        bos_id=0,
        eos_id=1,
        max_length=9)

    parameters = paddle.parameters.create(cost)
    if init_model_path:
        load_initial_model(init_model_path, parameters)

    trainer = paddle.trainer.SGD(cost=cost,
                                 parameters=parameters,
                                 update_equation=optimizer)

    # define data reader
    train_reader = paddle.batch(
        paddle.reader.shuffle(
            reader.train_reader(train_data_path, word_dict_path),
            buf_size=1024000),
        batch_size=batch_size)

    # define the event_handler callback
    def event_handler(event):
        if isinstance(event, paddle.event.EndIteration):
            if (not event.batch_id % 1000) and event.batch_id:
                save_path = os.path.join(save_dir_path,
                                         "pass_%05d_batch_%05d.tar.gz" %
                                         (event.pass_id, event.batch_id))
                save_model(trainer, save_path, parameters)

            if not event.batch_id % 10:
                logger.info("Pass %d, Batch %d, Cost %f, %s" % (
                    event.pass_id, event.batch_id, event.cost, event.metrics))

        if isinstance(event, paddle.event.EndPass):
            save_path = os.path.join(save_dir_path,
                                     "pass_%05d.tar.gz" % event.pass_id)
            save_model(trainer, save_path, parameters)

    # start training
    trainer.train(
        reader=train_reader, event_handler=event_handler, num_passes=num_passes)

if __name__ == "__main__":
    train()


text:
<?php
/**
 * the resource request data
 */
class HttpResourceHandler_Request
{
    /**
     * @var array
     */
    private $params;

    /**
     * @var array|stdClass|null
     */
    private $body;

    /**
     * @param array $params
     * @param array|stdClass|null $body
     */
    public function __construct(array $params, $body = null)
    {
        $this->params = $params;
        $this->body = $body;
    }

    /**
     * @param string $key
     * @return array
     */
    public function getParam($key)
    {
        if (!$this->hasParam($key)) {
            throw new InvalidArgumentException('param does not exist.');
        }
        return $this->params[$key];
    }

    /**
     * @param string $key
     * @return bool
     */
    public function hasParam($key)
    {
        return isset($this->params[$key]);
    }

    /**
     * @return array|stdClass
     */
    public function getBody()
    {
        if ($this->body === null) {
            throw new RuntimeException('body is empty');
        }
        return $this->body;
    }
}

redpajama_set_name: RedPajamaGithub


text:
'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = getImplicitRoleForTextarea;
/**
 * Returns the implicit role for a textarea tag.
 */
function getImplicitRoleForTextarea() {
  return 'textbox';
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ChangeListManager">
    <list default="true" id="e11050ff-674a-465f-a8a9-63ee3b1ec195" name="Default" comment="">
      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/vcs.xml" />
      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/_config.yml" afterPath="$PROJECT_DIR$/_config.yml" />
      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/_includes/head.html" afterPath="$PROJECT_DIR$/_includes/head.html" />
      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/_layouts/post.html" afterPath="$PROJECT_DIR$/_layouts/post.html" />
      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/index.html" afterPath="$PROJECT_DIR$/index.html" />
    </list>
    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
    <option name="TRACKING_ENABLED" value="true" />
    <option name="SHOW_DIALOG" value="false" />
    <option name="HIGHLIGHT_CONFLICTS" value="true" />
    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
    <option name="LAST_RESOLUTION" value="IGNORE" />
  </component>
  <component name="CreatePatchCommitExecutor">
    <option name="PATCH_PATH" value="" />
  </component>
  <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
  <component name="FileEditorManager">
    <leaf>
      <file leaf-file-name="footer.html" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/_includes/footer.html">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="225">
              <caret line="87" column="48" lean-forward="true" selection-start-line="87" selection-start-column="48" selection-end-line="87" selection-end-column="48" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="_config.yml" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/_config.yml">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="44">
              <caret line="8" column="15" lean-forward="true" selection-start-line="8" selection-start-column="15" selection-end-line="8" selection-end-column="15" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="page.html" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/_layouts/page.html">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="242">
              <caret line="11" column="38" lean-forward="false" selection-start-line="11" selection-start-column="20" selection-end-line="11" selection-end-column="38" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="post.html" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/_layouts/post.html">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="318">
              <caret line="22" column="38" lean-forward="true" selection-start-line="22" selection-start-column="38" selection-end-line="22" selection-end-column="38" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="index.html" pinned="false" current-in-tab="true">
        <entry file="file://$PROJECT_DIR$/index.html">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="154">
              <caret line="7" column="53" lean-forward="true" selection-start-line="7" selection-start-column="53" selection-end-line="7" selection-end-column="53" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="head.html" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/_includes/head.html">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="453">
              <caret line="24" column="84" lean-forward="true" selection-start-line="23" selection-start-column="4" selection-end-line="24" selection-end-column="84" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="bootstrap.min.js" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/js/bootstrap.min.js">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="0">
              <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="bootstrap.js" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/js/bootstrap.js">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="0">
              <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="backtop.js" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/js/backtop.js">
          <provider selected="true" editor-type-id="text-editor">
            <state relative-caret-position="88">
              <caret line="4" column="0" lean-forward="true" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
    </leaf>
  </component>
  <component name="FindInProjectRecents">
    <findStrings>
      <find>posted</find>
    </findStrings>
  </component>
  <component name="Git.Settings">
    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
  </component>
  <component name="IdeDocumentHistory">
    <option name="CHANGED_PATHS">
      <list>
        <option value="$PROJECT_DIR$/_config.yml" />
        <option value="$PROJECT_DIR$/_layouts/post.html" />
        <option value="$PROJECT_DIR$/index.html" />
        <option value="$PROJECT_DIR$/_includes/head.html" />
      </list>
    </option>
  </component>
  <component name="ProjectFrameBounds">
    <option name="x" value="-1913" />
    <option name="y" value="39" />
    <option name="width" value="1920" />
    <option name="height" value="1057" />
  </component>
  <component name="ProjectView">
    <navigator currentView="ProjectPane" proportions="" version="1">
      <flattenPackages />
      <showMembers />
      <showModules />
      <showLibraryContents />
      <hideEmptyPackages />
      <abbreviatePackageNames />
      <autoscrollToSource />
      <autoscrollFromSource />
      <sortByType />
      <manualOrder />
      <foldersAlwaysOnTop value="true" />
    </navigator>
    <panes>
      <pane id="Scope" />
      <pane id="Scratches" />
      <pane id="ProjectPane">
        <subPane>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="kotomifi.github.io" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="kotomifi.github.io" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="kotomifi.github.io" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="kotomifi.github.io" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="img" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="kotomifi.github.io" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="kotomifi.github.io" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="css" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="kotomifi.github.io" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="kotomifi.github.io" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="_posts" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="kotomifi.github.io" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="kotomifi.github.io" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="_layouts" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="kotomifi.github.io" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="kotomifi.github.io" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="_includes" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
        </subPane>
      </pane>
    </panes>
  </component>
  <component name="PropertiesComponent">
    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
  </component>
  <component name="RunManager">
    <configuration default="true" type="PythonConfigurationType" factoryName="Python">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs>
        <env name="PYTHONUNBUFFERED" value="1" />
      </envs>
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="kotomifi.github.io" />
      <option name="SCRIPT_NAME" value="" />
      <option name="PARAMETERS" value="" />
      <option name="SHOW_COMMAND_LINE" value="false" />
      <method />
    </configuration>
    <configuration default="true" type="Tox" factoryName="Tox">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="kotomifi.github.io" />
      <method />
    </configuration>
    <configuration default="true" type="tests" factoryName="Attests">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="kotomifi.github.io" />
      <option name="SCRIPT_NAME" value="" />
      <option name="CLASS_NAME" value="" />
      <option name="METHOD_NAME" value="" />
      <option name="FOLDER_NAME" value="" />
      <option name="TEST_TYPE" value="TEST_SCRIPT" />
      <option name="PATTERN" value="" />
      <option name="USE_PATTERN" value="false" />
      <method />
    </configuration>
    <configuration default="true" type="tests" factoryName="Doctests">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="kotomifi.github.io" />
      <option name="SCRIPT_NAME" value="" />
      <option name="CLASS_NAME" value="" />
      <option name="METHOD_NAME" value="" />
      <option name="FOLDER_NAME" value="" />
      <option name="TEST_TYPE" value="TEST_SCRIPT" />
      <option name="PATTERN" value="" />
      <option name="USE_PATTERN" value="false" />
      <method />
    </configuration>
    <configuration default="true" type="tests" factoryName="Nosetests">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="kotomifi.github.io" />
      <option name="SCRIPT_NAME" value="" />
      <option name="CLASS_NAME" value="" />
      <option name="METHOD_NAME" value="" />
      <option name="FOLDER_NAME" value="" />
      <option name="TEST_TYPE" value="TEST_SCRIPT" />
      <option name="PATTERN" value="" />
      <option name="USE_PATTERN" value="false" />
      <option name="PARAMS" value="" />
      <option name="USE_PARAM" value="false" />
      <method />
    </configuration>
    <configuration default="true" type="tests" factoryName="Unittests">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="kotomifi.github.io" />
      <option name="SCRIPT_NAME" value="" />
      <option name="CLASS_NAME" value="" />
      <option name="METHOD_NAME" value="" />
      <option name="FOLDER_NAME" value="" />
      <option name="TEST_TYPE" value="TEST_SCRIPT" />
      <option name="PATTERN" value="" />
      <option name="USE_PATTERN" value="false" />
      <option name="PUREUNITTEST" value="true" />
      <option name="PARAMS" value="" />
      <option name="USE_PARAM" value="false" />
      <method />
    </configuration>
    <configuration default="true" type="tests" factoryName="py.test">
      <option name="INTERPRETER_OPTIONS" value="" />
      <option name="PARENT_ENVS" value="true" />
      <envs />
      <option name="SDK_HOME" value="" />
      <option name="WORKING_DIRECTORY" value="" />
      <option name="IS_MODULE_SDK" value="false" />
      <option name="ADD_CONTENT_ROOTS" value="true" />
      <option name="ADD_SOURCE_ROOTS" value="true" />
      <module name="kotomifi.github.io" />
      <option name="SCRIPT_NAME" value="" />
      <option name="CLASS_NAME" value="" />
      <option name="METHOD_NAME" value="" />
      <option name="FOLDER_NAME" value="" />
      <option name="TEST_TYPE" value="TEST_SCRIPT" />
      <option name="PATTERN" value="" />
      <option name="USE_PATTERN" value="false" />
      <option name="testToRun" value="" />
      <option name="keywords" value="" />
      <option name="params" value="" />
      <option name="USE_PARAM" value="false" />
      <option name="USE_KEYWORD" value="false" />
      <method />
    </configuration>
  </component>
  <component name="ShelveChangesManager" show_recycled="false">
    <option name="remove_strategy" value="false" />
  </component>
  <component name="TaskManager">
    <task active="true" id="Default" summary="Default task">
      <changelist id="e11050ff-674a-465f-a8a9-63ee3b1ec195" name="Default" comment="" />
      <created>1482662575529</created>
      <option name="number" value="Default" />
      <option name="presentableId" value="Default" />
      <updated>1482662575529</updated>
    </task>
    <servers />
  </component>
  <component name="ToolWindowManager">
    <frame x="-1913" y="39" width="1920" height="1057" extended-state="0" />
    <editor active="true" />
    <layout>
      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.18697916" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
      <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
      <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
      <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
      <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
    </layout>
  </component>
  <component name="VcsContentAnnotationSettings">
    <option name="myLimit" value="2678400000" />
  </component>
  <component name="XDebuggerManager">
    <breakpoint-manager />
    <watches-manager />
  </component>
  <component name="editorHistoryManager">
    <entry file="file://$PROJECT_DIR$/_layouts/default.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/404.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="682">
          <caret line="31" column="26" lean-forward="true" selection-start-line="31" selection-start-column="26" selection-end-line="31" selection-end-column="26" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/less/variables.less">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/less/mixins.less">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/less/clean-blog.less">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="-3630">
          <caret line="12" column="0" lean-forward="true" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/js/clean-blog.js">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="-814">
          <caret line="12" column="0" lean-forward="true" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/js/bootstrap.min.js">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/js/bootstrap.js">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/js/backtop.js">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="88">
          <caret line="4" column="0" lean-forward="true" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_includes/footer.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="225">
          <caret line="87" column="48" lean-forward="true" selection-start-line="87" selection-start-column="48" selection-end-line="87" selection-end-column="48" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/favicon.ico">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/blue.jpg">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/img/cnfeat.jpg">
      <provider selected="true" editor-type-id="images">
        <state />
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_config.yml">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="44">
          <caret line="8" column="15" lean-forward="true" selection-start-line="8" selection-start-column="15" selection-end-line="8" selection-end-column="15" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_layouts/page.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="242">
          <caret line="11" column="38" lean-forward="false" selection-start-line="11" selection-start-column="20" selection-end-line="11" selection-end-column="38" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_layouts/post.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="318">
          <caret line="22" column="38" lean-forward="true" selection-start-line="22" selection-start-column="38" selection-end-line="22" selection-end-column="38" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/css/markdown.css">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="0">
          <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/_includes/head.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="453">
          <caret line="24" column="84" lean-forward="true" selection-start-line="23" selection-start-column="4" selection-end-line="24" selection-end-column="84" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/index.html">
      <provider selected="true" editor-type-id="text-editor">
        <state relative-caret-position="154">
          <caret line="7" column="53" lean-forward="true" selection-start-line="7" selection-start-column="53" selection-end-line="7" selection-end-column="53" />
          <folding />
        </state>
      </provider>
    </entry>
  </component>
</project>


text:
package io.permazen.core;

import java.util.Collection;

/**
 * Adapter class for {@link FieldSwitch}.
 *
 * @param <R> switch method return type
 */
public class FieldSwitchAdapter<R> implements FieldSwitch<R> {

    /**
     * Handle a {@link SetField}.
     *
     *

     * The implementation in {@link FieldSwitchAdapter} delegates to {@link #caseCollectionField caseCollectionField()}.
     */
    @Override
    public <E> R caseSetField(SetField<E> field) {
        return this.caseCollectionField(field);
    }

    /**
     * Handle a {@link ListField}.
     *
     *

     * The implementation in {@link FieldSwitchAdapter} delegates to {@link #caseCollectionField caseCollectionField()}.
     */
    @Override
    public <E> R caseListField(ListField<E> field) {
        return this.caseCollectionField(field);
    }

    /**
     * Handle a {@link MapField}.
     *
     *

     * The implementation in {@link FieldSwitchAdapter} delegates to {@link #caseComplexField caseComplexField()}.
     */
    @Override
    public <K, V> R caseMapField(MapField<K, V> field) {
        return this.caseComplexField(field);
    }

    /**
     * Handle a {@link SimpleField}.
     *
     *

     * The implementation in {@link FieldSwitchAdapter} delegates to {@link #caseField caseField()}.
     */
    @Override
    public <T> R caseSimpleField(SimpleField<T> field) {
        return this.caseField(field);
    }

    /**
     * Handle a {@link ReferenceField}.
     *
     *

     * The implementation in {@link FieldSwitchAdapter} delegates to {@link #caseSimpleField caseSimpleField()}.
     */
    @Override
    public R caseReferenceField(ReferenceField field) {
        return this.caseSimpleField(field);
    }

    /**
     * Handle a {@link CounterField}.
     *
     *

     * The implementation in {@link FieldSwitchAdapter} delegates to {@link #caseField caseField()}.
     */
    @Override
    public R caseCounterField(CounterField field) {
        return this.caseField(field);
    }

    /**
     * Handle a {@link EnumField}.
     *
     *

     * The implementation in {@link FieldSwitchAdapter} delegates to {@link #caseSimpleField caseSimpleField()}.
     */
    @Override
    public R caseEnumField(EnumField field) {
        return this.caseSimpleField(field);
    }

    /**
     * Handle a {@link EnumArrayField}.
     *
     *

     * The implementation in {@link FieldSwitchAdapter} delegates to {@link #caseSimpleField caseSimpleField()}.
     */
    @Override
    public R caseEnumArrayField(EnumArrayField field) {
        return this.caseSimpleField(field);
    }

    /**
     * Adapter class roll-up method.
     *
     *

     * The implementation in {@link FieldSwitchAdapter} delegates to {@link #caseComplexField caseComplexField()}.
     *
     * @param field visiting field
     * @param <C> visiting field type
     * @param <E> collection element type
     * @return visitor return value
     */
    protected <C extends Collection<E>, E> R caseCollectionField(CollectionField<C, E> field) {
        return this.caseComplexField(field);
    }

    /**
     * Adapter class roll-up method.
     *
     *

     * The implementation in {@link FieldSwitchAdapter} delegates to {@link #caseField caseField()}.
     *
     * @param field visiting field
     * @param <T> visiting field type
     * @return visitor return value
     */
    protected <T> R caseComplexField(ComplexField<T> field) {
        return this.caseField(field);
    }

    /**
     * Adapter class roll-up method.
     *
     *

     * The implementation in {@link FieldSwitchAdapter} always throws {@link UnsupportedOperationException}.
     *
     * @param field visiting field
     * @param <T> visiting field type
     * @return visitor return value
     */
    protected <T> R caseField(Field<T> field) {
        throw new UnsupportedOperationException("field type not handled: " + field);
    }
}


text:
layout: post
title: Whit friday and Black Dyke
date: 2007-06-11T08:23:00.000Z
author: Marcus Hammarberg
tags:
  - BrassBand
modified_time: 2007-06-11T08:28:47.633Z
blogger_id: tag:blogger.com,1999:blog-36533086.post-3434132804816088329
blogger_orig_url: http://www.marcusoft.net/2007/06/whit-friday-and-black-dyke.html
---

There is a famous brass band / marching competition in Great Britain
called Whit Friday. There are loads and loads of bands taking part and
they march up to a small village do a march and then continue on. Most
bands do more than 15 events like this during the day.

There really fun part of it is that bands of all sorts take part from
the most famous to the ...eh.. not so famous.

Here is a short clip of Black Dyke doing a march in Delph. Take special
notice of the tuba players in the front. I could carry one of those
tubas for a minute, not to mention how it would be to play it...


text:
<!doctype html>

  Online documentation can be found at http://app.capptain.com/doc-sdk/Android/2.4.1


text:
package org.jvnet.hudson.plugins.triggers.startup;

import hudson.model.Cause;
import hudson.model.Node;

public class HudsonStartupCause extends Cause {

    private final Node node;

    public HudsonStartupCause(Node node) {
        this.node = node;
    }

    @Override
    public String getShortDescription() {
        return "Started due to the start of the node " + node.getDisplayName();
    }
}


text:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Chapter 25.  DbstlDbt</title>
    <link rel="stylesheet" href="apiReference.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Berkeley DB C++ Standard Template Library API Reference" />
    <link rel="up" href="index.html" title="Berkeley DB C++ Standard Template Library API Reference" />
    <link rel="prev" href="stlElementRef_DB_STL_value.html" title="_DB_STL_value" />
    <link rel="next" href="stlDbstlDbtdstr_DbstlDbt.html" title="~DbstlDbt" />

Library Version 11.2.5.3

          Chapter 25.
 DbstlDbt

          Prev

           Next

Chapter 25.
 DbstlDbt

You can persist all bytes in a chunk of contiguous memory by constructing an DbstlDbt
 object A(use malloc to allocate the required number of bytes for A.data and copy the bytes to be stored into A.data, set other fields as necessary) and store A into a container, e.g.

db_vector<DbstlDbt>, this stores the bytes rather than the object A into the underlying database. The DbstlDbt
 class can help you avoid memory leaks, so it is strongly recommended that you use DbstlDbt
 rather than Dbt class.

DbstlDbt
 derives from Dbt class, and it does an deep copy on copy construction and assignment --by calling malloc to allocate its own memory and then copying the bytes to it; Conversely the destructor will free the memory on destruction if the data pointer is non-NULL. The destructor assumes the memory is allocated via malloc, hence why you are required to call malloc to allocate memory in order to use DbstlDbt
.

DbstlDbt
 simply inherits all methods from Dbt with no extra new methods except the constructors/destructor and assignment operator, so it is easy to use.

In practice you rarely need to use DbstlDbt
 or Dbt because dbstl enables you to store any complex objects or primitive data. Only when you need to store raw bytes, e.g. a bitmap, do you need to use DbstlDbt
.

Hence, DbstlDbt
 is the right class to use to store any object into Berkeley DB via dbstl without memory leaks.

Don't free the memory referenced by DbstlDbt
 objects, it will be freed when the DbstlDbt
 object is destructed.

Please refer to the two examples using DbstlDbt
 in TestAssoc::test_arbitrary_object_storage and TestAssoc::test_char_star_string_storage member functions, which illustrate how to correctly use DbstlDbt
 in order to store raw bytes.

This class handles the task of allocating and de-allocating memory internally. Although it can be used to store data which cannot be handled by the DbstlElemTraits
 class, in practice, it is usually more convenient to register callbacks in the DbstlElemTraits
 class for the type you are storing/retrieving using dbstl.

 Public Members

          <colgroup>
            <col />
            <col />
          </colgroup>

              Member
              Description

DbstlDbt

Construct an object with an existing chunk of memory of size1 bytes, refered by data1,.

~DbstlDbt

The memory will be free'ed by the destructor.

operator=

The memory will be reallocated if neccessary.

Group

 Dbstl Helper Classes

DbstlDbt

Function Details

DbstlDbt(void *data1,
    u_int32_t size1)

Construct an object with an existing chunk of memory of size1 bytes, refered by data1,.

DbstlDbt()

DbstlDbt(const DbstlDbt &d)

This copy constructor does a deep copy.

Class

  DbstlDbt

          Prev

           Next

          _DB_STL_value

            Home

           ~DbstlDbt


text:
<?php

namespace App\Repositories;

use App\Models\UserActivity;
use InfyOm\Generator\Common\BaseRepository;

class UserActivityRepository extends BaseRepository
{
    /**
     * @var array
     */
    protected $fieldSearchable = [
        'order',
        'is_registered',
        'registrarion_date',
        'registrated_by',
        'persona_id',
        'activity_id'
    ];

    /**
     * Configure the Model
     **/
    public function model()
    {
        return UserActivity::class;
    }
}


text:
package com.wingjay.wingjay_skin_loader;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.LayoutInflater.Factory;
import android.view.View;

/**
 * SkinInflaterFactory
 * 0. Each ViewHolder has one SkinInflaterFactory;
 * 1. During inflating view, it will store all skin-enable views as SkinView in skinViewList;
 * 2. When skin updates, it will traverse all skinView, let them apply new resource from SkinManager.
 *
 * Warning: Remember when ViewHolder destroys, you should make sure this Factory MUST also be destroyed.
 *
 * android:background="@color/red" (id: @12312312)
 *      background:     attributeSet.getAttributeName(i);
 *      id @12312312:   attributeSet.getAttributeValue(i);
 *      resId 12312312: Integer.parseInt(attributeSet.getAttributeValue(i).substring(1));
 *      color:          resource.getResourceTypeName(resId)
 *      red:            resource.getResourceEntryName(resId)
 *
 * @author wingjay
 * @date 2017/08/03
 */
public class SkinInflaterFactory implements Factory {

    private static final String skinNameSpace = "http://schemas.android.com/android/skin";
    private List<SkinView> skinViewList = new ArrayList<>();
    private Resources systemResource;

    public SkinInflaterFactory(Context context) {
        systemResource = context.getResources();
    }

    @Override
    public View onCreateView(String name, Context context, AttributeSet attributeSet) {
        // check if enable is true
        boolean enable = attributeSet.getAttributeBooleanValue(skinNameSpace, "enable", false);
        if (!enable) {
            return null;
        }

        View view = createView(name, context, attributeSet);

        // fetch all attrs whose value is like @color/ @drawable
        parseAttrs(view, attributeSet);

        return view;
    }

    /**
     * let all saved view use new resource.
     */
    public void updateSkin() {
        for (SkinView skinView : skinViewList) {
            skinView.apply();
        }
    }

    /**
     * when view holder destroy, better to invoke {@link #clean()} to avoid memory-leak
     */
    public void clean() {
        skinViewList.clear();
    }

    private void parseAttrs(View targetView, AttributeSet attributeSet) {
        // store all to-be-skined attrs
        int attrsCount = attributeSet.getAttributeCount();
        for (int i = 0; i < attrsCount; i++) {
            // android:background="@color/red" as example
            String attrName = attributeSet.getAttributeName(i); // background

            // not support: android:textSize etc.
            if (!SupportedAttrName.isSupport(attrName)) {
                continue;
            }

            // not support: android:background="#FF00FF", must be @1239812398 style
            String attrValue = attributeSet.getAttributeValue(i);
            if (!attrValue.startsWith("@")) {
                continue;
            }

            // extract resId
            int resId = Integer.parseInt(attrValue.substring(1));

            // assemble SkinView
            // systemResource use resId to get resource type name
            SkinView skinView = new SkinView(targetView, attrName, resId);
            skinViewList.add(skinView);
        }
    }

    private View createView(String name, Context context, AttributeSet attributeSet) {
        View v = null;
        try {
            if (-1 == name.indexOf('.')) {
                // system view
                if ("View".equals(name)) {
                    v = LayoutInflater.from(context).createView(name, "android.view.", attributeSet);
                }
                if (v == null) {
                    v = LayoutInflater.from(context).createView(name, "android.widget.", attributeSet);
                }
                if (v == null) {
                    v = LayoutInflater.from(context).createView(name, "android.webkit.", attributeSet);
                }
            } else {
                // customized view
                v = LayoutInflater.from(context).createView(name, null, attributeSet);
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        return v;
    }

}