text:
<?php
/**
 * Piwik - Open source web analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 * @category Piwik
 * @package Piwik
 */

/**
 * Piwik_ScheduledTime_Monthly class is used to schedule tasks every month.
 *
 * @see Piwik_ScheduledTask
 * @package Piwik
 * @subpackage Piwik_ScheduledTime
 */
class Piwik_ScheduledTime_Monthly extends Piwik_ScheduledTime
{
    /**
     * Day of the week for scheduled time.
     *
     * @var int
     */
    private $dayOfWeek = null;

    /**
     * Week number for scheduled time.
     *
     * @var int
     */
    private $week = null;

    /**
     * @return int
     */
    public function getRescheduledTime()
    {
        $currentTime = $this->getTime();

        // Adds one month
        $rescheduledTime = mktime(date('H', $currentTime),
            date('i', $currentTime),
            date('s', $currentTime),
            date('n', $currentTime) + 1,
            1,
            date('Y', $currentTime)
        );

        $nextMonthLength = date('t', $rescheduledTime);

        // Sets scheduled day
        $scheduledDay = date('j', $currentTime);

        if ($this->day !== null) {
            $scheduledDay = $this->day;
        }

        if ($this->dayOfWeek !== null
            && $this->week !== null
        ) {
            $newTime = $rescheduledTime + $this->week * 7 * 86400;
            while (date("w", $newTime) != $this->dayOfWeek % 7) // modulus for sanity check
            {
                $newTime += 86400;
            }
            $scheduledDay = ($newTime - $rescheduledTime) / 86400 + 1;
        }

        // Caps scheduled day
        if ($scheduledDay > $nextMonthLength) {
            $scheduledDay = $nextMonthLength;
        }

        // Adjusts the scheduled day
        $rescheduledTime += ($scheduledDay - 1) * 86400;

        // Adjusts the scheduled hour
        $rescheduledTime = $this->adjustHour($rescheduledTime);

        return $rescheduledTime;
    }

    /**
     * @param int $_day the day to set, has to be >= 1 and < 32
     * @throws Exception if parameter _day is invalid
     */
    public function setDay($_day)
    {
        if (!($_day >= 1 && $_day < 32)) {
            throw new Exception ("Invalid day parameter, must be >=1 and < 32");
        }

        $this->day = $_day;
    }

    /**
     * Makes this scheduled time execute on a particular day of the week on each month.
     *
     * @param int $_day the day of the week to use, between 0-6 (inclusive). 0 -> Sunday
     * @param int $_week the week to use, between 0-3 (inclusive)
     * @throws Exception if either parameter is invalid
     */
    public function setDayOfWeek($_day, $_week)
    {
        if (!($_day >= 0 && $_day < 7)) {
            throw new Exception("Invalid day of week parameter, must be >= 0 & < 7");
        }

        if (!($_week >= 0 && $_week < 4)) {
            throw new Exception("Invalid week number, must be >= 1 & < 4");
        }

        $this->dayOfWeek = $_day;
        $this->week = $_week;
    }
}


text:
@echo off
echo Writing sample map to %1
java -cp .\target\monster-map-1.0-SNAPSHOT.jar questions.SimpleSerializationWrite %1
echo ======================================================================================
echo Reading sample map from %1
java -cp .\target\monster-map-1.0-SNAPSHOT.jar questions.SimpleSerializationRead %1
echo ======================================================================================
echo Done.

redpajama_set_name: RedPajamaGithub


text:
import React, { Component, PropTypes } from 'react';
import config from '../../config';

class Html extends Component {

  static propTypes = {
    title: PropTypes.string,
    description: PropTypes.string,
    css: PropTypes.string,
    body: PropTypes.string.isRequired,
    entry: PropTypes.string.isRequired,
    req: PropTypes.object
  };

  static defaultProps = {
    title: '',
    description: '',
  };

  trackingCode() {
    return ({ __html:
      `(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=` +
      `function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;` +
      `e=o.createElement(i);r=o.getElementsByTagName(i)[0];` +
      `e.src='https://www.google-analytics.com/analytics.js';` +
      `r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));` +
      `ga('create','${config.googleAnalyticsId}','auto');ga('send','pageview');`,
    });
  }

  render() {
    return (
      <html className="no-js" lang="">
      <head>
        <meta charSet="utf-8" />
        <meta httpEquiv="X-UA-Compatible" content="IE=edge" />
        <title>{this.props.title}</title>
        <meta name="description" content={this.props.description} />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <link rel="apple-touch-icon" href="apple-touch-icon.png" />
        <link rel="stylesheet" href="vender/materialize/css/materialize.min.css"/>
        <style id="css" dangerouslySetInnerHTML={{ __html: this.props.css }} />
      </head>
      <body>
        <div id="app" dangerouslySetInnerHTML={{ __html: this.props.body }} />
        <script src={this.props.entry}></script>
        <script dangerouslySetInnerHTML={this.trackingCode()} />
      </body>
      </html>
    );
  }

}

