text:
package mp

import (
	"encoding/xml"
	"net/http"
	"time"
)

type MsgType string
type EventType string

const (
	MsgText             MsgType = "text"
	MsgImage                    = "image"
	MsgVoice                    = "voice"
	MsgVideo                    = "video"
	MsgMusic                    = "music"
	MsgNews                     = "news"
	MsgLocation                 = "location"
	MsgLink                     = "link"
	MsgEvent                    = "event"
	MsgSubscribeEvent           = "event.subscribe"
	MsgUnsubscribeEvent         = "event.unsubscribe"
	MsgScanEvent                = "event.SCAN"
	MsgLocationEvent            = "event.LOCATION"
	MsgClickEvent               = "event.CLICK"

	EventSubscribe   EventType = "subscribe"
	EventUnsubscribe           = "unsubscribe"
	EventScan                  = "SCAN"
	EventLocation              = "LOCATION"
	EventClick                 = "CLICK"
)

type MsgHeader struct {
	ToUserName   string
	FromUserName string
	CreateTime   int64
	Type         string
}

type ServiceMsgHeader struct {
	ToUser string `json:"touser"`
	Type   string `json:"msgtype"`
}

type TitleDesc struct {
	Title       string `json:"title"`
	Description string `json:"description"`
}

type Music struct {
	MusicURL     string `json:"musicurl"`
	HQMusicUrl   string `json:"hqmusicurl"`
	ThumbMediaId string `json:"thumb_media_id"`
}

type Article struct {
	TitleDesc
	PicUrl string `json:"picurl"`
	Url    string `json:"url"`
}

type Message struct {
	MsgHeader
	TitleDesc
	Music
	MsgId        uint64
	Content      string
	Url          string
	PicUrl       string
	MediaId      string
	ArticleCount int
	Articles     []Article
	Format       string
	Recognition  string
	LocationX    float64 `xml:"Location_X"`
	LocationY    float64 `xml:"Location_Y"`
	Scale        int
	Label        string
	Event        string
	EventKey     string
	Ticket       string
	Latitude     float64
	Longitude    float64
	Precision    float64
}

type Replyer interface {
	ReplyText(content string) error
	ReplyImage(mediaId string) error
	ReplyVoice(mediaId string) error
	ReplyVideo(mediaId string, info TitleDesc) error
	ReplyMusic(info TitleDesc, music Music) error
	ReplyImageText(articles []Article) error
}

type messageReply struct {
	fromUserName string
	toUserName   string
	w            http.ResponseWriter
	replied      bool
}

func (r *messageReply) reply(v interface{}) error {
	r.replied = true

	data, err := xml.Marshal(v)
	if err != nil {
		return err
	}
	r.w.Header().Set("Content-Type", xmlContentType)
	_, err = r.w.Write(data)
	return err
}

func (r *messageReply) ReplyText(content string) error {
	var data struct {
		XMLName xml.Name `xml:"xml"`
		MsgHeader
		Content string
	}

	data.Type = string(MsgText)
	data.ToUserName = r.toUserName
	data.FromUserName = r.fromUserName
	data.CreateTime = time.Now().Unix()
	data.Content = content

	return r.reply(&data)
}

func (r *messageReply) ReplyImage(mediaId string) error {
	var data struct {
		XMLName xml.Name `xml:"xml"`
		MsgHeader
		Image struct {
			MediaId string
		}
	}

	data.Type = string(MsgImage)
	data.ToUserName = r.toUserName
	data.FromUserName = r.fromUserName
	data.CreateTime = time.Now().Unix()
	data.Image.MediaId = mediaId

	return r.reply(&data)
}

func (r *messageReply) ReplyVoice(mediaId string) error {
	var data struct {
		XMLName xml.Name `xml:"xml"`
		MsgHeader
		Voice struct {
			MediaId string
		}
	}

	data.Type = string(MsgVoice)
	data.ToUserName = r.toUserName
	data.FromUserName = r.fromUserName
	data.CreateTime = time.Now().Unix()
	data.Voice.MediaId = mediaId

	return r.reply(&data)
}

