text:
package org.qi4j.library.shiro.domain.permissions;

import org.qi4j.api.entity.EntityBuilder;
import org.qi4j.api.injection.scope.Structure;
import org.qi4j.api.mixin.Mixins;
import org.qi4j.api.service.ServiceComposite;
import org.qi4j.api.unitofwork.UnitOfWork;
import org.qi4j.api.unitofwork.UnitOfWorkFactory;

@Mixins( RoleFactory.Mixin.class )
public interface RoleFactory
        extends ServiceComposite
{

    Role create( String name, Iterable<Permission> permissions );

    abstract class Mixin
            implements RoleFactory
    {

        @Structure
        private UnitOfWorkFactory uowf;

        public Role create( String name, Iterable<Permission> permissions )
        {
            UnitOfWork uow = uowf.currentUnitOfWork();
            EntityBuilder<Role> roleBuilder = uow.newEntityBuilder( Role.class );
            Role role = roleBuilder.instance();
            role.name().set( name );
            for ( Permission eachPermission : permissions ) {
                role.permissions().add( eachPermission );
            }
            return roleBuilder.newInstance();
        }

    }

}


text:
(function(ng){
	"use strict";

	ng
	.module("angular-autowrap-internal")
	.factory("autowrapLinker", [
		"$compile",
		"autowrapConfig",
		"autowrapLinkerHelper",
		"autowrapCustomPropertyHelper",
		"autowrapTemplateProvider",
		"autowrapUtility",
		"validationMessagePropertyPrefix",
		function($compile, providedConfig, linkerHelper, customPropertyHelper, templateProvider, utility, validationMessagePropertyPrefix){

			return {
				init: function(scope, element, attrs, formCtrl, modelCtrl){
					// set custom object properties
					var injectedCustomProperties = {};
					ng.forEach(attrs, function(val, key){
						if(customPropertyHelper.isCustomProperty(key)){
							injectedCustomProperties[customPropertyHelper.getCustomPropertyName(key)] = val;
						}
					});
					ng.extend(scope.custom, injectedCustomProperties);

					// transcluding(!)...
					var config = ng.extend({}, providedConfig, scope.config);
					if(ng.isDefined(attrs.autowrapNoTrack)){
						config.noTrack = true;
					}
					var template = templateProvider.get(scope.templateFor || element[0].tagName, scope.theme);
					var compiledTemplate = ng.element($compile(template)(scope));
					element.after(compiledTemplate);
					var inputPlaceHolder = compiledTemplate.find("placeholder");
					inputPlaceHolder.after(element);
					inputPlaceHolder.remove();

					if(config.noTrack === true){
						return;
					}

					var elementName = element[0].name;

					// defense
					if(!elementName){
						throw "The element must have a name attribute for the validation to work.";
					}

					if(formCtrl === null){
						throw "The element, applied 'autowrap' directive, must be placed inside form (or, ngForm) to work for validation messages." +
                              "\nIf this is not a form element that needs tracking of validation status, just add 'autowrap-no-track' property to the element.";
					}

					if(typeof scope.validators === "object" && utility.hasAnyProperty(scope.validators)){
						if(modelCtrl === null){
							throw "To use custom validators with 'autowrap', the element must have ngModel directive applied to it.";
						}
						else{
							ng.forEach(scope.validators, function(validationFunction, validationName){
								modelCtrl.$validators[validationName] = validationFunction;
							});
						}
					}

					// set watches
					linkerHelper.setWatch(scope, formCtrl, elementName, "$dirty", "_dirty");

					linkerHelper.setWatch(scope, formCtrl, elementName, "$valid", "_valid", function(valid){
						if(valid){
							scope._message = "";
						}
					});

					linkerHelper.setWatch(scope, formCtrl, elementName, "$invalid", "_invalid", function(invalid) {
						if(invalid) {
							var errorTypes =
								linkerHelper.getErrorTypes(formCtrl[elementName])
								.map(function(a){
									return utility.getCamelCasedAttributeName(a, validationMessagePropertyPrefix);
								});

							var availableErrorMessages =
								utility.filter(errorTypes, function(attributeName){
									return ng.isDefined(attrs[attributeName]);
								})
								.map(function(attributeName){
									return attrs[attributeName];
								});

							scope._message = availableErrorMessages.length ? availableErrorMessages[0] : "Invalid.";
						}
					});

					if(config.applyStatesToInput === true){
						linkerHelper.enableAddingStateClassesToInputElement(scope, element, config);
					}
				}
			};
		}
	]);

})(angular);

redpajama_set_name: RedPajamaGithub


text:
namespace dfmc {
namespace adapter
{
  class LogAdapter : private dfmc::Noncopyable
  {
  public:
    LogAdapter();
    ~LogAdapter();

    void WriteLine(const std::string& str);
  };

}}

#endif


text:
<?php

namespace CImrie\Odm\Tests\Unit\Extensions;

use CImrie\ODM\Extensions\ExtensionManager;
use CImrie\ODM\Extensions\Timestampable\TimestampableExtension;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\EventManager;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
use Doctrine\ODM\MongoDB\DocumentManager;
use Gedmo\Timestampable\TimestampableListener;
use Mockery as m;

class ExtensionManagerTest extends \PHPUnit_Framework_TestCase
{
    public function test_it_registers_an_extension()
    {
        $managerRegistry = m::mock(ManagerRegistry::class);
        $config = new \Doctrine\ODM\MongoDB\Configuration();
        $config->setHydratorDir(__DIR__);
        $config->setHydratorNamespace('ns');

        $config->setProxyDir(__DIR__);
        $config->setProxyNamespace('nsproxy');

        $config->setMetadataDriverImpl(new MappingDriverChain());

        $eventManager = new EventManager();
        $defaultManager = DocumentManager::create(null, $config, $eventManager);

        $managerRegistry->shouldReceive('getManagers')->andReturn(
            [$defaultManager]
        );

        $extensionManager = new ExtensionManager($managerRegistry);
        $extensionManager->register(new TimestampableExtension());

        $this->assertInstanceOf(TimestampableListener::class, array_first($eventManager->getListeners("prePersist")));
    }
}


text:
package com.intellij.execution.jshell.protocol;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import java.io.*;
import java.util.function.Consumer;

/**
 * @author Eugene Zhuravlev
 */
public class MessageReader<T> extends Endpoint {
  private final BufferedReader myIn;
  private final JAXBContext myContext;

  public MessageReader(InputStream input, Class<T> msgType) throws Exception {
    myIn = new BufferedReader(new InputStreamReader(input));
    myContext = JAXBContext.newInstance(msgType);
  }

  public T receive(final Consumer<? super String> unparsedOutputSink) throws IOException {
    while (true) {
      String line = myIn.readLine();
      if (line == null) {
        return null;
      }
      if (MSG_BEGIN.equals(line)) {
        final StringBuilder buf = new StringBuilder();
        for (String body = myIn.readLine(); !MSG_END.equals(body.trim()); body = myIn.readLine()) {
          buf.append(body).append("\n");
        }
        try {
          //noinspection unchecked
          return (T)myContext.createUnmarshaller().unmarshal(new StringReader(buf.toString()));
        }
        catch (JAXBException e) {
          throw new IOException(e);
        }
      }
      else {
        unparsedOutputSink.accept(line + "\n");
      }
    }
  }

}


text:
package cn.itcast_02;

public class DirectionDemo {
	public static void main(String[] args) {
		Direction d = Direction.FRONT;
		System.out.println(d); // FRONT
		// public String toString()返回枚举常量的名称,它包含在声明中。
		System.out.println("-------------");
		Direction2 d2 = Direction2.FRONT;
		System.out.println(d2);
		System.out.println(d2.getName());
		System.out.println("-------------");
		Direction3 d3 = Direction3.FRONT;
		System.out.println(d3);
		System.out.println(d3.getName());
		d3.show();
		System.out.println("--------------");

		Direction3 dd = Direction3.FRONT;
		dd = Direction3.LEFT;

		switch (dd) {
		case FRONT:
			System.out.println("你选择了前");
			break;
		case BEHIND:
			System.out.println("你选择了后");
			break;
		case LEFT:
			System.out.println("你选择了左");
			break;
		case RIGHT:
			System.out.println("你选择了右");
			break;
		}
	}
}


text:
<sse-header></sse-header>

<div class="container main-content">
  <router-outlet></router-outlet>
</div>

<sse-footer></sse-footer>


text:
package com.aayaffe.sailingracecoursemanager.initializinglayer.RaceCourseDescription;

/**
 * Avi Marine Innovations - www.avimarine.in
 *
 * Created by Amit Y. on 29/12/2016.
 */
public enum GateOption {
    GATABLE, NEVER_GATABLE, ALWAYS_GATED
}


text:
/* globals
=====================================================================*/
var center = view.bounds.center;
var grid, blank, deck, holes, deckDims, blankDims;
var deckster = {
    width: 8.5, // inches
    height: 30, // inches
    wheelBase: 14, // inches
    xSymmetry: true,
    isSmooth: false,
    hitOptions: {
        segments: true,
        stroke: false,
        fill: false,
        tolerance: 10
    }
};
var colors = {
    disabled: new Color(1, 0, 0),
    enabled: new Color(0, 1, 0),
    grid: new Color(1, 0, 0, 0.25),
    blank: new Color(0.13, 0.59, 0.95, 0.75),
    deck: new Color(0, 1, 0, 0.5),
    holes: 'black',
    transparent: new Color(1, 1, 1, 0),
    grey_50: new Color(0, 0, 0, 0.25)
};

/* update globals for current view
---------------------------------------------------------------------*/
console.log('you can change the default width, height, and wheel base with a url query:');
console.log('e.g. deckster.christiangimber.com/?width=9.5&height=35&wheelBase=13');

var query = QueryStringToJSON();
console.log("user defined values:", query);

// update the corresponding values and log to the console
if (query.width)
    deckster.width = query.width;
if (query.height)
    deckster.height = query.height;
if (query.wheelBase)
    deckster.wheelBase = query.wheelBase;

deckster.scalar = 500 / deckster.height; // pixels : inches
deckster.height *= deckster.scalar;
deckster.width *= deckster.scalar;
deckster.wheelBase *= deckster.scalar;

init();

/* init
---------------------------------------------------------------------*/
function init() {
    grid = newGrid(50, colors.grid);
    blank = newBlank(deckster.width, deckster.height);
    deck = newDeck(deckster.width, deckster.height);
}

/* draw grid
---------------------------------------------------------------------*/
function newGrid(interval, color) {
    var g = new Group();
    g.name = 'grid';

    var gDist = 50; // default distance between grid lines
    if (interval) gDist = interval;

    var gColor = new Color(0, 0, 255, 0.25); // default color
    if (color) gColor = new Color(color);

    // create x lines
    for (var i = 1; i * gDist < view.size.width; i++) {
        var dX = i * gDist;
        var lineX = new Path.Line({
            from: [dX, 0],
            to: [dX, view.bounds.height],
            strokeColor: gColor,
            dashArray: [5, 5]
        });
        g.addChild(lineX);
    }
    // create y lines
    for (var j = 1; j * gDist < view.size.height; j++) {
        var dY = j * gDist;
        var lineY = new Path.Line({
            from: [0, dY],
            to: [view.bounds.width, dY],
            strokeColor: gColor,
            dashArray: [5, 5]
        });
        g.addChild(lineY);
    }

    return g;
}

/* draw blank
---------------------------------------------------------------------*/
function newBlank(w, h) {
    var b = new Path.Rectangle({
        name: 'blank',
        position: center,
        size: [w, h],
        // dashArray: [5, 5],
        strokeColor: colors.grey_50,
        strokeWidth: 2,
        fillColor: colors.transparent
    });

    b.insertSegment(0, center + [0, h / 2]);
    b.insertSegment(2, center + [-w / 2, h / 4]);
    b.insertSegment(3, center + [-w / 2, 0]);
    b.insertSegment(4, center + [-w / 2, -h / 4]);
    b.insertSegment(6, center + [0, -h / 2]);
    b.insertSegment(8, center + [w / 2, -h / 4]);
    b.insertSegment(9, center + [w / 2, 0]);
    b.insertSegment(10, center + [w / 2, h / 4]);

    blankDims = displayDims(b, colors.blank);

    // hide dims when not moused over
    blankDims.visible = false;
    b.onMouseLeave = function() {
        blankDims.visible = false;
    };

    return b;
}