export default Html;


text:
function [cMap] = cMap(data, stat, endp, Fs, bg, rect)
%% cMap is the central function for creating conduction velocity maps
% [cMap] = cMap(data,stat,endp,Fs,bg,rect) calculates the conduction
% velocity map for a single action potential upstroke by fitting a
% polynomial and calculating the surface derivative to a pre-defined area
% of cmosData.  This area is specified by the vector rect.

% INPUTS
% data = cmos data (voltage, calcium, etc.) from the micam ultima system.
%
% stat = start of analysis (in msec)
%
% endp = end of analysis (in msec)
%
% Fs = sampling frequency
%
% bg = black and white background image from the CMOS camera.  This is a
% 100X100 pixel image from the micam ultima system. bg is stored in the
% handles structure handles.bg.
%
% rect = area of interest specified by getrect in Rhythm.m GUI

% OUTPUT
% cMap = conduction velocity map

% METHOD
% The method used for calculating conduction velocity is fully described by
% Bayly et al in "Estimation of Conduction Velocity Vecotr Fields from
% Epicardial Mapping Data".  Briefly, this function calculates the
% conduction velocity for a region of interest (ROI) for a single optical
% action potential.  First, an activation map is calculated for the ROI
% by identifying the time of maximum derivative of each ROI pixel.  Next, a
% third-order polynomial surface is fit to the activation map and the
% surface derivative of the fitted surface is calculated.  Finally, the x
% and y components of conduction velocity are calculated per pixel
% (pixel/msec).

% REFERENCES
% Bayly PV, KenKnight BH, Rogers JM, Hillsley RE, Ideker RE, Smith WM.
% "Estimation of COnduction Velocity Vecotr Fields from Epicardial Mapping
% Data". IEEE Trans. Bio. Eng. Vol 45. No 5. 1998.

% ADDITIONAL NOTES
% The conduction velocity vectors are highly dependent on the goodness of
% fit of the polynomial surface.  In the Balyly paper, a 2nd order polynomial
% surface is used.  We found this polynomial to be insufficient and thus increased
% the order to 3.  MATLAB's intrinsic fitting functions might do a better
% job fitting the data and should be more closely examined if velocity
% vectors look incorrect.

% RELEASE VERSION 1.0.1

% AUTHOR: Jacob Laughner (jacoblaughner@gmail.com)

%% Code
%% Find Activation Times for Polynomial Surface
stat = round(stat * Fs);
endp = round(endp * Fs);
actMap = zeros(size(data, 1), size(data, 2));
mask2 = zeros(size(data, 1), size(data, 2));
temp = data(:, :, stat:endp); % truncate data

% Re-normalize data in case of drift
temp = normalize_data(temp, Fs);

% identify channels that have been zero-ed out due to noise
mask = max(temp, [], 3) > 0;

% Remove non-connected artifacts
CC = bwconncomp(mask, 4);
numPixels = cellfun(@numel, CC.PixelIdxList);
[biggest, idx] = max(numPixels);
mask_id = CC.PixelIdxList{idx};
mask2(mask_id) = 1;

% Find First Derivative and time of maxium
temp2 = diff(temp, 1, 3); % first derivative
[max_der, max_i] = max(temp2, [], 3); % find location of max derivative

% Create Activation Map
actMap1 = max_i .* mask;
actMap1(actMap1 == 0) = nan;
offset1 = min(min(actMap1));
actMap1 = actMap1 - offset1 * ones(size(data, 1), size(data, 2));
actMap1 = actMap1 / Fs * 1000; %% time in ms