func (r *messageReply) ReplyVideo(mediaId string, info TitleDesc) error {
	var data struct {
		XMLName xml.Name `xml:"xml"`
		MsgHeader
		Video struct {
			MediaId string
			TitleDesc
		}
	}

	data.Type = string(MsgVideo)
	data.ToUserName = r.toUserName
	data.FromUserName = r.fromUserName
	data.CreateTime = time.Now().Unix()
	data.Video.MediaId = mediaId
	data.Video.TitleDesc = info

	return r.reply(&data)
}

func (r *messageReply) ReplyMusic(info TitleDesc, music Music) error {
	var data struct {
		XMLName xml.Name `xml:"xml"`
		MsgHeader
		M struct {
			TitleDesc
			Music
		} `xml:"Music"`
	}

	data.Type = string(MsgMusic)
	data.ToUserName = r.toUserName
	data.FromUserName = r.fromUserName
	data.CreateTime = time.Now().Unix()
	data.M.TitleDesc = info
	data.M.Music = music

	return r.reply(&data)
}

func (r *messageReply) ReplyImageText(articles []Article) error {
	var data struct {
		XMLName xml.Name `xml:"xml"`
		MsgHeader
		ArticleCount int
		Articles     []Article `xml:"Articles>item"`
	}

	data.Type = string(MsgNews)
	data.ToUserName = r.toUserName
	data.FromUserName = r.fromUserName
	data.CreateTime = time.Now().Unix()
	data.ArticleCount = len(articles)
	data.Articles = articles

	return r.reply(&data)
}


text:
var StateMachine = (function () {
    function StateMachine() {
    }
    var d = __define,c=StateMachine,p=c.prototype;
    //设置状态
    p.setState = function (e) {
        if (this.currentState != null) {
            this.currentState.onExit();
        }
        this.currentState = e;
        e.onEnter();
    };
    return StateMachine;
}());
egret.registerClass(StateMachine,'StateMachine');
var CharacterState = (function (_super) {
    __extends(CharacterState, _super);
    function CharacterState(character) {
        _super.call(this);
        this._character = character;
    }
    var d = __define,c=CharacterState,p=c.prototype;
    p.onEnter = function () { };
    p.onExit = function () { };
    return CharacterState;
}(StateMachine));
egret.registerClass(CharacterState,'CharacterState');
var CharacterIdleState = (function (_super) {
    __extends(CharacterIdleState, _super);
    function CharacterIdleState() {
        _super.apply(this, arguments);
    }
    var d = __define,c=CharacterIdleState,p=c.prototype;
    //进入时设置Character类的变量
    p.onEnter = function () {
        this._character._ifidle = true;
    };
    //离开时同理
    p.onExit = function () {
        this._character._ifidle = false;
    };
    return CharacterIdleState;
}(CharacterState));
egret.registerClass(CharacterIdleState,'CharacterIdleState');
var CharacterMoveState = (function (_super) {
    __extends(CharacterMoveState, _super);
    function CharacterMoveState() {
        _super.apply(this, arguments);
    }
    var d = __define,c=CharacterMoveState,p=c.prototype;
    p.onEnter = function () {
        this._character._ifmove = true;
    };
    p.onExit = function () {
        this._character._ifmove = false;
    };
    return CharacterMoveState;
}(CharacterState));
egret.registerClass(CharacterMoveState,'CharacterMoveState');
//# sourceMappingURL=StateMachine.js.map

redpajama_set_name: RedPajamaGithub


text:
{% assign image = nil %}

{% for data_image in site.data.images %}
  {% if data_image.source == include.image %}
    {% assign image = data_image %}
    {% break %}
  {% endif %}
{% endfor %}