/* draw deck
---------------------------------------------------------------------*/
function newDeck(w, h) {
    var d = new Path({
        name: 'deck',
        strokeColor: 'black',
        strokeWidth: 2,
        fillColor: colors.deck
    });

    // draw the left side of the deck
    d.add(center + [0, h / 2]);
    d.add(center + [-w / 2, h / 2]);
    d.add(center + [-w / 2, h / 4]);
    d.add(center + [-w / 2, 0]);
    d.add(center + [-w / 2, -h / 4]);
    d.add(center + [-w / 2, -h / 2]);
    d.add(center + [0, -h / 2]);

    if (deckster.xSymmetry) {
        // randomly shift each point on the left side of deck
        for (var i = 0; i < d.segments.length; i++) {
            if (i === 0) // don't shift the bottom point in the x direction or beyond the blank
                d.segments[i].point += new Point(0, -getRandom(0, h / 8));
            else if (i === 1) // don't shift the bottom right point beyond the blank
                d.segments[i].point += new Point(getRandom(0, w / 4), -getRandom(0, h / 8));
            else if (i === d.segments.length - 2) // don't shift the top left point beyond the blank
                d.segments[i].point += new Point(getRandom(0, w / 4), getRandom(0, h / 8));
            else if (i === d.segments.length - 1) // don't shift the top point in the x direction or beyond the blank
                d.segments[i].point += new Point(0, getRandom(0, h / 8));
            else
                d.segments[i].point += new Point(getRandom(0, w / 4), getRandom(-h / 8, h / 8));
        }
        // reflect along y-axis
        var rtSide = d.clone();
        rtSide.scale(-1, 1, rtSide.bounds.topRight);
        d.join(rtSide);
    } else {
        // draw the right side of the deck
        d.add(center + [w / 2, -h / 2]);
        d.add(center + [w / 2, -h / 4]);
        d.add(center + [w / 2, 0]);
        d.add(center + [w / 2, h / 4]);
        d.add(center + [w / 2, h / 2]);
        d.closePath();

        // randomly shift each point on the deck
        for (var i = 0; i < d.segments.length; i++)
            d.segments[i].point += new Point(getRandom(-w / 8, w / 8), getRandom(-h / 8, h / 8));

        // if not inside the blank, scale to fit
        if (!d.isInside(blank.bounds)) {
            var scalarX = w / d.bounds.width;
            var scalarY = h / d.bounds.height;
            d.scale(scalarX, scalarY);
        }
    }
    d.position = center;

    if (deckster.isSmooth)
        d.smooth();

    holes = newMountHoles(deckster.wheelBase);
    // if (holes.bounds.height < d.bounds.height) {
    //     holes.pivot = holes.bounds.bottomCenter;
    //     // holes.position = d.bounds.bottomCenter - [0, getRandom(0.75, 1) * (20 * deckster.scalar - deckster.wheelBase)];
    //     holes.position = d.bounds.bottomCenter - [0, (20 * deckster.scalar - deckster.wheelBase)];
    // }
    // d.subtract(holes);

    if (deckDims)
        deckDims.remove();
    deckDims = displayDims(d);
    checkDeckDims(d, deckDims);

    // hide dims when not moused over
    deckDims.visible = false;
    d.onMouseLeave = function() {
        deckDims.visible = false;
    };

    return d;
}

/* draw mount holes
---------------------------------------------------------------------*/
function newMountHoles(wheelBase) {
    var mWidth = 1.625 * deckster.scalar;
    var mHeight = 2.125 * deckster.scalar;
    var holeRadius = 0.10 * deckster.scalar;

    var mRect = new Path.Rectangle(center, [mWidth, mHeight]);
    var hole1 = new Path.Circle(mRect.bounds.topLeft, holeRadius);
    var hole2 = new Path.Circle(mRect.bounds.topRight, holeRadius);
    var hole3 = new Path.Circle(mRect.bounds.bottomLeft, holeRadius);
    var hole4 = new Path.Circle(mRect.bounds.bottomRight, holeRadius);

    var mTop = new Group({
        name: 'mount_top',
        children: [hole1, hole2, hole3, hole4],
        position: center - [0, (wheelBase + mHeight) / 2]
    });
    var mBottom = mTop.clone();
    mBottom.name = 'mount_bottom';
    mBottom.position = center + [0, (wheelBase + mHeight) / 2];

    mGroup = new Group({
        name: 'mount_group',
        children: [mTop, mBottom],
        fillColor: colors.holes,
        strokeColor: colors.holes
    });

    return mGroup;
}

/* draw height / width dimensions
---------------------------------------------------------------------*/
function displayDims(item, color) {
    // remove any old dims for this item
    if (project.activeLayer.children[item.name + '_dims'])
        project.activeLayer.children[item.name + '_dims'].remove();

    var wInches = truncateDecimals(item.bounds.width / deckster.scalar, 2) + ' in';
    var hInches = truncateDecimals(item.bounds.height / deckster.scalar, 2) + ' in';

    var dimsMarginX = 200;
    var dimsMarginY = 100;
    var dimsPadding = 50;

    var dimsColor = colors.enabled;
    if (color) dimsColor = color;

    // create width items
    var item_bottomLeft, item_bottomRight;

    item_bottomLeft = item.bounds.bottomLeft + [0, dimsPadding];
    item_bottomRight = item.bounds.bottomRight + [0, dimsPadding];

    var wLine = new Path.Line({
        name: 'line_w',
        from: item_bottomLeft,
        to: item_bottomRight,
        strokeColor: dimsColor,
        strokeWidth: 2
    });

    var wHandles = newHandles(wLine);

    var wText = new PointText({
        name: 'text_w',
        content: wInches,
        point: wLine.bounds.bottomCenter + [0, 35],
        justification: 'center',
        fontFamily: 'audimat',
        fontSize: 20,
        fillColor: dimsColor
    });

    var wGroup = new Group({
        name: 'width',
        children: [wLine, wHandles, wText]
    });

    // create height items
    var item_topLeft, item_bottomLeft;

    item_topLeft = item.bounds.topLeft + [-dimsPadding, 0];
    item_bottomLeft = item.bounds.bottomLeft + [-dimsPadding, 0];

    var hLine = new Path.Line({
        name: 'line_h',
        from: item_topLeft,
        to: item_bottomLeft,
        strokeColor: dimsColor,
        strokeWidth: 2
    });

    var hHandles = newHandles(hLine);

    var hText = new PointText({
        name: 'text_h',
        content: hInches,
        point: hLine.bounds.leftCenter + [-25, 0],
        justification: 'right',
        fontFamily: 'audimat',
        fontSize: 20,
        fillColor: dimsColor
    });

    var hGroup = new Group({
        name: 'height',
        children: [hLine, hHandles, hText]
    });

    var dimsGroup = new Group({
        name: item.name + '_dims',
        children: [wGroup, hGroup]
    });

    return dimsGroup;
}

/* check deck dimensions and update the colors
---------------------------------------------------------------------*/
function checkDeckDims(deckItem, deckDims) {
    if (!deckItem.isInside(blank.bounds)) {
        console.error("OH SHIZAH: this deck won't fit on your blank");

        var wGroup = deckDims.children['width'];
        var wLine = wGroup.children['line_w'];
        var hGroup = deckDims.children['height'];
        var hLine = hGroup.children['line_h'];

        // check width
        if (deckItem.bounds.left < blank.bounds.left || deckItem.bounds.right > blank.bounds.right) {
            wLine.strokeColor = colors.disabled;
            wGroup.children['line_w_handles'].strokeColor = colors.disabled;
            wGroup.children['text_w'].fillColor = colors.disabled;
        }
        // check height
        if (deckItem.bounds.top < blank.bounds.top || deckItem.bounds.bottom > blank.bounds.bottom) {
            hLine.strokeColor = colors.disabled;
            hGroup.children['line_h_handles'].strokeColor = colors.disabled;
            hGroup.children['text_h'].fillColor = colors.disabled;
        }
    }
}

/* draw handles for a line item
---------------------------------------------------------------------*/
function newHandles(line) {
    var h1, h2, margin;
    if (line.bounds.width > line.bounds.height) { // handles along x-axis
        h1 = new Path.Line({
            name: line.name + '_handle1',
            from: line.firstSegment.point + [0, -10],
            to: line.firstSegment.point + [0, 10],
            strokeColor: line.strokeColor,
            strokeWidth: line.strokeWidth
        });
        h2 = new Path.Line({
            name: line.name + '_handle2',
            from: line.lastSegment.point + [0, -10],
            to: line.lastSegment.point + [0, 10],
            strokeColor: line.strokeColor,
            strokeWidth: line.strokeWidth
        });
    } else { // handles along y-axis
        h1 = new Path.Line({
            name: line.name + '_handle1',
            from: line.firstSegment.point + [-10, 0],
            to: line.firstSegment.point + [10, 0],
            strokeColor: line.strokeColor,
            strokeWidth: line.strokeWidth
        });
        h2 = new Path.Line({
            name: line.name + '_handle2',
            from: line.lastSegment.point + [-10, 0],
            to: line.lastSegment.point + [10, 0],
            strokeColor: line.strokeColor,
            strokeWidth: line.strokeWidth
        });
    }
    hGroup = new Group({
        name: line.name + '_handles',
        children: [h1, h2]
    });

    return hGroup;
}

/* GUI
=====================================================================*/
var btn_margin = 33;

/* title
---------------------------------------------------------------------*/
var title_t = new PointText({
    content: '– deckster v1.0 –',
    point: view.bounds.topCenter + [0, 55],
    justification: 'center',
    fontFamily: 'audimat-bold',
    fontSize: 20,
    fillColor: 'black'
});

/* xSymmetry button
---------------------------------------------------------------------*/
var xSymmetry_t = new PointText({
    content: 'x-symmetry',
    point: view.bounds.topLeft + [50, 55],
    justification: 'left',
    fontFamily: 'audimat',
    fontSize: 20,
    fillColor: 'black'
});
var xSymmetry_bg = new Path.Rectangle({
    position: xSymmetry_t.position,
    size: [xSymmetry_t.bounds.width + 30, xSymmetry_t.bounds.height + 10],
    strokeColor: 'black',
    strokeWidth: 2
});
var xSymmetry_shadow = xSymmetry_bg.clone();
xSymmetry_shadow.position += [3, 3];
xSymmetry_shadow.fillColor = 'black';

if (deckster.xSymmetry)
    xSymmetry_bg.fillColor = colors.enabled;
else
    xSymmetry_bg.fillColor = colors.disabled;

var xSymmetry_btn = new Group([xSymmetry_shadow, xSymmetry_bg, xSymmetry_t]);

/* toggle blank button
---------------------------------------------------------------------*/
var toggleBlank_t = new PointText({
    content: 'toggle blank',
    point: view.bounds.topLeft + [50, 185],
    justification: 'left',
    fontFamily: 'audimat',
    fontSize: 20,
    fillColor: 'black'
});
var toggleBlank_bg = new Path.Rectangle({
    position: toggleBlank_t.position,
    size: [toggleBlank_t.bounds.width + 30, toggleBlank_t.bounds.height + 10],
    fillColor: 'white',
    strokeColor: 'black',
    strokeWidth: 2
});
var toggleBlank_shadow = toggleBlank_bg.clone();
toggleBlank_shadow.position += [3, 3];
toggleBlank_shadow.fillColor = 'black';

var toggleBlank_btn = new Group([toggleBlank_shadow, toggleBlank_bg, toggleBlank_t]);

/* toggle grid button
---------------------------------------------------------------------*/
var toggleGrid_t = new PointText({
    content: 'toggle grid',
    point: view.bounds.topLeft + [50, 250],
    justification: 'left',
    fontFamily: 'audimat',
    fontSize: 20,
    fillColor: 'black'
});
var toggleGrid_bg = new Path.Rectangle({
    position: toggleGrid_t.position,
    size: [toggleGrid_t.bounds.width + 30, toggleGrid_t.bounds.height + 10],
    fillColor: 'white',
    strokeColor: 'black',
    strokeWidth: 2
});
var toggleGrid_shadow = toggleGrid_bg.clone();
toggleGrid_shadow.position += [3, 3];
toggleGrid_shadow.fillColor = 'black';