%% Find Conduction Velocity Map - Bayly Method
% Isolate ROI Specified by RECT
% rect = round(rect);
% temp = actMap1(rect(2):rect(2)+rect(4),rect(1):rect(1)+rect(3));
% Fit Activation Map with 3rd-order Polynomial
% cind = isfinite(temp);
% [x y]= meshgrid(rect(1):rect(1)+rect(3),rect(2):rect(2)+rect(4));
% x = reshape(x,[],1);
% y = reshape(y,[],1);
% z = reshape(temp,[],1);
% X = x(cind);
% Y = y(cind);
% Z = z(cind);
% A = [X.^3 Y.^3 X.*Y.^2 Y.*X.^2 X.^2 Y.^2 X.*Y X Y ones(size(X,1),1)];
% a = A\Z;
% Z_fit = A*a;
% Z_fit = reshape(Z_fit,size(cind));
% Find Gradient of Polynomial Surface
% [Tx Ty] = gradient(Z_fit);
% Calculate Conduction Velocity
% Vx = -Tx./(Tx.^2+Ty.^2);
% Vy = -Ty./(Tx.^2+Ty.^2);
% V = sqrt(Vx.^2 + Vy.^2);
% meanV = mean2(V)
% stdV = std2(V)
% meanAng = mean2(atand(Vy./Vx))
% stdAng = std2(atand(Vy./Vx))
% Plot Map
% cc = figure('Name','Activation Map with Velocity Vectors');
% Create Mask
% actMap_Mask = zeros(size(bg));
% actMap_Mask(rect(2):rect(2)+rect(4),rect(1):rect(1)+rect(3)) = 1;
% Build the Image
% G = real2rgb(bg, 'gray');
% J = real2rgb(actMap1, 'jet',[min(min(temp)) max(max(temp))]);
% A = real2rgb(actMap_Mask, 'gray');
% I = J .* A + G .* (1-A);
% image(I)
% hold on
% Overlay Conduction Velocity Vectors
% quiver(X,Y,reshape(Vx,[],1),reshape(Vy,[],1),3,'w')
% title('Activation Map with Velocity Vectors')
% axis image
% axis off
%
% cv = figure('Name','Conduction Velocity Map');
% Create Mask
% actMap_Mask = zeros(size(bg));
% actMap_Mask(rect(2):rect(2)+rect(4),rect(1):rect(1)+rect(3)) = 1;
% cvMap_Mask = zeros(size(bg));
% cvMap_Mask(rect(2):rect(2)+rect(4),rect(1):rect(1)+rect(3)) = V;
% Build the Image
% G = real2rgb(bg, 'gray');
% J = real2rgb(cvMap_Mask, 'jet',[min(min(V)) max(max(V))]);
% A = real2rgb(actMap_Mask, 'gray');
% I = J .* A + G .* (1-A);
% subplot(121)
% image(I)
% axis off
% axis image
% subplot(122)
% imagesc(V);colormap jet;colorbar
% axis image
% axis off
% title('Conduction Velocity Magnitude')

%% Find Conduction Velocity Map - Efimov Method
% Fit Activation Map with New Surface based on Kernel Smoothing
cind = isfinite(actMap1);
[x, y] = meshgrid(1:size(data, 2), 1:size(data, 1));
x = reshape(x, [], 1);
y = reshape(y, [], 1);
z = reshape(actMap1, [], 1);
X = x(cind);
Y = y(cind);
k_size = 3;
h = fspecial('average', [k_size, k_size]);
Z_fit = filter2(h, actMap1);
% Remove Edge Effect Introduced from Kernel
seD = strel('diamond', k_size - 2);
mask = imerode(cind, seD);
mask(1, :) = 0;
mask(end, :) = 0;
mask(:, 1) = 0;
mask(:, end) = 0;
Z = Z_fit .* mask;
Z(Z == 0) = nan;
% Find Gradient of Polynomial Surface
[Tx, Ty] = gradient(Z);
% Calculate Conduction Velocity
Vx = Tx ./ (Tx.^2 + Ty.^2);
Vy = -Ty ./ (Tx.^2 + Ty.^2);
V = sqrt(Vx.^2 + Vy.^2);
rect = round(rect);
temp_Vx = Vx(rect(2):rect(2) + rect(4), rect(1):rect(1) + rect(3));
temp_Vy = Vy(rect(2):rect(2) + rect(4), rect(1):rect(1) + rect(3));
temp_V = V(rect(2):rect(2) + rect(4), rect(1):rect(1) + rect(3));
medV = median(median(temp_V(isfinite(temp_V))))
stdV = std2(temp_V(isfinite(temp_V)))
medAng = median(median(atan2(temp_Vy(isfinite(temp_Vy)), temp_Vx(isfinite(temp_Vy))) .* 180 / pi))
stdAng = std2(atan2(temp_Vy(isfinite(temp_Vy)), temp_Vx(isfinite(temp_Vy))) .* 180 / pi)
num_vectors = numel(temp_V(isfinite(temp_V)))
% Plot Results
cv_wholeheart = figure('Name', 'Whole Heart Conduction Velocity');
contourf(flipud(actMap1), (endp -stat) / 2, 'LineColor', 'k')
title('Whole Heart Conduction Velocity with Activation')
colormap bone
axis image
axis off
colorbar
hold on
Y_plot = size(data, 1) + 1 - y(isfinite(Z));
X_plot = x(isfinite(Z));
Vx_plot = Vx(isfinite(Z));
Vx_plot(abs(Vx_plot) > 5) = 5 .* sign(Vx_plot(abs(Vx_plot) > 5));
Vy_plot = Vy(isfinite(Z));
Vy_plot(abs(Vy_plot) > 5) = 5 .* sign(Vy_plot(abs(Vy_plot) > 5));
quiver(X_plot, Y_plot, Vx_plot, Vy_plot, 3, 'r')
rect_plot = [rect(1), (size(data, 1) + 1 - rect(2) - rect(4)), rect(3), rect(4)];
rectangle('Position', rect_plot, 'EdgeColor', 'c')