{% if image %}
  {% if image.publisher == 'Fotolia' %}
    {% capture image_credit %}© {{ image.author }} - Fotolia.com{% endcapture %}
  {% elsif image.publisher == 'Flickr' %}
    {% capture image_credit %}© {{ image.author }} - Flickr.com{% endcapture %}
  {% elsif image.publisher == 'iStockphoto' %}
    {% capture image_credit %}©iStockphoto.com/{{ image.author }}{% endcapture %}
  {% elsif image.publisher == 'Unsplash' %}
    {% capture image_credit %}© {{ image.author }} - unsplash.com{% endcapture %}
  {% else %}
    {% capture image_credit %}{{ image.author }}{% endcapture %}
  {% endif %}

  Image Credits: {{ image_credit }}
{% endif %}


text:
/**
 * Line renderer
 */
var LineRenderer = Renderer.extend({
	init: function(context, matrix, material) {
		this._super(matrix);
		this.material = material;
		this.buffer = new LinesRenderBuffer(context);
	},

	/** Renders mesh geometry with material */
	onRender: function(context) {
		this.buffer.render(this.material.shader);
	},

	/** Renders only mesh geometry without material switches with given shader */
	onRenderGeometry: function(context, shader) {
		if (!this._cache) {
			this._cache = this.getDefaultUniforms(context);
		}
		else {
			this.getDefaultUniforms(context, this._cache);
		}
		shader.bindUniforms(this._cache);
		this.buffer.render(shader);
	}
});


text:
<?php

namespace app\models;

use Yii;
use yii\helpers\ArrayHelper;

/**
 * This is the model class for table "{{%course}}".
 *
 * @property integer $id
 * @property integer $program_id
 * @property string $code
 * @property string $title
 *
 * @property Program $program
 * @property FacultyCourse[] $facultyCourses
 * @property Notice[] $notices
 */