var toggleGrid_btn = new Group([toggleGrid_shadow, toggleGrid_bg, toggleGrid_t]);

/* newDeck button
---------------------------------------------------------------------*/
var newDeck_t = new PointText({
    content: 'new deck',
    point: view.bounds.bottomLeft + [90, -45],
    justification: 'center',
    fontFamily: 'audimat',
    fontSize: 20,
    fillColor: 'black'
});
var newDeck_bg = new Path.Rectangle({
    position: newDeck_t.position,
    size: [newDeck_t.bounds.width + 30, newDeck_t.bounds.height + 10],
    fillColor: 'white',
    strokeColor: 'black',
    strokeWidth: 2
});
var newDeck_shadow = newDeck_bg.clone();
newDeck_shadow.position += [3, 3];
newDeck_shadow.fillColor = 'black';

var newDeck_btn = new Group([newDeck_shadow, newDeck_bg, newDeck_t]);

/* flip button
---------------------------------------------------------------------*/
var flip_t = new PointText({
    content: 'flip',
    point: view.bounds.bottomLeft + [195, -45],
    justification: 'left',
    fontFamily: 'audimat',
    fontSize: 20,
    fillColor: 'black'
});
var flip_bg = new Path.Rectangle({
    position: flip_t.position,
    size: [flip_t.bounds.width + 30, flip_t.bounds.height + 10],
    fillColor: 'white',
    strokeColor: 'black',
    strokeWidth: 2
});
var flip_shadow = flip_bg.clone();
flip_shadow.position += [3, 3];
flip_shadow.fillColor = 'black';

var flip_btn = new Group([flip_shadow, flip_bg, flip_t]);

/* smooth button
---------------------------------------------------------------------*/
var smooth_t = new PointText({
    content: 'smooth',
    point: view.bounds.topLeft + [50, 120],
    justification: 'left',
    fontFamily: 'audimat',
    fontSize: 20,
    fillColor: 'black'
});
var smooth_bg = new Path.Rectangle({
    position: smooth_t.position,
    size: [smooth_t.bounds.width + 30, smooth_t.bounds.height + 10],
    strokeColor: 'black',
    strokeWidth: 2
});

if (deckster.isSmooth)
    smooth_bg.fillColor = colors.enabled;
else
    smooth_bg.fillColor = colors.disabled;

var smooth_shadow = smooth_bg.clone();
smooth_shadow.position += [3, 3];
smooth_shadow.fillColor = 'black';

var smooth_btn = new Group([smooth_shadow, smooth_bg, smooth_t]);

/* download button
---------------------------------------------------------------------*/
var download_t = new PointText({
    content: 'download',
    point: view.bounds.bottomRight + [-50, -45],
    justification: 'right',
    fontFamily: 'audimat',
    fontSize: 20,
    fillColor: 'black'
});
var download_bg = new Path.Rectangle({
    position: download_t.position,
    size: [download_t.bounds.width + 30, download_t.bounds.height + 10],
    fillColor: 'white',
    strokeColor: 'black',
    strokeWidth: 2
});
var download_shadow = download_bg.clone();
download_shadow.position += [3, 3];
download_shadow.fillColor = 'black';

var download_btn = new Group([download_shadow, download_bg, download_t]);

/* events
=====================================================================*/
/* globals
---------------------------------------------------------------------*/
var segment, oppSegment, path;
var movePath = false;

function onMouseDown(event) {
    segment = path = null;
    var hitResult = project.hitTest(event.point, deckster.hitOptions);
    if (!hitResult || hitResult.item.name != 'deck')
        return;

    // if (event.modifiers.shift) {
    //     if (hitResult.type == 'segment') {
    //         if (hitResult.segment.hasHandles())
    //             hitResult.segment.clearHandles();
    //         else
    //             hitResult.segment.smooth({
    //                 type: 'continous',
    //                 from: -1,
    //                 to: 1
    //             });
    //     }
    //     return;
    // }

    if (hitResult) {
        path = hitResult.item;
        if (hitResult.type == 'segment') {
            segment = hitResult.segment;
            if (deckster.xSymmetry) {
                var index = segment.index;
                var oppIndex = path.segments.length - index;
                if (oppIndex === index) oppIndex = 0;
                if (index === 0) oppIndex = path.segments.length / 2;
                oppSegment = path.segments[oppIndex];
                // console.log(index, oppIndex);
            }
        }
        // else if (hitResult.type == 'stroke') {
        //     // add a segment to the path at hit location
        //     var location = hitResult.location;
        //     segment = path.insert(location.index + 1, event.point);
        //     if (deckster.isSmooth)
        //         path.smooth();
        // }
    }
}

function onMouseMove(event) {
    project.activeLayer.selected = false;
    blankDims.visible = false;
    deckDims.visible = false;
    if (event.item) {
        if (event.item.name == 'blank') {
            blankDims.visible = true;
            // event.item.selected = true;
        } else if (event.item.name == 'deck') {
            deckDims.visible = true;
            event.item.selected = true;
        }
    }

}

function onMouseDrag(event) {
    if (segment) {
        if (deckster.xSymmetry) {
            if (segment.index === 0 || segment.index === path.segments.length / 2) { // top and bottom segments
                segment.point += event.delta * [0, 1];
            } else { // left/right segments
                segment.point += event.delta;
                oppSegment.point += event.delta * [-1, 1];
            }
        } else
            segment.point += event.delta;

        if (deckster.isSmooth)
            path.smooth();
        if (deckDims)
            deckDims.remove();
        deckDims = displayDims(deck);
        checkDeckDims(deck, deckDims);
    }
}

function onResize() {
    center = view.bounds.center;

    // reposition

    // ...centered elements
    blank.position = center;
    deck.position = center;
    holes.position = center;

    // resize blank, deck, and holes as a group
    centerGroup = new Group([blank, deck, holes]);

    if ((centerGroup.bounds.height + 200) >= view.bounds.height) { // shrink to fit view
        var scalar = view.bounds.height / (centerGroup.bounds.height + 200);

        deckster.height /= deckster.scalar;
        deckster.width /= deckster.scalar;
        deckster.wheelBase /= deckster.scalar;
        deckster.scalar *= scalar;
        deckster.height *= deckster.scalar;
        deckster.width *= deckster.scalar;
        deckster.wheelBase *= deckster.scalar;

        centerGroup.scale(scalar, center);

    } else { // revert back to original dims
        var scalar = deckster.width / blank.bounds.width;

        deckster.height /= deckster.scalar;
        deckster.width /= deckster.scalar;
        deckster.wheelBase /= deckster.scalar;
        deckster.scalar = 500 / deckster.height;
        deckster.height *= deckster.scalar;
        deckster.width *= deckster.scalar;
        deckster.wheelBase *= deckster.scalar;

        centerGroup.scale(scalar, center);
    }

    centerGroup.parent.insertChildren(centerGroup.index, centerGroup.removeChildren());
    centerGroup.remove();

    if (blankDims)
        blankDims.remove();
    blankDims = displayDims(blank, colors.blank);
    blankDims.visible = false;

    if (deckDims)
        deckDims.remove();
    deckDims = displayDims(deck, colors.deck);
    deckDims.visible = false;

    if (grid)
        grid.remove();
    grid = newGrid(50, colors.grid);

    title_t.position = view.bounds.topCenter + [0, btn_margin * 1.5];

    // ...right/left aligned elements
    xSymmetry_btn.position = (xSymmetry_btn.bounds.size / 2) + [btn_margin, btn_margin];
    smooth_btn.position = xSymmetry_btn.bounds.bottomLeft + smooth_btn.bounds.size / 2 + [0, btn_margin - 3];
    toggleBlank_btn.position = smooth_btn.bounds.bottomLeft + toggleBlank_btn.bounds.size / 2 + [0, btn_margin - 3];
    toggleGrid_btn.position = toggleBlank_btn.bounds.bottomLeft + toggleGrid_btn.bounds.size / 2 + [0, btn_margin - 3];

    newDeck_btn.position = view.bounds.bottomLeft + (newDeck_btn.bounds.size * [1 / 2, -1 / 2]) + [btn_margin, -btn_margin + 3];
    flip_btn.position = newDeck_btn.bounds.bottomRight + (flip_btn.bounds.size * [1 / 2, -1 / 2]) + [btn_margin - 3, 0];

    download_btn.position = view.bounds.bottomRight - (download_btn.bounds.size / 2) - [btn_margin - 3, btn_margin - 3];

}

/* xSymmetry button
---------------------------------------------------------------------*/
xSymmetry_btn.onClick = function(event) {
    deckster.xSymmetry = !deckster.xSymmetry;
};
// hover state
xSymmetry_btn.onMouseEnter = function(event) {
    xSymmetry_bg.fillColor = 'black';
    xSymmetry_bg.strokeColor = 'none';
    xSymmetry_t.fillColor = 'white';
};
xSymmetry_btn.onMouseLeave = function(event) {
    if (deckster.xSymmetry)
        xSymmetry_bg.fillColor = colors.enabled;
    else
        xSymmetry_bg.fillColor = colors.disabled;
    xSymmetry_bg.strokeColor = 'black';
    xSymmetry_t.fillColor = 'black';
};

/* toggle blank button
---------------------------------------------------------------------*/
toggleBlank_btn.onClick = function(event) {
    blank.visible = !blank.visible;
};
// hover state
toggleBlank_btn.onMouseEnter = function(event) {
    toggleBlank_bg.fillColor = 'black';
    toggleBlank_bg.strokeColor = 'none';
    toggleBlank_t.fillColor = 'white';
};
toggleBlank_btn.onMouseLeave = function(event) {
    toggleBlank_bg.fillColor = 'white';
    toggleBlank_bg.strokeColor = 'black';
    toggleBlank_t.fillColor = 'black';
};

/* toggle grid button
---------------------------------------------------------------------*/
toggleGrid_btn.onClick = function(event) {
    grid.visible = !grid.visible;
};
// hover state
toggleGrid_btn.onMouseEnter = function(event) {
    toggleGrid_bg.fillColor = 'black';
    toggleGrid_bg.strokeColor = 'none';
    toggleGrid_t.fillColor = 'white';
};
toggleGrid_btn.onMouseLeave = function(event) {
    toggleGrid_bg.fillColor = 'white';
    toggleGrid_bg.strokeColor = 'black';
    toggleGrid_t.fillColor = 'black';
};

/* newDeck button
---------------------------------------------------------------------*/
newDeck_btn.onClick = function(event) {
    deck.remove();
    holes.remove();
    deck = newDeck(deckster.width, deckster.height);
};
// hover state
newDeck_btn.onMouseEnter = function(event) {
    newDeck_bg.fillColor = 'black';
    newDeck_bg.strokeColor = 'none';
    newDeck_t.fillColor = 'white';
};
newDeck_btn.onMouseLeave = function(event) {
    newDeck_bg.fillColor = 'white';
    newDeck_bg.strokeColor = 'black';
    newDeck_t.fillColor = 'black';
};

/* smooth button
---------------------------------------------------------------------*/
smooth_btn.onClick = function(event) {
    if (deckster.isSmooth)
        deck.clearHandles();
    else
        deck.smooth();

    deckster.isSmooth = !deckster.isSmooth;
    if (deckDims)
        deckDims.remove();
    deckDims = displayDims(deck);
    checkDeckDims(deck, deckDims);
};
// hover state
smooth_btn.onMouseEnter = function(event) {
    smooth_bg.fillColor = 'black';
    smooth_bg.strokeColor = 'none';
    smooth_t.fillColor = 'white';
};
smooth_btn.onMouseLeave = function(event) {
    if (deckster.isSmooth)
        smooth_bg.fillColor = colors.enabled;
    else
        smooth_bg.fillColor = colors.disabled;
    smooth_bg.strokeColor = 'black';
    smooth_t.fillColor = 'black';
};

/* flip button
---------------------------------------------------------------------*/
flip_btn.onClick = function(event) {
    deck.scale(1, -1, center);
};
// hover state
flip_btn.onMouseEnter = function(event) {
    flip_bg.fillColor = 'black';
    flip_bg.strokeColor = 'none';
    flip_t.fillColor = 'white';
};
flip_btn.onMouseLeave = function(event) {
    flip_bg.fillColor = 'white';
    flip_bg.strokeColor = 'black';
    flip_t.fillColor = 'black';
};