text:
/**
 * Tests OOP tests
 * @author Niko Ni (bluepspower@163.com)
 * @create 2010-05-25
 * @update 2010-06-25
 */
(function() {

    // TestSuite for OOP tests
    new Ext.test.TestSuite({
        name : 'OOP TestSuite',

        items : [{
            name : 'OOP Tests',

            testExtend : function() {
				var firedbase = false;
				var firedextended = false;

				var Base = function() {
					//console.log('Base Constructor executed');
					arguments.callee.superclass.constructor.apply(this, arguments);

					// bind by string in order to allow the subclass
					this.on('testStringFn', Y.bind('base', this));
				};
				Y.extend(Base, Y.EventTarget, {
					base: function() {
						//console.log('base function');
						firedbase = true;
					}
				});

				var Extended = function() {
					//console.log('Extended Constructor executed');
					arguments.callee.superclass.constructor.apply(this, arguments);
				};
				Y.extend(Extended, Base, {
					base: function() {
						//console.log('extended function');
						firedextended = true;
					}
				});

				var b = new Extended();
				b.fire('testStringFn', 1, 2);

				Y.Assert.isFalse(firedbase);
				Y.Assert.isTrue(firedextended);
            },

			testMerge : function() {
				Object.prototype.foo = 'hello';

				var o1 = {one: 'one'},
					o2 = {two: 'two'},
					o3 = {two: 'twofromthree', three: 'three'},
					o4 = {one: 'one', two: 'twofromthree', three: 'three'};

				var o123 = Y.merge(o1, o2, o3);
				Y.ObjectAssert.areEqual(o123, o4);
				Y.Assert.areEqual(o123.two, o4.two);

				Y.Assert.isFalse(o123.hasOwnProperty(foo), 'prototype properties added to Object should not be iterable');
			}
        }]
    });

})();


text:
window.addEventListener("load", e => {
    const content = document.getElementById("content");
    questions.forEach(function(question, index) {
        console.log(`DEBUG: question ${index}: ${question.statement}`);
        console.log(`DEBUG: answer: ${question.answer}`);

        // create a block to contain the question/answer
        const questionAnswerBlock = document.createElement("p"); // Create an "li" element
        questionAnswerBlock.id = `block${index}`;

        // question
        const q = document.createElement("div");
        q.innerHTML = `<b>Question ${index+1}:</b> <i>${question.statement}</i>`;
        questionAnswerBlock.appendChild(q);

        const a = document.createElement("div");

        // create a button to conceal the answer until clicked...
        var showButton = document.createElement('button');
        showButton.id = index;
        showButton.textContent = 'Show Answer';
        showButton.className = 'showButton';
        showButton.addEventListener("click", e => {
            // reveal the answer when the user clicks on the button
            console.log(`DEBUG:: Event type: ${e.type}, target: ${e.target.id}, targetParentNode: ${e.target.parentNode}`);

            // show answer
            a.innerHTML = `${question.answer}`;
            questionAnswerBlock.appendChild(a);

            // delete button
            e.target.parentNode.removeChild(e.target);
        }, this);
        questionAnswerBlock.appendChild(showButton);

        // finally, append the container questionAnswerBlock to the page content
        content.appendChild(questionAnswerBlock);
    });
});


text:
/*
 (c) 2014 Glen Joseph Fernandes
 glenjofe at gmail dot com

 Distributed under the Boost Software
 License, Version 1.0.
 http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_HPP
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_HPP

#include <boost/align/detail/min_size.hpp>
#include <boost/align/detail/offset_object.hpp>

namespace boost {
    namespace alignment {
        namespace detail {
            template<class T>
            struct alignment_of
                : min_size<sizeof(T),
                    sizeof(offset_object<T>) - sizeof(T)>::type {
            };
        }
    }
}

#endif