class Course extends \yii\db\ActiveRecord
{
    private static $_courses = [];

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%course}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['program_id', 'code', 'title'], 'required'],
            [['program_id'], 'integer'],
            [['code'], 'string', 'max' => 20],
            [['title'], 'string', 'max' => 150],
            [['code', 'title'], 'trim'],
            ['code', 'filter', 'filter' => 'strtoupper'],
            ['title', 'filter', 'filter' => 'ucwords'],
            ['code', 'unique'],
            [['program_id'], 'exist', 'skipOnError' => true, 'targetClass' => Program::className(), 'targetAttribute' => ['program_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'program_id' => Yii::t('app', 'Program ID'),
            'code' => Yii::t('app', 'Code'),
            'title' => Yii::t('app', 'Title'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getProgram()
    {
        return $this->hasOne(Program::className(), ['id' => 'program_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getFacultyCourses()
    {
        return $this->hasMany(FacultyCourse::className(), ['course_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getNotices()
    {
        return $this->hasMany(Notice::className(), ['course_id' => 'id']);
    }

    public static function getCourseList()
    {
        static::$_courses = ArrayHelper::map(static::find()->asArray()->all(), 'id', 'title');
        return static::$_courses;
    }
}


text:
/**
 * HabitacionController
 *
 * @description :: Server-side logic for managing Habitacions
 * @help        :: See http://sailsjs.org/#!/documentation/concepts/Controllers
 */

module.exports = {
    Buscar: function (req, res) {
        //console.log(req.param('roomType'));
        if (req.method == 'POST') {
            var params = req.allParams();
            //sails.log.info(params);

            sql = "select * from verHabitacionesDisponibles('" + params.fechaIngreso + "','" + params.fechaSalida + "','" + params.roomType + "','" + params.maxPrice + "')";

            Habitacion.query(sql, [], function (err, habitaciones) {
                if (err) {
                    return res.serverError(err);
                }

                /*return res.view('rooms', {
                    habitaciones: habitaciones
                });*/

                //sails.log('Bien');

                return res.ok(habitaciones.rows);
            });
        }
    },

    Seleccionadas: function (req, res) {
        if (req.method == 'POST') {
            var params = req.allParams();
            //sails.log.info(params);

            Habitacion.findOne({
                id_habitacion: params.id_habitacion
            }).exec(function (err, result) {
                if (err) {
                    return res.serverError(err);
                }

                return res.ok(result);
            });
        }
    }
};


text:
QIIME 1.9.1 Galaxy Wrapper
--------------------------

Note: Many of these tools output html files that will not display properly
unless sanitization is turned off in Galaxy. This can be done globally via the
`santize_all_html` option in `galaxy.ini` or on a per tool basis using the
`santize_whitelist_file` in `galaxy.ini`.


text:
/*
  ENGAGED TIME TRACKING

  This tracker works by listening to a series of events that indicate user
  interaction with a webpage. Many times per second, the tracker checks whether
  any of these events have been triggered in the last few seconds. It accumulates
  the time between positive checks, resulting in a number of "engaged seconds"
  with a fairly high time resolution. Every few seconds (on a separate timeout
  from the accumulator) another function validates the accumulator's value and
  makes a pixel request.
 */
(function() {
    var root = window.CONFIG,
        $ = root.$,
        util = root.util;

    root.onReady();

    // Allow publishers to disable engaged time pings all together
    if (typeof root.enableHeartbeats === "boolean" && !root.enableHeartbeats) {
        return;
    }

    var MIN_TIME_BETWEEN_HEARTBEATS = 1,  // 1 sec
        MAX_TIME_BETWEEN_HEARTBEATS = 15,  // 15 secs
        MIN_ACTIVE_TIMEOUT = 1,  // 1 sec
        MAX_ACTIVE_TIMEOUT = 60,  // 60 secs
        SAMPLE_RATE_SECONDS = 0.1,  // 100 milliseconds
        EVENT_NAMES = ["focus", "mousedown", "mouseup", "mousemove", "scroll",
                       "touchstart", "touchenter", "keyup", "keydown"];

    var secondsBetweenHeartbeats = 5.5;  // default, 5.5s
    // Allow integrators to configure secondsBetweenHeartbeats if, for example, they
    // wish to send fewer pixels for mobile devices
    if ($.isNumeric(root.secondsBetweenHeartbeats) &&
        root.secondsBetweenHeartbeats >= MIN_TIME_BETWEEN_HEARTBEATS &&
        root.secondsBetweenHeartbeats <= MAX_TIME_BETWEEN_HEARTBEATS) {
        secondsBetweenHeartbeats = root.secondsBetweenHeartbeats;
    }

    var activeTimeout = 5;  // default, 5 seconds
    if ($.isNumeric(root.activeTimeout) &&
        root.activeTimeout >= MIN_ACTIVE_TIMEOUT &&
        root.activeTimeout <= MAX_ACTIVE_TIMEOUT) {
        activeTimeout = root.activeTimeout;
    }

    var now = new Date().getTime();

    // keep track of how recently we saw the last event
    root._lastEvent = now;
    // time of the last sample, used for time accumulation
    root._lastSample = now;
    // total number of engaged seconds to report next
    root._engagedMs = 0;
    // externally visible indicator of engaged status
    root.isEngaged = true;
    // externally visible indicator of interacting status
    root.isInteracting = true;
    // maintain a focused property that indicates whether the document has focus
    root.focused = true;
    // externally visible indicator of whether a video is being tracked and is playing
    root.videoPlaying = false;

    // maintain a flag that indicates whether the window is currently focused
    $(document).on("show.visibility", function() {
        root.focused = true;
    });
    $(document).on("hide.visibility", function() {
        root.focused = false;
    });

    var _buildListener = function(event_name, callback) {
        if (window.addEventListener) {
            window.addEventListener(event_name, callback, false);
        } else {
            document.attachEvent("on" + event_name, callback);
        }
    };

    // trigger the activity timeout with any of EVENT_NAMES
    var registerEvent = function() {
        root._lastEvent = new Date().getTime();
    };
    for (var i = 0; i < EVENT_NAMES.length; i++) {
        _buildListener(EVENT_NAMES[i], registerEvent);
    }

    /*
     * Track embedded YouTube videos
     * https://developers.google.com/youtube/js_api_reference#Events
     */
    var YT_PLAYING = 1, YT_UNSTARTED = -1, YT_ENDED = 0, YT_PAUSED = 2;
    root.listenToYTVideoPlayer = function(player) {
        if (!$.isFunction(player["addEventListener"])) {
            return false;
        } else {
            console.log("Adding event listener to YT video player: " + player.getIframe().id);
            player.addEventListener("onStateChange", function(event) {
                if (event.data === YT_UNSTARTED || event.data === YT_ENDED ||
                    event.data === YT_PAUSED)
                {
                    root.videoPlaying = false;
                } else if (event.data === YT_PLAYING) {
                    root.videoPlaying = true;
                    registerEvent();
                }
            });
        }
    };

    /*
     * Every SAMPLE_RATE_SECONDS, increase the counter root._engagedMs
     * by the amount of time engaged measured since the last sample was taken.
     */
    var sample = function() {
        var currentTime = new Date().getTime();
        // define "interacting" as "it is currently less than activeTimeout seconds
        // since the last engagement event was triggered
        root.isInteracting = currentTime - root._lastEvent < activeTimeout * 1000;
        root.isEngaged = (root.isInteracting && root.focused) || root.videoPlaying;
        // accumulate the amount of engaged time since last heartbeat
        root._engagedMs += root.isEngaged ? (currentTime - root._lastSample) : 0;
        root._lastSample = currentTime;
    };
    window.setInterval(sample, SAMPLE_RATE_SECONDS * 1000);

    /*
     * Every secondsBetweenHeartbeats seconds, send a heartbeat and reset the
     * accumulator
     */
    var sendHeartbeat = function() {
        if (typeof root.enableHeartbeats === "undefined" ||
            (typeof root.enableHeartbeats === "boolean" && root.enableHeartbeats))
        {
            var engagedSecs = Math.round(root._engagedMs / 1000);
            if (engagedSecs > 0 && engagedSecs <= Math.round(secondsBetweenHeartbeats))
            {
                PARSELY.beacon.pixel.beacon({
                    date: new Date().toString(),
                    action: "heartbeat",
                    inc: engagedSecs,
                    url: PARSELY.lastRequest ? PARSELY.lastRequest.url : window.location.href,
                    urlref: PARSELY.lastRequest ? PARSELY.lastRequest.urlref : window.document.referrer
                });

                if ($.isFunction(root.onHeartbeat)) {
                    root.onHeartbeat(engagedSecs);
                }
            }
        }
        root._engagedMs = 0;
    };
    // every secondsBetweenHeartbeats, attempt to send a pixel
    window.setInterval(sendHeartbeat, secondsBetweenHeartbeats * 1000);
    _buildListener("beforeunload", sendHeartbeat);
}());


text:
import {
    invariant,
    warning,
    sprintf,
    isObject,
    isObjectEmpty,
    isNumeric,
    nullthrows,
    isBrowser,
    rangeMap,
} from '@adeira/js';

invariant(true, 'message');
invariant('true', 'message'); // $ExpectError

const calc = (value: number | undefined, operation: '*' | '+') => {
    invariant(value != null, 'Expected value to be defined');
    if (operation === '*') {
        return value * value;
    }
    return value + value;
};

warning(true, 'message');
warning('true', 'message'); // $ExpectError

sprintf('Oh, %s', 'yeah!');
sprintf('%j', {});
sprintf(1, {}); // $ExpectError

isObject({});
isObject(null);
isObject([]);

isObjectEmpty({});
isObjectEmpty(null);
isObjectEmpty(new Date());

isNumeric('42');
isNumeric(42);
isNumeric(null);

nullthrows(null);
nullthrows(1);
nullthrows('1');

isBrowser();

rangeMap<string>(5, i => i.toString());
rangeMap<number>(5, i => i.toString()); // $ExpectError
rangeMap<string>('5', i => i.toString()); // $ExpectError


text:
title: Because of Winn Dixie
age: 9 - 12 years
grade: 4 - 7
page_count: 208
publisher: Candlewick
language: English
isbn_10: "0763680869"
isbn_13: "978-0763680862"
dimensions: 5.2 x 0.5 x 7.7 inches
shipping_weight: 4
completed: true
animals:
  - dog
---

One summer's day, ten-year-old India Opal Buloni goes down to the local supermarket for some groceries – and comes home with a dog. But Winn-Dixie is no ordinary dog. It's because of Winn-Dixie that Opal begins to make friends. And it's because of Winn-Dixie that she finally dares to ask her father about her mother, who left when Opal was three. In fact, as Opal admits, just about everything that happens that summer is because of Winn-Dixie.


text:
$(function() {
	$('#register').on('click', function(e) {
		e.preventDefault();
		var username = $('#name').val();
		var password = $('#password').val();
		var email = $('#email').val();

		$.ajax({
			type: 'POST',
			url: '/register',
			data: JSON.stringify({ "username": username, "password": password, "email": email }),
			contentType: 'application/json',
			dataType: 'json',
			success: function() {
				self.location = '/event'
			}
		})
	});
});


text:
package jp.co.techmatrix.store.services.rest;

import java.util.List;

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import javax.transaction.Transactional;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jp.co.techmatrix.store.model.Book;
import jp.co.techmatrix.store.model.OrderLine;
import jp.co.techmatrix.store.model.User;
import jp.co.techmatrix.store.services.AbstractCart;

/**
 * RESTサービス
 *  + /cart/getbooks?title=<title>

 *  + /cart/get/book?id=<id>

 *  + /cart/add/book

 *  + /cart/delete/book?id=<id>
 * @author kosugi
 *
 */
@Named
@RequestScoped
@Produces(value = MediaType.APPLICATION_JSON + ";charset=UTF-8;")
@Path("/cart")
@Api(value = "/cart", produces = MediaType.APPLICATION_JSON + ";charset=UTF-8;")
public class CartResource extends AbstractCart{
	@GET
	@Path("/get/books")
	@ApiOperation(value = "指定したタイトルで本を検索します。", response = Book.class, responseContainer = "List")
	@Override
	public List<Book> getItemByTitle(@QueryParam("title") String title){
		return super.getItemByTitle(title);
	}

	@GET
	@Path("/get/book")
	@ApiOperation(value = "指定したidで本を検索します。", response = Book.class)
	@Override
	public Book getItemById(@QueryParam("id") int id){
		return super.getItemById(id);
	}

	@PUT
	@Path("/add/book")
	@ApiOperation(value = "指定した本を追加します。")
	@Override
	@Transactional
	public void addNewBook(Book book){
		super.addNewBook(book);
	}

	@DELETE
	@Path("/delete/book")
	@ApiOperation(value = "指定した本を削除します。")
	@Override
	public void deleteBook(@QueryParam("id") int id){
		super.deleteBook(id);
	}

	@Override
	public List<OrderLine> getAllRegister(int id){
		return null;
	}

	@PUT
	@ApiOperation(value = "指定したカートを追加します。")
	@Path("/add/register")
	@Override
	public void addRegister(List<OrderLine> register){
		super.addRegister(register);
	}

	@DELETE
	@Path("/delete/register")
	@Override
	public List<OrderLine> removeRegister(User user, @QueryParam("id") int id){
		return super.removeRegister(user, id);
	}

	@Override
	public String login(User user){
		return "";
	}
}


text:
package io.github.rcarlosdasilva.weixin.model.request.message;

import com.google.gson.annotations.SerializedName;

import io.github.rcarlosdasilva.weixin.common.ApiAddress;
import io.github.rcarlosdasilva.weixin.model.request.base.BasicWeixinRequest;

/**
 * 删除群发请求模型
 *
 * @author Dean Zhao
 */
public class MessageDeleteMassRequest extends BasicWeixinRequest {

  @SerializedName("msg_id")
  private String messageId;
  @SerializedName("article_idx")
  private int index;

  public MessageDeleteMassRequest() {
    this.path = ApiAddress.URL_MESSAGE_DELETE_MASS;
  }

  public void setMessageId(String messageId) {
    this.messageId = messageId;
  }

  public void setIndex(int index) {
    this.index = index;
  }

}