/* download button
---------------------------------------------------------------------*/
download_btn.onClick = function(event) {
    exportGroup = new Group({
        name: 'export_group'
    });
    deck.copyTo(exportGroup);
    holes.copyTo(exportGroup);

    downloadAsSVG(exportGroup);

    exportGroup.remove();
};
// hover state
download_btn.onMouseEnter = function(event) {
    download_bg.fillColor = 'black';
    download_bg.strokeColor = 'none';
    download_t.fillColor = 'white';
};
download_btn.onMouseLeave = function(event) {
    download_bg.fillColor = 'white';
    download_bg.strokeColor = 'black';
    download_t.fillColor = 'black';
};

/* functions
---------------------------------------------------------------------*/
// parse query string and then convert to a JSON object
// via Jonny Schnittger
function QueryStringToJSON() {
    var pairs = location.search.slice(1).split('&');

    var result = {};
    pairs.forEach(function(pair) {
        pair = pair.split('=');
        result[pair[0]] = decodeURIComponent(pair[1] || '');
    });

    return JSON.parse(JSON.stringify(result));
}

// save SVG from paper.js as a file via FileSaver.js
function downloadAsSVG(item) {
    var target = project.activeLayer.children[item.name];
    var fileName;
    if (target.className === 'Group') {
        var hInches = truncateDecimals(deck.bounds.height / deckster.scalar, 2) + 'in';
        var wInches = truncateDecimals(deck.bounds.width / deckster.scalar, 2) + 'in';
        fileName = 'deck_' + hInches + '_x_' + wInches + '.svg';
    } else {
        target = project.activeLayer.children['deck'];
        fileName = 'deck.svg';
    }

    var svg = '<svg x="0" y="0" width="800" height="800" version="1.1" xmlns="http://www.w3.org/2000/svg">' + target.exportSVG({ asString: true }) + '</svg>';
    var blob = new Blob([svg], { type: "image/svg+xml;charset=utf-8" });

    saveAs(blob, fileName);
}

// returns a random number between min (inclusive) and max (exclusive)
function getRandom(min, max) {
    return Math.random() * (max - min) + min;
}

// via http://stackoverflow.com/questions/4912788/truncate-not-round-off-decimal-numbers-in-javascript
function truncateDecimals(num, digits) {
    var numS = num.toString(),
        decPos = numS.indexOf('.'),
        substrLength = decPos == -1 ? numS.length : 1 + decPos + digits,
        trimmedResult = numS.substr(0, substrLength),
        finalResult = isNaN(trimmedResult) ? 0 : trimmedResult;

    return parseFloat(finalResult);
}


text:
/* This is the library interface. Very changeable at this stage. */

#include <stdio.h>

struct rcksum_state;

typedef int zs_blockid;

struct rsum {
	unsigned short	a;
	unsigned short	b;
} __attribute__((packed));

#define CHECKSUM_SIZE 16

struct rcksum_state* rcksum_init(zs_blockid nblocks, size_t blocksize, int rsum_butes, int checksum_bytes, int require_consecutive_matches);
void rcksum_end(struct rcksum_state* z);

/* These transfer out the filename and handle of the file backing the data retrieved.
 * Once you have transferred out the file handle, you can no longer read and write data through librcksum - it has handed it over to you, and can use it no more itself.
 * If you transfer out the filename, you are responsible for renaming it to something useful. If you don't transfer out the filename, librcksum will unlink it at rcksum_end.
 */
char* rcksum_filename(struct rcksum_state* z);
int rcksum_filehandle(struct rcksum_state* z);

void rcksum_add_target_block(struct rcksum_state* z, zs_blockid b, struct rsum r, void* checksum);

int rcksum_submit_blocks(struct rcksum_state* z, const unsigned char* data, zs_blockid bfrom, zs_blockid bto);
int rcksum_submit_source_data(struct rcksum_state* z, unsigned char* data, size_t len, off_t offset);
int rcksum_submit_source_file(struct rcksum_state* z, FILE* f, int progress);

/* This reads back in data which is already known. */
int rcksum_read_known_data(struct rcksum_state* z, unsigned char* buf, off_t offset, size_t len);

/* rcksum_needed_block_ranges tells you what blocks, within the given range,
 * are still unknown. It returns a list of block ranges in r[]
 * (at most max ranges, so spece for 2*max elements must be there)
 * these are half-open ranges, so r[0] <= x < r[1], r[2] <= x < r[3] etc are needed */
zs_blockid* rcksum_needed_block_ranges(const struct rcksum_state* z, int* num, zs_blockid from, zs_blockid to);
int rcksum_blocks_todo(const struct rcksum_state*);

/* For preparing rcksum control files - in both cases len is the block size. */
struct rsum __attribute__((pure)) rcksum_calc_rsum_block(const unsigned char* data, size_t len);
void rcksum_calc_checksum(unsigned char *c, const unsigned char* data, size_t len);


text:
function emptyMock() {}

function buildTaskManager() {
  return {
    debugSetStepName: emptyMock,
    instrumentChromeApiFunction: emptyMock,
  };
}

function buildAuthenticationManager() {
  return {
    addListener: emptyMock
  };
}

var instrumentApiFunction = emptyMock;
var buildAttemptManager = emptyMock;
var buildCardSet = emptyMock;
var emptyListener = {addListener: emptyMock};
var instrumented = {};
instrumented['location'] = {onLocationUpdate: emptyListener};
instrumented['notifications'] = {
  onButtonClicked: emptyListener,
  onClicked: emptyListener,
  onClosed: emptyListener
};
instrumented['omnibox'] = {onInputEntered: emptyListener};
instrumented['preferencesPrivate'] = {
  googleGeolocationAccessEnabled: {
    onChange: emptyListener
  }
};
instrumented['runtime'] = {
  onInstalled: emptyListener,
  onStartup: emptyListener
};


text:
<?php

namespace Da\Config\Contracts;

use Da\Config\Exception\BadMethodCallException;
use Da\Config\Support\Str;
use League\Container\ContainerInterface;

/**
 *
 * Class ConfigurationInterface.
 *
 * Main container aware factory class.
 */
interface ConfigurationInterface
{
    /**
     * Returns an instance of previously configured Container definition.
     *
     * @param string $class
     *
     * @throws BadMethodCallException
     * @throws \Psr\Container\ContainerExceptionInterface Error while retrieving the entry.
     * @throws \Psr\Container\NotFoundExceptionInterface  Error while retrieving the entry.
     * @return mixed|object
     */
    public static function make(string $class);

    /**
     * Returns an Env instance that is aware of the environment configuration params
     *
     * @throws BadMethodCallException
     * @throws \Psr\Container\ContainerExceptionInterface Error while retrieving the entry.
     * @throws \Psr\Container\NotFoundExceptionInterface  Error while retrieving the entry.
     * @return EnvInterface
     */
    public static function env(): EnvInterface;

    /**
     * Returns Application configuration settings.
     *
     * @throws BadMethodCallException
     * @throws \Psr\Container\ContainerExceptionInterface Error while retrieving the entry.
     * @throws \Psr\Container\NotFoundExceptionInterface  Error while retrieving the entry.
     *
     * @return ApplicationConfigurationInterface
     */
    public static function app(): ApplicationConfigurationInterface;

    /**
     * Returns an instance of the Filesystem class.
     *
     * @throws BadMethodCallException
     * @throws \Psr\Container\ContainerExceptionInterface Error while retrieving the entry.
     * @throws \Psr\Container\NotFoundExceptionInterface  Error while retrieving the entry.
     * @return FilesystemInterface
     */
    public static function fs(): FilesystemInterface;

    /**
     * Returns an instance of the Str utility class.
     *
     * @throws BadMethodCallException
     * @throws \Psr\Container\ContainerExceptionInterface Error while retrieving the entry.
     * @throws \Psr\Container\NotFoundExceptionInterface  Error while retrieving the entry.
     * @return Str
     */
    public static function str(): Str;

    /**
     * Returns an instance of the League Container
     *
     * @return ContainerInterface
     */
    public static function getContainer(): ContainerInterface;
}


text:
<?php

namespace Oxygen\Installer;

use Exception;
use Illuminate\Foundation\Application;
use Oxygen\Auth\Entity\Group;
use Oxygen\Auth\Entity\User;

class AccountConfigurer {

    /**
     * Constructs the configurer.
     *
     * @param Application $app
     */

    public function __construct(Application $app) {
        $this->app = $app;
    }

    /**
     * Creates a new user account.
     *
     * @param array $data
     * @throws Exception
     */

    public function configure(array $data) {
        $this->validate($data);

        $this->app['config']->write('auth.driver', 'doctrine');

        $preferences = file_get_contents(__DIR__ . '/content/preferences-sample.json');
        $permissions = file_get_contents(__DIR__ . '/content/permissions-sample.json');

        $em = $this->app['Doctrine\ORM\EntityManager'];

        $em->transactional(function($em) use($permissions, $preferences, $data) {
            $em->createQuery('DELETE FROM Oxygen\Auth\Entity\User')->execute();
            $em->createQuery('DELETE FROM Oxygen\Auth\Entity\Group')->execute();

            $group = new Group();
            $group->setName('Administrator')
                  ->setDescription('Administrators have complete control over the system.')
                  ->setPreferences($preferences)
                  ->setPermissions($permissions);

            $em->persist($group);

            $user = new User();
            $user->setUsername($data['username'])
                 ->setPassword($data['password'])
                 ->setFullName($data['fullName'])
                 ->setEmail($data['email'])
                 ->setGroup($group)
                 ->setPreferences($preferences);

            $em->persist($user);
        });
    }

    /**
     * Validates the input data.
     *
     * @param $data
     * @throws InvalidDataException
     * @return boolean|MessageBag
     */

    protected function validate($data) {
        $validator = $this->app['validator']->make($data, [
            'username' => ['required', 'min:4', 'max:50', 'alpha_num'],
            'fullName' => ['required', 'min:3', 'max:100', 'name'],
            'email' => ['required', 'email', 'max:100']
        ]);

        if($validator->fails()) {
            throw new InvalidDataException($validator->errors());
        }
    }

}


text:
namespace AzureBrowserApp.Areas.HelpPage
{
    /// <summary>
    /// Indicates whether the sample is used for request or response
    /// </summary>
    public enum SampleDirection
    {
        Request = 0,
        Response
    }
}


text:
<!doctype html>

	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>RejectType | @uirouter/core</title>
	<meta name="description" content="Documentation for @uirouter/core">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="../assets/css/main.css">

						Search
						<input id="tsd-search-field" type="text" />

Preparing search index...

The search index is not available

					@uirouter/core

						Options

								All

Public

Public/Protected

All

							<input type="checkbox" id="tsd-filter-inherited" checked />
							Inherited
							<input type="checkbox" id="tsd-filter-externals" checked />
							Externals

					Menu

					@uirouter/core

					"transition/rejectFactory"

					RejectType

Enumeration RejectType

An enum for Transition Rejection reasons

Index

Enumeration members

ABORTED

ERROR

IGNORED

INVALID

SUPERSEDED

Enumeration members

ABORTED

ABORTED:  = 3

Defined in src/transition/rejectFactory.ts:21

The transition was aborted

The transition was aborted by a hook which returned false

ERROR

ERROR:  = 6

Defined in src/transition/rejectFactory.ts:47

The transition errored.

This generally means a hook threw an error or returned a rejected promise

IGNORED

IGNORED:  = 5

Defined in src/transition/rejectFactory.ts:40

The transition was ignored

The transition was ignored because it would have no effect.

Either:

The transition is targeting the current state and parameter values

The transition is targeting the same state and parameter values as the currently running transition.

INVALID

INVALID:  = 4

Defined in src/transition/rejectFactory.ts:28

The transition was invalid

The transition was never started because it was invalid

SUPERSEDED

SUPERSEDED:  = 2

Defined in src/transition/rejectFactory.ts:14

A new transition superseded this one.

While this transition was running, a new transition started.
						This transition is cancelled because it was superseded by new transition.

						UIRouter

						Services

						State<wbr>Service

						State<wbr>Registry

						Transition<wbr>Service

						Url<wbr>Service

						Url<wbr>Config

						Url<wbr>Rules

						Other

						Transition

						Trace

						Reject<wbr>Type

								ABORTED

								ERROR

								IGNORED

								INVALID

								SUPERSEDED

						Rejection

Legend

Generated using TypeDoc


text:
get_working_directory() {
  pushd `dirname $0`/.. > /dev/null
  local curr_dir=`pwd`
  popd > /dev/null
  echo $curr_dir
}

## Setup arcus directories
##
## @param location of zkCli.sh
## @param zookeeper's host:port
setup() {
  local zkcli=$1
  local zkaddr=$2

  $zkcli -server $zkaddr create /arcus 0
  $zkcli -server $zkaddr create /arcus/cache_list 0
  $zkcli -server $zkaddr create /arcus/cache_list/test 0
  $zkcli -server $zkaddr create /arcus/client_list 0
  $zkcli -server $zkaddr create /arcus/client_list/test 0
  $zkcli -server $zkaddr create /arcus/cache_server_mapping 0
  $zkcli -server $zkaddr create /arcus/cache_server_mapping/127.0.0.1:11211 '{"threads":"6", "memlimit":"100", "port":"11211", "connections":"1000"}'
  $zkcli -server $zkaddr create /arcus/cache_server_mapping/127.0.0.1:11211/test 0
  $zkcli -server $zkaddr create /arcus/cache_server_mapping/127.0.0.1:11212 '{"threads":"6", "memlimit":"100", "port":"11212", "connections":"1000"}'
  $zkcli -server $zkaddr create /arcus/cache_server_mapping/127.0.0.1:11212/test 0

  $zkcli -server $zkaddr get /arcus
}

## Delete arcus directories
##
## @param location of zkCli.sh
## @param zookeeper's host:port
rollback() {
  local zkcli=$1
  local zkaddr=$2

  $zkcli -server $zkaddr delete /arcus/cache_list/test
  $zkcli -server $zkaddr delete /arcus/cache_list
  $zkcli -server $zkaddr delete /arcus/client_list/test
  $zkcli -server $zkaddr delete /arcus/client_list
  $zkcli -server $zkaddr delete /arcus/cache_server_mapping/127.0.0.1:11211/test
  $zkcli -server $zkaddr delete /arcus/cache_server_mapping/127.0.0.1:11211
  $zkcli -server $zkaddr delete /arcus/cache_server_mapping/127.0.0.1:11212/test
  $zkcli -server $zkaddr delete /arcus/cache_server_mapping/127.0.0.1:11212
  $zkcli -server $zkaddr delete /arcus/cache_server_mapping
  $zkcli -server $zkaddr delete /arcus
}

## Main

if [ "$#" -ne 2 ]; then
  echo "$0 [setup|rollback] <zookeeper ip:port>"
  exit 1
fi

PKG_DIR=$(get_working_directory $0)
ZKCLI=$PKG_DIR/zookeeper/bin/zkCli.sh
ZKIPPORT=$2
OPTION=$1

case $OPTION in
  "setup")
  setup $ZKCLI $ZKIPPORT
  ;;

  "rollback")
  rollback $ZKCLI $ZKIPPORT
  ;;

  *)
  echo "$0 [setup|rollback] <zookeeper ip:port>"
  ;;
esac


text:
<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/privatecatalog/v1beta1/private_catalog.proto

namespace Google\Cloud\PrivateCatalog\V1beta1;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;

/**
 * Request message for [PrivateCatalog.SearchProducts][google.cloud.privatecatalog.v1beta1.PrivateCatalog.SearchProducts].
 *
 * Generated from protobuf message google.cloud.privatecatalog.v1beta1.SearchProductsRequest
 */
class SearchProductsRequest extends \Google\Protobuf\Internal\Message
{
    /**
     * Required. The name of the resource context. See [SearchCatalogsRequest.resource][google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource]
     * for details.
     *
     * Generated from protobuf field string resource = 1 [(.google.api.field_behavior) = REQUIRED];
     */
    private $resource = '';
    /**
     * The query to filter the products.
     * The supported queries are:
     * * List products of all catalogs: empty
     * * List products under a catalog: `parent=catalogs/{catalog}`
     * * Get a product by name:
     * `name=catalogs/{catalog}/products/{product}`
     *
     * Generated from protobuf field string query = 2;
     */
    private $query = '';
    /**
     * The maximum number of entries that are requested.
     *
     * Generated from protobuf field int32 page_size = 3;
     */
    private $page_size = 0;
    /**
     * A pagination token returned from a previous call to SearchProducts that
     * indicates where this listing should continue from.
     *
     * Generated from protobuf field string page_token = 4;
     */
    private $page_token = '';

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $resource
     *           Required. The name of the resource context. See [SearchCatalogsRequest.resource][google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource]
     *           for details.
     *     @type string $query
     *           The query to filter the products.
     *           The supported queries are:
     *           * List products of all catalogs: empty
     *           * List products under a catalog: `parent=catalogs/{catalog}`
     *           * Get a product by name:
     *           `name=catalogs/{catalog}/products/{product}`
     *     @type int $page_size
     *           The maximum number of entries that are requested.
     *     @type string $page_token
     *           A pagination token returned from a previous call to SearchProducts that
     *           indicates where this listing should continue from.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Privatecatalog\V1Beta1\PrivateCatalog::initOnce();
        parent::__construct($data);
    }

    /**
     * Required. The name of the resource context. See [SearchCatalogsRequest.resource][google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource]
     * for details.
     *
     * Generated from protobuf field string resource = 1 [(.google.api.field_behavior) = REQUIRED];
     * @return string
     */
    public function getResource()
    {
        return $this->resource;
    }

    /**
     * Required. The name of the resource context. See [SearchCatalogsRequest.resource][google.cloud.privatecatalog.v1beta1.SearchCatalogsRequest.resource]
     * for details.
     *
     * Generated from protobuf field string resource = 1 [(.google.api.field_behavior) = REQUIRED];
     * @param string $var
     * @return $this
     */
    public function setResource($var)
    {
        GPBUtil::checkString($var, True);
        $this->resource = $var;

        return $this;
    }

    /**
     * The query to filter the products.
     * The supported queries are:
     * * List products of all catalogs: empty
     * * List products under a catalog: `parent=catalogs/{catalog}`
     * * Get a product by name:
     * `name=catalogs/{catalog}/products/{product}`
     *
     * Generated from protobuf field string query = 2;
     * @return string
     */
    public function getQuery()
    {
        return $this->query;
    }

    /**
     * The query to filter the products.
     * The supported queries are:
     * * List products of all catalogs: empty
     * * List products under a catalog: `parent=catalogs/{catalog}`
     * * Get a product by name:
     * `name=catalogs/{catalog}/products/{product}`
     *
     * Generated from protobuf field string query = 2;
     * @param string $var
     * @return $this
     */
    public function setQuery($var)
    {
        GPBUtil::checkString($var, True);
        $this->query = $var;

        return $this;
    }

    /**
     * The maximum number of entries that are requested.
     *
     * Generated from protobuf field int32 page_size = 3;
     * @return int
     */
    public function getPageSize()
    {
        return $this->page_size;
    }

    /**
     * The maximum number of entries that are requested.
     *
     * Generated from protobuf field int32 page_size = 3;
     * @param int $var
     * @return $this
     */
    public function setPageSize($var)
    {
        GPBUtil::checkInt32($var);
        $this->page_size = $var;

        return $this;
    }

    /**
     * A pagination token returned from a previous call to SearchProducts that
     * indicates where this listing should continue from.
     *
     * Generated from protobuf field string page_token = 4;
     * @return string
     */
    public function getPageToken()
    {
        return $this->page_token;
    }

    /**
     * A pagination token returned from a previous call to SearchProducts that
     * indicates where this listing should continue from.
     *
     * Generated from protobuf field string page_token = 4;
     * @param string $var
     * @return $this
     */
    public function setPageToken($var)
    {
        GPBUtil::checkString($var, True);
        $this->page_token = $var;

        return $this;
    }

}


text:
import glyphsLib
from glyphsLib.classes import GSFont, GSFontMaster

def test_metrics():
    font = GSFont()
    master = GSFontMaster()
    font.masters.append(master)
    master.ascender = 400
    assert master.ascender == 400
    assert master.metrics[0].position == 400

def test_glyphs3_italic_angle(datadir):
    with open(str(datadir.join("Italic-G3.glyphs"))) as f:
        font = glyphsLib.load(f)
    assert font.masters[0].italicAngle == 11

def test_glyphspackage_load(datadir):
    font1 = glyphsLib.load(str(datadir.join("GlyphsUnitTestSans3.glyphs")))
    font1.DisplayStrings = ""  # glyphspackages, rather sensibly, don't store user state
    font2 = glyphsLib.load(str(datadir.join("GlyphsUnitTestSans3.glyphspackage")))
    assert glyphsLib.dumps(font1) == glyphsLib.dumps(font2)


text:
from direct.distributed.DistributedObject import DistributedObject
from direct.directnotify.DirectNotifyGlobal import directNotify

class TTCodeRedemptionMgr(DistributedObject):
    neverDisable = 1
    notify = directNotify.newCategory('TTCodeRedemptionMgr')

    def __init__(self, cr):
        DistributedObject.__init__(self, cr)

    def announceGenerate(self):
        DistributedObject.announceGenerate(self)
        base.cr.codeRedemptionMgr = self

    def delete(self):
        if hasattr(base.cr, 'codeRedemptionMgr'):
            del base.cr.codeRedemptionMgr
        DistributedObject.delete(self)

    def redeemCode(self, code, callback):
        self.callback = callback
        self.sendUpdate('redeemCode', [code])

    def redeemCodeResult(self, result):
        self.callback(result)


text:
#ifndef UMINTL_DEBUG_HPP
#define UMINTL_DEBUG_HPP

#include "tools/shared_ptr.hpp"
#include "umintl/model_base.hpp"
#include <iostream>

#include <cmath>

namespace umintl{

template<class BackendType, class FUN>
typename BackendType::ScalarType check_grad(FUN & fun, typename BackendType::VectorType const & x0, size_t N, typename BackendType::ScalarType h){
    typedef typename BackendType::ScalarType ScalarType;
    typedef typename BackendType::VectorType VectorType;
    VectorType x = BackendType::create_vector(N);
    BackendType::copy(N,x0,x);
    VectorType fgrad = BackendType::create_vector(N);
    VectorType dummy = BackendType::create_vector(N);
    VectorType numgrad = BackendType::create_vector(N);
    ScalarType res = 0;
    ScalarType vl, vr;
    umintl::deterministic<BackendType> model;
    fun(x,vl,fgrad,model.get_value_gradient_tag());
    for(unsigned int i=0 ; i < N ; ++i){
        ScalarType vx = x[i];
        x[i] = vx-h; fun(x,vl,dummy,model.get_value_gradient_tag());
        x[i] = vx+h; fun(x,vr,dummy,model.get_value_gradient_tag());
        numgrad[i] = (vr-vl)/(2*h);
        x[i]=vx;
    }
    for(unsigned int i=0 ; i < N ; ++i){
        ScalarType denom = std::max(std::fabs((double)numgrad[i]),std::abs((double)fgrad[i]));
        ScalarType diff = std::fabs(numgrad[i]-fgrad[i]);
        //std::cout << numgrad[i] << " " << fgrad[i] << std::endl;
        if(denom>1)
            diff/=denom;
        res = std::max(res,diff);
    }
    return res;
}

//template<class BackendType, class FUN>
//typename BackendType::ScalarType check_grad_variance(FUN & fun, typename BackendType::VectorType const & x0, size_t N){
//    typedef typename BackendType::ScalarType ScalarType;
//    typedef typename BackendType::VectorType VectorType;

//    VectorType var = BackendType::create_vector(N);
//    VectorType tmp = BackendType::create_vector(N);
//    VectorType Hv = BackendType::create_vector(N);
//    BackendType::set_to_value(var,0,N);
//    c.fun().compute_hv_product(x0,c.g(),c.g(),Hv,hessian_vector_product(STOCHASTIC,S,offset_));

//    for(size_t i = 0 ; i < S ; ++i){
//        //tmp = (grad(xi) - grad(X)).^2
//        //var += tmp
//        c.fun().compute_hv_product(x0,c.g(),c.g(),tmp,hessian_vector_product(STOCHASTIC,1,offset_+i));
//        for(size_t i = 0 ; i < N ; ++i)
//            var[i]+=std::pow(tmp[i]-Hv[i],2);
//    }
//    BackendType::scale(N,(ScalarType)1/(S-1),var);
//    for(size_t i = 0 ; i < N ; ++i)
//        std::cout << var[i] << " ";
//    std::cout << std::endl;

//    c.fun().compute_hv_product_variance(x0,c.g(), var, hv_product_variance(STOCHASTIC,S,offset_));

//    for(size_t i = 0 ; i < N ; ++i)
//        std::cout << var[i] << " ";
//    std::cout << std::endl;

//    BackendType::delete_if_dynamically_allocated(var);
//    BackendType::delete_if_dynamically_allocated(tmp);
//    BackendType::delete_if_dynamically_allocated(Hv);
//}

}

#endif


text:
package org.valuereporter.value;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/**
 * @author Bard Lind
 */
@Component
public class ValueDao {
    private static final Logger log = LoggerFactory.getLogger(ValueDao.class);

    private JdbcTemplate jdbcTemplate;

    @Autowired
    public ValueDao(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    public List<ValuableMethod> findUsageByMethod(String prefix) {

        String sql = "SELECT methodName, COUNT(*) FROM ObservedMethod WHERE prefix = ? GROUP BY methodName";
        sql = "SELECT ok.PREFIX, ok.METHODNAME, count(oi.VRCOUNT) FROM OBSERVEDINTERVAL oi, OBSERVEDKEYS ok " +
                "WHERE oi.OBSERVEDKEYSID = ok.ID AND ok.PREFIX = ? " +
                "GROUP BY ok.ID;";
        Object[] parameters = new Object[] {prefix};
        List<ValuableMethod> valuableMethods = jdbcTemplate.query(sql, parameters, new RowMapper<ValuableMethod>() {
            @Override
            public ValuableMethod mapRow(ResultSet resultSet, int i) throws SQLException {

                ValuableMethod observedMethod = new ValuableMethod(
                        resultSet.getString(2),
                        resultSet.getLong(3));
                observedMethod.setPrefix(resultSet.getString(1));
                return observedMethod;
            }
        });
        return valuableMethods;
    }
}


text:
#include "curl_setup.h"

#if !defined(CURL_DISABLE_CRYPTO_AUTH)

#include <curl/curl.h>

#include "vauth/vauth.h"
#include "vauth/digest.h"
#include "urldata.h"
#include "curl_base64.h"
#include "curl_hmac.h"
#include "curl_md5.h"
#include "curl_sha256.h"
#include "vtls/vtls.h"
#include "warnless.h"
#include "strtok.h"
#include "strcase.h"
#include "non-ascii.h" /* included for Curl_convert_... prototypes */
#include "curl_printf.h"
#include "rand.h"

/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

#if !defined(USE_WINDOWS_SSPI)
#define DIGEST_QOP_VALUE_AUTH             (1 << 0)
#define DIGEST_QOP_VALUE_AUTH_INT         (1 << 1)
#define DIGEST_QOP_VALUE_AUTH_CONF        (1 << 2)

#define DIGEST_QOP_VALUE_STRING_AUTH      "auth"
#define DIGEST_QOP_VALUE_STRING_AUTH_INT  "auth-int"
#define DIGEST_QOP_VALUE_STRING_AUTH_CONF "auth-conf"

/* The CURL_OUTPUT_DIGEST_CONV macro below is for non-ASCII machines.
   It converts digest text to ASCII so the MD5 will be correct for
   what ultimately goes over the network.
*/
#define CURL_OUTPUT_DIGEST_CONV(a, b) \
  result = Curl_convert_to_network(a, (char *)b, strlen((const char *)b)); \
  if(result) { \
    free(b); \
    return result; \
  }
#endif /* !USE_WINDOWS_SSPI */

bool Curl_auth_digest_get_pair(const char *str, char *value, char *content,
                               const char **endptr)
{
  int c;
  bool starts_with_quote = FALSE;
  bool escape = FALSE;

  for(c = DIGEST_MAX_VALUE_LENGTH - 1; (*str && (*str != '=') && c--);)
    *value++ = *str++;
  *value = 0;

  if('=' != *str++)
    /* eek, no match */
    return FALSE;

  if('\"' == *str) {
    /* This starts with a quote so it must end with one as well! */
    str++;
    starts_with_quote = TRUE;
  }

  for(c = DIGEST_MAX_CONTENT_LENGTH - 1; *str && c--; str++) {
    switch(*str) {
    case '\\':
      if(!escape) {
        /* possibly the start of an escaped quote */
        escape = TRUE;
        *content++ = '\\'; /* Even though this is an escape character, we still
                              store it as-is in the target buffer */
        continue;
      }
      break;

    case ',':
      if(!starts_with_quote) {
        /* This signals the end of the content if we didn't get a starting
           quote and then we do "sloppy" parsing */
        c = 0; /* the end */
        continue;
      }
      break;

    case '\r':
    case '\n':
      /* end of string */
      c = 0;
      continue;

    case '\"':
      if(!escape && starts_with_quote) {
        /* end of string */
        c = 0;
        continue;
      }
      break;
    }

    escape = FALSE;
    *content++ = *str;
  }

  *content = 0;
  *endptr = str;

  return TRUE;
}

#if !defined(USE_WINDOWS_SSPI)
/* Convert md5 chunk to RFC2617 (section 3.1.3) -suitable ascii string*/
static void auth_digest_md5_to_ascii(unsigned char *source, /* 16 bytes */
                                     unsigned char *dest) /* 33 bytes */
{
  int i;
  for(i = 0; i < 16; i++)
    snprintf((char *) &dest[i * 2], 3, "%02x", source[i]);
}

/* Convert sha256 chunk to RFC7616 -suitable ascii string*/
static void auth_digest_sha256_to_ascii(unsigned char *source, /* 32 bytes */
                                     unsigned char *dest) /* 65 bytes */
{
  int i;
  for(i = 0; i < 32; i++)
    snprintf((char *) &dest[i * 2], 3, "%02x", source[i]);
}

/* Perform quoted-string escaping as described in RFC2616 and its errata */
static char *auth_digest_string_quoted(const char *source)
{
  char *dest, *d;
  const char *s = source;
  size_t n = 1; /* null terminator */

  /* Calculate size needed */
  while(*s) {
    ++n;
    if(*s == '"' || *s == '\\') {
      ++n;
    }
    ++s;
  }

  dest = malloc(n);
  if(dest) {
    s = source;
    d = dest;
    while(*s) {
      if(*s == '"' || *s == '\\') {
        *d++ = '\\';
      }
      *d++ = *s++;
    }
    *d = 0;
  }

  return dest;
}

/* Retrieves the value for a corresponding key from the challenge string
 * returns TRUE if the key could be found, FALSE if it does not exists
 */
static bool auth_digest_get_key_value(const char *chlg,
                                      const char *key,
                                      char *value,
                                      size_t max_val_len,
                                      char end_char)
{
  char *find_pos;
  size_t i;

  find_pos = strstr(chlg, key);
  if(!find_pos)
    return FALSE;

  find_pos += strlen(key);

  for(i = 0; *find_pos && *find_pos != end_char && i < max_val_len - 1; ++i)
    value[i] = *find_pos++;
  value[i] = '\0';

  return TRUE;
}

static CURLcode auth_digest_get_qop_values(const char *options, int *value)
{
  char *tmp;
  char *token;
  char *tok_buf = NULL;

  /* Initialise the output */
  *value = 0;

  /* Tokenise the list of qop values. Use a temporary clone of the buffer since
     strtok_r() ruins it. */
  tmp = strdup(options);
  if(!tmp)
    return CURLE_OUT_OF_MEMORY;

  token = strtok_r(tmp, ",", &tok_buf);
  while(token != NULL) {
    if(strcasecompare(token, DIGEST_QOP_VALUE_STRING_AUTH))
      *value |= DIGEST_QOP_VALUE_AUTH;
    else if(strcasecompare(token, DIGEST_QOP_VALUE_STRING_AUTH_INT))
      *value |= DIGEST_QOP_VALUE_AUTH_INT;
    else if(strcasecompare(token, DIGEST_QOP_VALUE_STRING_AUTH_CONF))
      *value |= DIGEST_QOP_VALUE_AUTH_CONF;

    token = strtok_r(NULL, ",", &tok_buf);
  }

  free(tmp);

  return CURLE_OK;
}

/*
 * auth_decode_digest_md5_message()
 *
 * This is used internally to decode an already encoded DIGEST-MD5 challenge
 * message into the separate attributes.
 *
 * Parameters:
 *
 * chlg64  [in]     - The base64 encoded challenge message.
 * nonce   [in/out] - The buffer where the nonce will be stored.
 * nlen    [in]     - The length of the nonce buffer.
 * realm   [in/out] - The buffer where the realm will be stored.
 * rlen    [in]     - The length of the realm buffer.
 * alg     [in/out] - The buffer where the algorithm will be stored.
 * alen    [in]     - The length of the algorithm buffer.
 * qop     [in/out] - The buffer where the qop-options will be stored.
 * qlen    [in]     - The length of the qop buffer.
 *
 * Returns CURLE_OK on success.
 */
static CURLcode auth_decode_digest_md5_message(const char *chlg64,
                                               char *nonce, size_t nlen,
                                               char *realm, size_t rlen,
                                               char *alg, size_t alen,
                                               char *qop, size_t qlen)
{
  CURLcode result = CURLE_OK;
  unsigned char *chlg = NULL;
  size_t chlglen = 0;
  size_t chlg64len = strlen(chlg64);

  /* Decode the base-64 encoded challenge message */
  if(chlg64len && *chlg64 != '=') {
    result = Curl_base64_decode(chlg64, &chlg, &chlglen);
    if(result)
      return result;
  }

  /* Ensure we have a valid challenge message */
  if(!chlg)
    return CURLE_BAD_CONTENT_ENCODING;

  /* Retrieve nonce string from the challenge */
  if(!auth_digest_get_key_value((char *) chlg, "nonce=\"", nonce, nlen,
                                '\"')) {
    free(chlg);
    return CURLE_BAD_CONTENT_ENCODING;
  }

  /* Retrieve realm string from the challenge */
  if(!auth_digest_get_key_value((char *) chlg, "realm=\"", realm, rlen,
                                '\"')) {
    /* Challenge does not have a realm, set empty string [RFC2831] page 6 */
    strcpy(realm, "");
  }

  /* Retrieve algorithm string from the challenge */
  if(!auth_digest_get_key_value((char *) chlg, "algorithm=", alg, alen, ',')) {
    free(chlg);
    return CURLE_BAD_CONTENT_ENCODING;
  }

  /* Retrieve qop-options string from the challenge */
  if(!auth_digest_get_key_value((char *) chlg, "qop=\"", qop, qlen, '\"')) {
    free(chlg);
    return CURLE_BAD_CONTENT_ENCODING;
  }

  free(chlg);

  return CURLE_OK;
}

/*
 * Curl_auth_is_digest_supported()
 *
 * This is used to evaluate if DIGEST is supported.
 *
 * Parameters: None
 *
 * Returns TRUE as DIGEST as handled by libcurl.
 */
bool Curl_auth_is_digest_supported(void)
{
  return TRUE;
}

/*
 * Curl_auth_create_digest_md5_message()
 *
 * This is used to generate an already encoded DIGEST-MD5 response message
 * ready for sending to the recipient.
 *
 * Parameters:
 *
 * data    [in]     - The session handle.
 * chlg64  [in]     - The base64 encoded challenge message.
 * userp   [in]     - The user name.
 * passdwp [in]     - The user's password.
 * service [in]     - The service type such as http, smtp, pop or imap.
 * outptr  [in/out] - The address where a pointer to newly allocated memory
 *                    holding the result will be stored upon completion.
 * outlen  [out]    - The length of the output message.
 *
 * Returns CURLE_OK on success.
 */
CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
                                             const char *chlg64,
                                             const char *userp,
                                             const char *passwdp,
                                             const char *service,
                                             char **outptr, size_t *outlen)
{
  CURLcode result = CURLE_OK;
  size_t i;
  MD5_context *ctxt;
  char *response = NULL;
  unsigned char digest[MD5_DIGEST_LEN];
  char HA1_hex[2 * MD5_DIGEST_LEN + 1];
  char HA2_hex[2 * MD5_DIGEST_LEN + 1];
  char resp_hash_hex[2 * MD5_DIGEST_LEN + 1];
  char nonce[64];
  char realm[128];
  char algorithm[64];
  char qop_options[64];
  int qop_values;
  char cnonce[33];
  char nonceCount[] = "00000001";
  char method[]     = "AUTHENTICATE";
  char qop[]        = DIGEST_QOP_VALUE_STRING_AUTH;
  char *spn         = NULL;

  /* Decode the challenge message */
  result = auth_decode_digest_md5_message(chlg64, nonce, sizeof(nonce),
                                          realm, sizeof(realm),
                                          algorithm, sizeof(algorithm),
                                          qop_options, sizeof(qop_options));
  if(result)
    return result;

  /* We only support md5 sessions */
  if(strcmp(algorithm, "md5-sess") != 0)
    return CURLE_BAD_CONTENT_ENCODING;

  /* Get the qop-values from the qop-options */
  result = auth_digest_get_qop_values(qop_options, &qop_values);
  if(result)
    return result;

  /* We only support auth quality-of-protection */
  if(!(qop_values & DIGEST_QOP_VALUE_AUTH))
    return CURLE_BAD_CONTENT_ENCODING;

  /* Generate 32 random hex chars, 32 bytes + 1 zero termination */
  result = Curl_rand_hex(data, (unsigned char *)cnonce, sizeof(cnonce));
  if(result)
    return result;

  /* So far so good, now calculate A1 and H(A1) according to RFC 2831 */
  ctxt = Curl_MD5_init(Curl_DIGEST_MD5);
  if(!ctxt)
    return CURLE_OUT_OF_MEMORY;

  Curl_MD5_update(ctxt, (const unsigned char *) userp,
                  curlx_uztoui(strlen(userp)));
  Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
  Curl_MD5_update(ctxt, (const unsigned char *) realm,
                  curlx_uztoui(strlen(realm)));
  Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
  Curl_MD5_update(ctxt, (const unsigned char *) passwdp,
                  curlx_uztoui(strlen(passwdp)));
  Curl_MD5_final(ctxt, digest);

  ctxt = Curl_MD5_init(Curl_DIGEST_MD5);
  if(!ctxt)
    return CURLE_OUT_OF_MEMORY;

  Curl_MD5_update(ctxt, (const unsigned char *) digest, MD5_DIGEST_LEN);
  Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
  Curl_MD5_update(ctxt, (const unsigned char *) nonce,
                  curlx_uztoui(strlen(nonce)));
  Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
  Curl_MD5_update(ctxt, (const unsigned char *) cnonce,
                  curlx_uztoui(strlen(cnonce)));
  Curl_MD5_final(ctxt, digest);

  /* Convert calculated 16 octet hex into 32 bytes string */
  for(i = 0; i < MD5_DIGEST_LEN; i++)
    snprintf(&HA1_hex[2 * i], 3, "%02x", digest[i]);

  /* Generate our SPN */
  spn = Curl_auth_build_spn(service, realm, NULL);
  if(!spn)
    return CURLE_OUT_OF_MEMORY;

  /* Calculate H(A2) */
  ctxt = Curl_MD5_init(Curl_DIGEST_MD5);
  if(!ctxt) {
    free(spn);

    return CURLE_OUT_OF_MEMORY;
  }

  Curl_MD5_update(ctxt, (const unsigned char *) method,
                  curlx_uztoui(strlen(method)));
  Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
  Curl_MD5_update(ctxt, (const unsigned char *) spn,
                  curlx_uztoui(strlen(spn)));
  Curl_MD5_final(ctxt, digest);

  for(i = 0; i < MD5_DIGEST_LEN; i++)
    snprintf(&HA2_hex[2 * i], 3, "%02x", digest[i]);

  /* Now calculate the response hash */
  ctxt = Curl_MD5_init(Curl_DIGEST_MD5);
  if(!ctxt) {
    free(spn);

    return CURLE_OUT_OF_MEMORY;
  }

  Curl_MD5_update(ctxt, (const unsigned char *) HA1_hex, 2 * MD5_DIGEST_LEN);
  Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
  Curl_MD5_update(ctxt, (const unsigned char *) nonce,
                  curlx_uztoui(strlen(nonce)));
  Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);

  Curl_MD5_update(ctxt, (const unsigned char *) nonceCount,
                  curlx_uztoui(strlen(nonceCount)));
  Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
  Curl_MD5_update(ctxt, (const unsigned char *) cnonce,
                  curlx_uztoui(strlen(cnonce)));
  Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
  Curl_MD5_update(ctxt, (const unsigned char *) qop,
                  curlx_uztoui(strlen(qop)));
  Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);

  Curl_MD5_update(ctxt, (const unsigned char *) HA2_hex, 2 * MD5_DIGEST_LEN);
  Curl_MD5_final(ctxt, digest);

  for(i = 0; i < MD5_DIGEST_LEN; i++)
    snprintf(&resp_hash_hex[2 * i], 3, "%02x", digest[i]);

  /* Generate the response */
  response = aprintf("username=\"%s\",realm=\"%s\",nonce=\"%s\","
                     "cnonce=\"%s\",nc=\"%s\",digest-uri=\"%s\",response=%s,"
                     "qop=%s",
                     userp, realm, nonce,
                     cnonce, nonceCount, spn, resp_hash_hex, qop);
  free(spn);
  if(!response)
    return CURLE_OUT_OF_MEMORY;

  /* Base64 encode the response */
  result = Curl_base64_encode(data, response, 0, outptr, outlen);

  free(response);

  return result;
}

/*
 * Curl_auth_decode_digest_http_message()
 *
 * This is used to decode a HTTP DIGEST challenge message into the separate
 * attributes.
 *
 * Parameters:
 *
 * chlg    [in]     - The challenge message.
 * digest  [in/out] - The digest data struct being used and modified.
 *
 * Returns CURLE_OK on success.
 */
CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
                                              struct digestdata *digest)
{
  bool before = FALSE; /* got a nonce before */
  bool foundAuth = FALSE;
  bool foundAuthInt = FALSE;
  char *token = NULL;
  char *tmp = NULL;

  /* If we already have received a nonce, keep that in mind */
  if(digest->nonce)
    before = TRUE;

  /* Clean up any former leftovers and initialise to defaults */
  Curl_auth_digest_cleanup(digest);

  for(;;) {
    char value[DIGEST_MAX_VALUE_LENGTH];
    char content[DIGEST_MAX_CONTENT_LENGTH];

    /* Pass all additional spaces here */
    while(*chlg && ISSPACE(*chlg))
      chlg++;

    /* Extract a value=content pair */
    if(Curl_auth_digest_get_pair(chlg, value, content, &chlg)) {
      if(strcasecompare(value, "nonce")) {
        free(digest->nonce);
        digest->nonce = strdup(content);
        if(!digest->nonce)
          return CURLE_OUT_OF_MEMORY;
      }
      else if(strcasecompare(value, "stale")) {
        if(strcasecompare(content, "true")) {
          digest->stale = TRUE;
          digest->nc = 1; /* we make a new nonce now */
        }
      }
      else if(strcasecompare(value, "realm")) {
        free(digest->realm);
        digest->realm = strdup(content);
        if(!digest->realm)
          return CURLE_OUT_OF_MEMORY;
      }
      else if(strcasecompare(value, "opaque")) {
        free(digest->opaque);
        digest->opaque = strdup(content);
        if(!digest->opaque)
          return CURLE_OUT_OF_MEMORY;
      }
      else if(strcasecompare(value, "qop")) {
        char *tok_buf = NULL;
        /* Tokenize the list and choose auth if possible, use a temporary
           clone of the buffer since strtok_r() ruins it */
        tmp = strdup(content);
        if(!tmp)
          return CURLE_OUT_OF_MEMORY;

        token = strtok_r(tmp, ",", &tok_buf);
        while(token != NULL) {
          if(strcasecompare(token, DIGEST_QOP_VALUE_STRING_AUTH)) {
            foundAuth = TRUE;
          }
          else if(strcasecompare(token, DIGEST_QOP_VALUE_STRING_AUTH_INT)) {
            foundAuthInt = TRUE;
          }
          token = strtok_r(NULL, ",", &tok_buf);
        }

        free(tmp);

        /* Select only auth or auth-int. Otherwise, ignore */
        if(foundAuth) {
          free(digest->qop);
          digest->qop = strdup(DIGEST_QOP_VALUE_STRING_AUTH);
          if(!digest->qop)
            return CURLE_OUT_OF_MEMORY;
        }
        else if(foundAuthInt) {
          free(digest->qop);
          digest->qop = strdup(DIGEST_QOP_VALUE_STRING_AUTH_INT);
          if(!digest->qop)
            return CURLE_OUT_OF_MEMORY;
        }
      }
      else if(strcasecompare(value, "algorithm")) {
        free(digest->algorithm);
        digest->algorithm = strdup(content);
        if(!digest->algorithm)
          return CURLE_OUT_OF_MEMORY;

        if(strcasecompare(content, "MD5-sess"))
          digest->algo = CURLDIGESTALGO_MD5SESS;
        else if(strcasecompare(content, "MD5"))
          digest->algo = CURLDIGESTALGO_MD5;
        else if(strcasecompare(content, "SHA-256"))
          digest->algo = CURLDIGESTALGO_SHA256;
        else if(strcasecompare(content, "SHA-256-SESS"))
          digest->algo = CURLDIGESTALGO_SHA256SESS;
        else if(strcasecompare(content, "SHA-512-256"))
          digest->algo = CURLDIGESTALGO_SHA512_256;
        else if(strcasecompare(content, "SHA-512-256-SESS"))
          digest->algo = CURLDIGESTALGO_SHA512_256SESS;
        else
          return CURLE_BAD_CONTENT_ENCODING;
      }
      else if(strcasecompare(value, "userhash")) {
        if(strcasecompare(content, "true")) {
          digest->userhash = TRUE;
        }
      }
      else {
        /* Unknown specifier, ignore it! */
      }
    }
    else
      break; /* We're done here */

    /* Pass all additional spaces here */
    while(*chlg && ISSPACE(*chlg))
      chlg++;

    /* Allow the list to be comma-separated */
    if(',' == *chlg)
      chlg++;
  }

  /* We had a nonce since before, and we got another one now without
     'stale=true'. This means we provided bad credentials in the previous
     request */
  if(before && !digest->stale)
    return CURLE_BAD_CONTENT_ENCODING;

  /* We got this header without a nonce, that's a bad Digest line! */
  if(!digest->nonce)
    return CURLE_BAD_CONTENT_ENCODING;

  return CURLE_OK;
}

/*
 * _Curl_auth_create_digest_http_message()
 *
 * This is used to generate a HTTP DIGEST response message ready for sending
 * to the recipient.
 *
 * Parameters:
 *
 * data    [in]     - The session handle.
 * userp   [in]     - The user name.
 * passdwp [in]     - The user's password.
 * request [in]     - The HTTP request.
 * uripath [in]     - The path of the HTTP uri.
 * digest  [in/out] - The digest data struct being used and modified.
 * outptr  [in/out] - The address where a pointer to newly allocated memory
 *                    holding the result will be stored upon completion.
 * outlen  [out]    - The length of the output message.
 *
 * Returns CURLE_OK on success.
 */
static CURLcode _Curl_auth_create_digest_http_message(
                  struct Curl_easy *data,
                  const char *userp,
                  const char *passwdp,
                  const unsigned char *request,
                  const unsigned char *uripath,
                  struct digestdata *digest,
                  char **outptr, size_t *outlen,
                  void (*convert_to_ascii)(unsigned char *, unsigned char *),
                  void (*hash)(unsigned char *, const unsigned char *))
{
  CURLcode result;
  unsigned char hashbuf[32]; /* 32 bytes/256 bits */
  unsigned char request_digest[65];
  unsigned char *hashthis;
  unsigned char ha1[65];    /* 64 digits and 1 zero byte */
  unsigned char ha2[65];    /* 64 digits and 1 zero byte */
  char userh[65];
  char cnoncebuf[33];
  char *cnonce = NULL;
  size_t cnonce_sz = 0;
  char *userp_quoted;
  char *response = NULL;
  char *tmp = NULL;

  if(!digest->nc)
    digest->nc = 1;

  if(!digest->cnonce) {
    result = Curl_rand_hex(data, (unsigned char *)cnoncebuf,
                           sizeof(cnoncebuf));
    if(result)
      return result;

    result = Curl_base64_encode(data, cnoncebuf, strlen(cnoncebuf),
                                &cnonce, &cnonce_sz);
    if(result)
      return result;

    digest->cnonce = cnonce;
  }

  if(digest->userhash) {
    hashthis = (unsigned char *) aprintf("%s:%s", userp, digest->realm);
    if(!hashthis)
      return CURLE_OUT_OF_MEMORY;

    CURL_OUTPUT_DIGEST_CONV(data, hashthis);
    hash(hashbuf, hashthis);
    free(hashthis);
    convert_to_ascii(hashbuf, (unsigned char *)userh);
  }

  /*
    If the algorithm is "MD5" or unspecified (which then defaults to MD5):

      A1 = unq(username-value) ":" unq(realm-value) ":" passwd

    If the algorithm is "MD5-sess" then:

      A1 = H(unq(username-value) ":" unq(realm-value) ":" passwd) ":"
           unq(nonce-value) ":" unq(cnonce-value)
  */

  hashthis = (unsigned char *)
    aprintf("%s:%s:%s", digest->userhash ? userh : userp,
                                    digest->realm, passwdp);
  if(!hashthis)
    return CURLE_OUT_OF_MEMORY;

  CURL_OUTPUT_DIGEST_CONV(data, hashthis); /* convert on non-ASCII machines */
  hash(hashbuf, hashthis);
  free(hashthis);
  convert_to_ascii(hashbuf, ha1);

  if(digest->algo == CURLDIGESTALGO_MD5SESS ||
     digest->algo == CURLDIGESTALGO_SHA256SESS ||
     digest->algo == CURLDIGESTALGO_SHA512_256SESS) {
    /* nonce and cnonce are OUTSIDE the hash */
    tmp = aprintf("%s:%s:%s", ha1, digest->nonce, digest->cnonce);
    if(!tmp)
      return CURLE_OUT_OF_MEMORY;

    CURL_OUTPUT_DIGEST_CONV(data, tmp); /* Convert on non-ASCII machines */
    hash(hashbuf, (unsigned char *) tmp);
    free(tmp);
    convert_to_ascii(hashbuf, ha1);
  }

  /*
    If the "qop" directive's value is "auth" or is unspecified, then A2 is:

      A2 = Method ":" digest-uri-value

    If the "qop" value is "auth-int", then A2 is:

      A2 = Method ":" digest-uri-value ":" H(entity-body)

    (The "Method" value is the HTTP request method as specified in section
    5.1.1 of RFC 2616)
  */

  hashthis = (unsigned char *) aprintf("%s:%s", request, uripath);

  if(digest->qop && strcasecompare(digest->qop, "auth-int")) {
    /* We don't support auth-int for PUT or POST at the moment.
       TODO: replace hash of empty string with entity-body for PUT/POST */
    char hashed[65];
    unsigned char *hashthis2;

    hash(hashbuf, (const unsigned char *)"");
    convert_to_ascii(hashbuf, (unsigned char *)hashed);

    hashthis2 = (unsigned char *)aprintf("%s:%s", hashthis, hashed);
    free(hashthis);
    hashthis = hashthis2;
  }

  if(!hashthis)
    return CURLE_OUT_OF_MEMORY;

  CURL_OUTPUT_DIGEST_CONV(data, hashthis); /* convert on non-ASCII machines */
  hash(hashbuf, hashthis);
  free(hashthis);
  convert_to_ascii(hashbuf, ha2);

  if(digest->qop) {
    hashthis = (unsigned char *) aprintf("%s:%s:%08x:%s:%s:%s",
                                        ha1,
                                        digest->nonce,
                                        digest->nc,
                                        digest->cnonce,
                                        digest->qop,
                                        ha2);
  }
  else {
    hashthis = (unsigned char *) aprintf("%s:%s:%s",
                                        ha1,
                                        digest->nonce,
                                        ha2);
  }

  if(!hashthis)
    return CURLE_OUT_OF_MEMORY;

  CURL_OUTPUT_DIGEST_CONV(data, hashthis); /* convert on non-ASCII machines */
  hash(hashbuf, hashthis);
  free(hashthis);
  convert_to_ascii(hashbuf, request_digest);

  /* For test case 64 (snooped from a Mozilla 1.3a request)

     Authorization: Digest username="testuser", realm="testrealm", \
     nonce="1053604145", uri="/64", response="c55f7f30d83d774a3d2dcacf725abaca"

     Digest parameters are all quoted strings.  Username which is provided by
     the user will need double quotes and backslashes within it escaped.  For
     the other fields, this shouldn't be an issue.  realm, nonce, and opaque
     are copied as is from the server, escapes and all.  cnonce is generated
     with web-safe characters.  uri is already percent encoded.  nc is 8 hex
     characters.  algorithm and qop with standard values only contain web-safe
     characters.
  */
  userp_quoted = auth_digest_string_quoted(digest->userhash ? userh : userp);
  if(!userp_quoted)
    return CURLE_OUT_OF_MEMORY;

  if(digest->qop) {
    response = aprintf("username=\"%s\", "
                       "realm=\"%s\", "
                       "nonce=\"%s\", "
                       "uri=\"%s\", "
                       "cnonce=\"%s\", "
                       "nc=%08x, "
                       "qop=%s, "
                       "response=\"%s\"",
                       userp_quoted,
                       digest->realm,
                       digest->nonce,
                       uripath,
                       digest->cnonce,
                       digest->nc,
                       digest->qop,
                       request_digest);

    if(strcasecompare(digest->qop, "auth"))
      digest->nc++; /* The nc (from RFC) has to be a 8 hex digit number 0
                       padded which tells to the server how many times you are
                       using the same nonce in the qop=auth mode */
  }
  else {
    response = aprintf("username=\"%s\", "
                       "realm=\"%s\", "
                       "nonce=\"%s\", "
                       "uri=\"%s\", "
                       "response=\"%s\"",
                       userp_quoted,
                       digest->realm,
                       digest->nonce,
                       uripath,
                       request_digest);
  }
  free(userp_quoted);
  if(!response)
    return CURLE_OUT_OF_MEMORY;

  /* Add the optional fields */
  if(digest->opaque) {
    /* Append the opaque */
    tmp = aprintf("%s, opaque=\"%s\"", response, digest->opaque);
    free(response);
    if(!tmp)
      return CURLE_OUT_OF_MEMORY;

    response = tmp;
  }

  if(digest->algorithm) {
    /* Append the algorithm */
    tmp = aprintf("%s, algorithm=\"%s\"", response, digest->algorithm);
    free(response);
    if(!tmp)
      return CURLE_OUT_OF_MEMORY;

    response = tmp;
  }

  if(digest->userhash) {
    /* Append the userhash */
    tmp = aprintf("%s, userhash=true", response);
    free(response);
    if(!tmp)
      return CURLE_OUT_OF_MEMORY;

    response = tmp;
  }

  /* Return the output */
  *outptr = response;
  *outlen = strlen(response);

  return CURLE_OK;
}

/*
 * Curl_auth_create_digest_http_message()
 *
 * This is used to generate a HTTP DIGEST response message ready for sending
 * to the recipient.
 *
 * Parameters:
 *
 * data    [in]     - The session handle.
 * userp   [in]     - The user name.
 * passdwp [in]     - The user's password.
 * request [in]     - The HTTP request.
 * uripath [in]     - The path of the HTTP uri.
 * digest  [in/out] - The digest data struct being used and modified.
 * outptr  [in/out] - The address where a pointer to newly allocated memory
 *                    holding the result will be stored upon completion.
 * outlen  [out]    - The length of the output message.
 *
 * Returns CURLE_OK on success.
 */
CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
                                              const char *userp,
                                              const char *passwdp,
                                              const unsigned char *request,
                                              const unsigned char *uripath,
                                              struct digestdata *digest,
                                              char **outptr, size_t *outlen)
{
  switch(digest->algo) {
  case CURLDIGESTALGO_MD5:
  case CURLDIGESTALGO_MD5SESS:
    return _Curl_auth_create_digest_http_message(data, userp, passwdp,
                                                 request, uripath, digest,
                                                 outptr, outlen,
                                                 auth_digest_md5_to_ascii,
                                                 Curl_md5it);

  case CURLDIGESTALGO_SHA256:
  case CURLDIGESTALGO_SHA256SESS:
  case CURLDIGESTALGO_SHA512_256:
  case CURLDIGESTALGO_SHA512_256SESS:
    return _Curl_auth_create_digest_http_message(data, userp, passwdp,
                                                 request, uripath, digest,
                                                 outptr, outlen,
                                                 auth_digest_sha256_to_ascii,
                                                 Curl_sha256it);

  default:
    return CURLE_UNSUPPORTED_PROTOCOL;
  }
}

/*
 * Curl_auth_digest_cleanup()
 *
 * This is used to clean up the digest specific data.
 *
 * Parameters:
 *
 * digest    [in/out] - The digest data struct being cleaned up.
 *
 */
void Curl_auth_digest_cleanup(struct digestdata *digest)
{
  Curl_safefree(digest->nonce);
  Curl_safefree(digest->cnonce);
  Curl_safefree(digest->realm);
  Curl_safefree(digest->opaque);
  Curl_safefree(digest->qop);
  Curl_safefree(digest->algorithm);

  digest->nc = 0;
  digest->algo = CURLDIGESTALGO_MD5; /* default algorithm */
  digest->stale = FALSE; /* default means normal, not stale */
  digest->userhash = FALSE;
}
#endif  /* !USE_WINDOWS_SSPI */

#endif  /* CURL_DISABLE_CRYPTO_AUTH */


text:
<bill session="110" type="h" number="1794" updated="2009-01-08T20:35:46-05:00">
	<status><introduced date="1175140800" datetime="2007-03-29"/></status>

	<introduced date="1175140800" datetime="2007-03-29"/>
	<titles>
		<title type="short" as="introduced">Families Learning and Understanding English Together Act of 2007</title>
		<title type="official" as="introduced">To improve the literacy and English skills of limited English proficient individuals, and for other purposes.</title>
	</titles>
	<sponsor id="400162"/>
	<cosponsors>
		<cosponsor id="400133" joined="2007-06-27"/>
		<cosponsor id="400385" joined="2007-06-27"/>
		<cosponsor id="400344" joined="2007-05-09"/>
		<cosponsor id="400653" joined="2007-06-27"/>
		<cosponsor id="400185" joined="2007-06-27"/>
		<cosponsor id="400179" joined="2007-06-27"/>
	</cosponsors>
	<actions>
		<action date="1175140800" datetime="2007-03-29"><text>Referred to the House Committee on Education and Labor.</text></action>
		<action date="1183953600" datetime="2007-07-09"><text>Referred to the Subcommittee on Healthy Families and Communities.</text></action>
	</actions>
	<committees>

	</committees>
	<relatedbills>

	</relatedbills>
	<subjects>

	</subjects>
	<amendments>

	</amendments>
	<summary>
	3/29/2007--Introduced.<br/>Families Learning and Understanding English Together Act of 2007 - Authorizes the Secretary of Education to make grants to providers of family literacy services to improve the literacy and English skills of limited English proficient individuals who are parents or children in families where each parent is at least 16 years old and where at least one child is under age eight. Directs the Secretary to reserve certain funds to: (1) provide technical assistance and training to such grantees; (2) make grants to, or enter contracts with, national organizations that have family literacy service expertise to provide grantees with technical assistance and training; and (3) evaluate and improve such grant program. Requires grantees to meet specified outcome measures.
	</summary>
</bill>


text:
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**AssetVersions** | [**[]ServerlessV1AssetVersion**](ServerlessV1AssetVersion.md) |  |[optional]
**Meta** | [**ListAssetResponseMeta**](ListAssetResponseMeta.md) |  |[optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)