text:
@interface checkingPatterns()  <UICollisionBehaviorDelegate>

@end

@implementation checkingPatterns : UIView

-(id) initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    return self;
}

+(checkingPatterns *)  frameX:(CGFloat) x frameY: (CGFloat) y width: (CGFloat) w height: (CGFloat) h {

    checkingPatterns *frame = [[checkingPatterns alloc] initWithFrame:CGRectMake(x, y, w, h)];

    frame.height = h;
    frame.width = w;

    return frame;

}

-(void)runAnimationWithPatternSelected:(NSInteger)patternSelected{
    switch (patternSelected) {
        case 0:
            [self pattern0];
            break;
        case 1:
            [self pattern1];
            break;
        case 2:
            [self pattern2];
            break;
        case 3:
            [self pattern3];
            break;
        case 4:
            [self pattern4];
            break;
        case 5:
            [self pattern5];
            break;
        case 6:
            [self pattern6];
            break;
        case 7:
            [self patternWithImage:@"fractal" frames:11 duration:4.0 widthMultiplier:1 heightMultiplier:1 xPosition:0 yPosition:0 ];
            break;
        case 8:
            [self patternWithImage:@"bird" frames:27 duration:1.0 widthMultiplier:.2 heightMultiplier:.2 xPosition:_width*.4 yPosition:_height/2];
            break;
        case 9:
            [self patternWithImage:@"cowboy" frames:2 duration:0.5 widthMultiplier:0.3  heightMultiplier: 0.3  xPosition:_width*.3 yPosition:_height*.5];
            break;
        case 10:
            [self patternWithImage:@"Shark-Bingo" frames:140 duration:20 widthMultiplier:1 heightMultiplier:1 xPosition:0 yPosition:0];
            break;
        case 11:
            [self patternWithImage:@"Basketball-Bingo" frames:177 duration:15 widthMultiplier:1 heightMultiplier:1 xPosition:0 yPosition:0];
            break;
        case 12:
            [self newBaby];
            break;
        case 13:
            [self ballDrop];
            break;

        default:
            break;
    }
}

#pragma mark PATTERNS START HERE

-(void) pattern0 {
    //COMPLETE

    float discSizeMultiplier = 0.15;
    float fontSizeMultiplier = 0.2;

    CGFloat sizeOfDisc = discSizeMultiplier*_width;

    self.layer.borderColor = [[UIColor blueColor] CGColor];
    self.layer.borderWidth = 2;
    self.backgroundColor = [UIColor cyanColor];

    UIView *checkingTopView = [[UIView alloc] initWithFrame:CGRectMake(_width/2-sizeOfDisc/2,10, sizeOfDisc, sizeOfDisc)];
    checkingTopView.layer.cornerRadius = sizeOfDisc/2;
    checkingTopView.clipsToBounds = YES;

    checkingTopView.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    checkingTopView.layer.borderWidth = 2;

    UIView *checkingBottomView = [[UIView alloc] initWithFrame:CGRectMake(_width/2-sizeOfDisc/2,_height-10-sizeOfDisc, sizeOfDisc, sizeOfDisc)];

    checkingBottomView.layer.cornerRadius = sizeOfDisc/2;
    checkingBottomView.clipsToBounds = YES;

    checkingBottomView.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    checkingBottomView.layer.borderWidth = 2;

    [self addSubview:checkingTopView];
    [self addSubview:checkingBottomView];

    UILabel *labelBackground = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, _width, _height)];
    labelBackground.text = @"Hold Cards";
    labelBackground.font = [UIFont fontWithName:@"Helvetica" size:fontSizeMultiplier*_width];
    labelBackground.numberOfLines = 0;
    labelBackground.textColor = [UIColor yellowColor];
    labelBackground.textAlignment = NSTextAlignmentCenter;

    [self addSubview: labelBackground];

    CABasicAnimation *spinning = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
    //for backward text
    spinning.toValue = [NSNumber numberWithFloat:2*M_PI];
    //only forward text
    //spinning.toValue = [NSNumber numberWithFloat:.5*M_PI];

    spinning.autoreverses = YES;
    spinning.duration = 2;
    spinning.repeatCount = HUGE_VALF;

    CABasicAnimation *colorAnimation = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
    UIColor *fromColor = [UIColor redColor];
    UIColor *toColor = [UIColor greenColor];

    colorAnimation.duration = 1.0;
    colorAnimation.fromValue = (id)fromColor.CGColor;
    colorAnimation.toValue = (id)toColor.CGColor;
    colorAnimation.repeatCount = HUGE_VALF;
    colorAnimation.autoreverses = YES;

    CABasicAnimation *colorAnimation2 = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
    UIColor *fromColor2 = [UIColor greenColor];
    UIColor *toColor2 = [UIColor redColor];

    colorAnimation2.duration = 1.0;
    colorAnimation2.fromValue = (id)fromColor2.CGColor;
    colorAnimation2.toValue = (id)toColor2.CGColor;
    colorAnimation2.repeatCount = HUGE_VALF;
    colorAnimation2.autoreverses = YES;

    [checkingTopView.layer addAnimation:spinning forKey:nil];
    [checkingTopView.layer addAnimation:colorAnimation forKey:nil];

    [checkingBottomView.layer addAnimation:spinning forKey:nil];
    [checkingBottomView.layer addAnimation:colorAnimation2 forKey:nil];
}

-(void)pattern1 {
    //COMPLETE

    float letterDiscSize = _width/10;

    float textSize = _width/10;
    float topRow = _height*.45;
    float bottomRow = _height *.55;

    self.layer.borderColor = [[UIColor blueColor] CGColor];
    self.layer.borderWidth = 2;
    self.backgroundColor = [UIColor yellowColor];

    CABasicAnimation *shake = [CABasicAnimation animationWithKeyPath:@"transform.translation.y"];

    shake.toValue = [NSNumber numberWithFloat:10];
    shake.autoreverses = YES;
    shake.duration = 0.1;
    shake.repeatCount = HUGE_VALF;

    for (int c= 0; c<8; c++) {

        UILabel *letter = [[UILabel alloc]init];
        letter.font = [UIFont fontWithName:@"Courier" size:textSize];
        letter.textAlignment = NSTextAlignmentCenter;
                if (c%2) {
            letter.frame = CGRectMake(letterDiscSize*c+letterDiscSize, bottomRow, letterDiscSize,letterDiscSize);
        }
        else{
            letter.frame = CGRectMake(letterDiscSize*c+letterDiscSize,topRow, letterDiscSize,letterDiscSize);

        }

        letter.layer.cornerRadius = letterDiscSize/2;
        letter.clipsToBounds = YES;

        switch (c) {
            case 0:
                letter.text = @"C";
                letter.backgroundColor = [UIColor grayColor];
                break;
            case 1:
                letter.text = @"H";
                letter.backgroundColor = [UIColor redColor];
                break;
            case 2:
                letter.text = @"E";
                letter.backgroundColor = [UIColor greenColor];
                break;
            case 3:
                letter.text = @"C";
                letter.backgroundColor = [UIColor orangeColor];
                break;
            case 4:
                letter.text = @"K";
                letter.backgroundColor = [UIColor magentaColor];
                break;
            case 5:
                letter.text = @"I";
                letter.backgroundColor = [UIColor cyanColor];
                break;
            case 6:
                letter.text = @"N";
                letter.backgroundColor = [UIColor brownColor];
                break;
            case 7:
                letter.text = @"G";
                letter.backgroundColor = [UIColor lightGrayColor];
                break;

            default:
                break;
        }

        [self addSubview:letter];

        [letter.layer addAnimation:shake forKey:nil];
        [self sendSubviewToBack:letter];

    }
    UILabel *labelHold = [[UILabel alloc] initWithFrame:CGRectMake(_width*.1, _height*.1, _width*.8, _height*.2)];
    labelHold.text = @"Hold Cards";
    labelHold.backgroundColor = [UIColor whiteColor];
    labelHold.textColor = [UIColor redColor];
    labelHold.font = [UIFont fontWithName:@"Arial" size:_height*.2];
    labelHold.layer.borderColor = [[UIColor redColor] CGColor];
    labelHold.layer.borderWidth = 3;
    labelHold.textAlignment =NSTextAlignmentCenter;
    labelHold.numberOfLines = 0;
    labelHold.layer.cornerRadius = _height*.2/5;
    labelHold.clipsToBounds = YES;

    [self addSubview:labelHold];

}

-(void)pattern2 {

    //COMPLETE
    float letterDiscSize = _width/10;
    float topRow = _height*.0;
    float bottomRow = _height *.05;
    float letterWidth = _width/10;
    float labelFontSize = _height*.2;
    float diskFontSize = _height * .1;
    float moveRange = _height*.8;

    self.layer.borderColor = [[UIColor blueColor] CGColor];
    self.layer.borderWidth = 2;
    self.backgroundColor = [UIColor yellowColor];

    CABasicAnimation *moveUpAndDown = [CABasicAnimation animationWithKeyPath:@"transform.translation.y" ];
    [moveUpAndDown setFromValue:[NSNumber numberWithFloat:0]];
    [moveUpAndDown setByValue:[NSNumber numberWithFloat:moveRange]];
    [moveUpAndDown setBeginTime:CACurrentMediaTime() ];
    [moveUpAndDown setDuration:2];
    moveUpAndDown.removedOnCompletion = NO;
    moveUpAndDown.autoreverses = YES;
    moveUpAndDown.fillMode = kCAFillModeForwards;
    moveUpAndDown.repeatCount =HUGE_VALF;

    UILabel *labelBackground = [[UILabel alloc] initWithFrame:CGRectMake(_width*.1, 0, _width*.8, _height)];
    labelBackground.text = @"Hold Cards\nHold Cards\nHold Cards\nHold Cards";
    labelBackground.font = [UIFont fontWithName:@"Helvetica" size:labelFontSize];
    labelBackground.numberOfLines = 0;
    labelBackground.textColor = [UIColor redColor];
    labelBackground.textAlignment = NSTextAlignmentCenter;

    [self addSubview: labelBackground];
    [self bringSubviewToFront:labelBackground];

    for (int c= 0; c<8; c++) {

        UILabel *letter = [[UILabel alloc]init];
        letter.font = [UIFont fontWithName:@"Courier" size:diskFontSize];
        letter.textAlignment = NSTextAlignmentCenter;
        if (c%2) {
            letter.frame = CGRectMake(letterDiscSize+letterDiscSize*c, topRow, letterDiscSize, letterDiscSize);
        }
        else{
            letter.frame = CGRectMake(letterWidth+letterWidth*c, bottomRow, letterDiscSize, letterDiscSize);

        }

        letter.layer.cornerRadius = letterDiscSize/2;
        letter.clipsToBounds = YES;

        switch (c) {
            case 0:
                letter.text = @"C";
                letter.backgroundColor = [UIColor whiteColor];
                break;
            case 1:
                letter.text = @"H";
                letter.backgroundColor = [UIColor redColor];
                break;
            case 2:
                letter.text = @"E";
                letter.backgroundColor = [UIColor greenColor];
                break;
            case 3:
                letter.text = @"C";
                letter.backgroundColor = [UIColor orangeColor];
                break;
            case 4:
                letter.text = @"K";
                letter.backgroundColor = [UIColor magentaColor];
                break;
            case 5:
                letter.text = @"I";
                letter.backgroundColor = [UIColor cyanColor];
                break;
            case 6:
                letter.text = @"N";
                letter.backgroundColor = [UIColor brownColor];
                break;
            case 7:
                letter.text = @"G";
                letter.backgroundColor = [UIColor lightGrayColor];
                break;

            default:
                break;
        }

        [self addSubview:letter];

        [letter.layer addAnimation:moveUpAndDown forKey:nil];

        }

}

-(void)pattern3{
    //COMPLETE
    float letterDiscSize = _width/10;
    float topRow = _height*.0;

    float labelFontSize = _height*.2;
    float diskFontSize = _height * .1;
    float moveRange = _height*.85;

    self.layer.borderColor = [[UIColor blueColor] CGColor];
    self.layer.borderWidth = 2;
    self.backgroundColor = [UIColor whiteColor];

    UILabel *labelBackground = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, _width, _height)];
    labelBackground.text = @"Hold Cards\nHold Cards\nHold Cards\nHold Cards";
    labelBackground.font = [UIFont fontWithName:@"Helvetica" size:labelFontSize];
    labelBackground.numberOfLines = 0;
    labelBackground.textColor = [UIColor yellowColor];
    labelBackground.textAlignment = NSTextAlignmentCenter;

    [self addSubview: labelBackground];

    CABasicAnimation *moveDown = [CABasicAnimation animationWithKeyPath:@"transform.translation.y" ];
    [moveDown setFromValue:[NSNumber numberWithFloat:0]];
    [moveDown setByValue:[NSNumber numberWithFloat:moveRange]];
    [moveDown setBeginTime:CACurrentMediaTime()];
    [moveDown setDuration:2];
    moveDown.removedOnCompletion = NO;
    moveDown.autoreverses = YES;
    moveDown.fillMode = kCAFillModeForwards;
    moveDown.repeatCount =HUGE_VALF;

    for (int c= 0; c<8; c++) {

        UILabel *letter = [[UILabel alloc]init];
        letter.font = [UIFont fontWithName:@"Courier" size:diskFontSize];
        letter.textAlignment = NSTextAlignmentCenter;
        letter.frame = CGRectMake(letterDiscSize+letterDiscSize*c,topRow, letterDiscSize, letterDiscSize);
        letter.layer.cornerRadius = letterDiscSize/2;
        letter.clipsToBounds = YES;

        switch (c) {
            case 0:
                letter.text = @"C";
                letter.backgroundColor = [UIColor yellowColor];
                [moveDown setBeginTime:CACurrentMediaTime()+c];
                [letter.layer addAnimation:moveDown forKey:nil];

                break;
            case 1:
                letter.text = @"H";
                letter.backgroundColor = [UIColor redColor];
                [moveDown setBeginTime:CACurrentMediaTime()+c];
                [letter.layer addAnimation:moveDown forKey:nil];
                break;
            case 2:
                letter.text = @"E";
                letter.backgroundColor = [UIColor greenColor];
                [moveDown setBeginTime:CACurrentMediaTime()+c];
                [letter.layer addAnimation:moveDown forKey:nil];

                break;
            case 3:
                letter.text = @"C";
                letter.backgroundColor = [UIColor orangeColor];
                [moveDown setBeginTime:CACurrentMediaTime()+c];
                [letter.layer addAnimation:moveDown forKey:nil];

                break;
            case 4:
                letter.text = @"K";
                letter.backgroundColor = [UIColor magentaColor];
                [moveDown setBeginTime:CACurrentMediaTime()+c];
                [letter.layer addAnimation:moveDown forKey:nil];

                break;
            case 5:
                letter.text = @"I";
                letter.backgroundColor = [UIColor cyanColor];
                [moveDown setBeginTime:CACurrentMediaTime()+c];
                [letter.layer addAnimation:moveDown forKey:nil];

                break;
            case 6:
                letter.text = @"N";
                letter.backgroundColor = [UIColor brownColor];
                [moveDown setBeginTime:CACurrentMediaTime()+c];
                [letter.layer addAnimation:moveDown forKey:nil];

                break;
            case 7:
                letter.text = @"G";
                letter.backgroundColor = [UIColor lightGrayColor];
                [moveDown setBeginTime:CACurrentMediaTime()+c];
                [letter.layer addAnimation:moveDown forKey:nil];

                break;

            default:
                break;
        }

        [self addSubview:letter];

    }

}

-(void)pattern4 {
    //COMPLETE

    UIColor *fromColor = [UIColor cyanColor];
    UIColor *toColor = [UIColor blueColor];
    float duration = 5;
    float labelFontSize = _height*.35;

    self.layer.borderColor = [[UIColor blueColor] CGColor];
    self.layer.borderWidth = 2;
    self.backgroundColor = [UIColor whiteColor];

    UILabel *labelBackground = [[UILabel alloc] initWithFrame:CGRectMake(_width*.1, 0, _width*.8, _height)];
    labelBackground.text = @"Hold Cards";
    labelBackground.font = [UIFont fontWithName:@"Helvetica" size:labelFontSize];
    labelBackground.numberOfLines = 0;
    labelBackground.textColor = [UIColor redColor];
    labelBackground.textAlignment = NSTextAlignmentCenter;

    [self addSubview: labelBackground];

    CABasicAnimation *colorAnimation = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];

    colorAnimation.duration = duration  ;
    colorAnimation.fromValue = (id)fromColor.CGColor;
    colorAnimation.toValue = (id)toColor.CGColor;
    colorAnimation.repeatCount = HUGE_VALF;
    colorAnimation.autoreverses = YES;

    [self.layer addAnimation:colorAnimation forKey:nil];

    }

-(void)pattern5 {
    //COMPLETE

    self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"floral.jpg"]];

    float labelFontSize = _height*.2;
    UIColor *fromColor = [UIColor redColor];
    UIColor *toColor = [UIColor greenColor];

    self.layer.borderColor = [[UIColor blueColor] CGColor];
    self.layer.borderWidth = 2;
    //self.backgroundColor = [UIColor cyanColor];

    UILabel *checkingTopLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, _width, _height/2)];
    checkingTopLabel.text = @"Checking";
    checkingTopLabel.font = [UIFont fontWithName:@"Courier" size:labelFontSize];
    checkingTopLabel.textAlignment = NSTextAlignmentCenter;
    checkingTopLabel.layer.cornerRadius = 25;
    checkingTopLabel.clipsToBounds = YES;

    checkingTopLabel.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    checkingTopLabel.layer.borderWidth = 2;

    UILabel *checkingBottomLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, _height/2, _width, _height/2)];
    checkingBottomLabel.text = @"Hold\nYour Cards";
    checkingBottomLabel.font = [UIFont fontWithName:@"Courier" size:labelFontSize];
    checkingBottomLabel.numberOfLines = 0;
    checkingBottomLabel.lineBreakMode = NSLineBreakByWordWrapping;
    checkingBottomLabel.textAlignment = NSTextAlignmentCenter;
    checkingBottomLabel.layer.cornerRadius = 25;
    checkingBottomLabel.clipsToBounds = YES;

    checkingBottomLabel.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    checkingBottomLabel.layer.borderWidth = 2;

    [self addSubview:checkingTopLabel];
    [self addSubview:checkingBottomLabel];

    CABasicAnimation *spinning = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
    //for backward text
    spinning.toValue = [NSNumber numberWithFloat:2*M_PI];
    //only forward text
    //spinning.toValue = [NSNumber numberWithFloat:.5*M_PI];

    spinning.autoreverses = YES;
    spinning.duration = 4;
    spinning.repeatCount = HUGE_VALF;

    CABasicAnimation *colorAnimation = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];

    colorAnimation.duration = 2.0;
    colorAnimation.fromValue = (id)fromColor.CGColor;
    colorAnimation.toValue = (id)toColor.CGColor;
    colorAnimation.repeatCount = HUGE_VALF;
    colorAnimation.autoreverses = YES;

    CABasicAnimation *colorAnimation2 = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
    UIColor *fromColor2 = [UIColor greenColor];
    UIColor *toColor2 = [UIColor redColor];

    colorAnimation2.duration = 2.0;
    colorAnimation2.fromValue = (id)fromColor2.CGColor;
    colorAnimation2.toValue = (id)toColor2.CGColor;
    colorAnimation2.repeatCount = HUGE_VALF;
    colorAnimation2.autoreverses = YES;

    [checkingTopLabel.layer addAnimation:spinning forKey:nil];
    [checkingTopLabel.layer addAnimation:colorAnimation forKey:nil];

    [checkingBottomLabel.layer addAnimation:spinning forKey:nil];
    [checkingBottomLabel.layer addAnimation:colorAnimation2 forKey:nil];

}

-(void)pattern6 {
    //COMPLETE

    self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"steel1.jpg"]];

    float labelFontSize = _height*.2;
    float spinDuration = 1;
    float colorDuration = 2;
    UIColor *fromColor = [UIColor whiteColor];
    UIColor *toColor = [UIColor blackColor];

    UIColor *fromColor2 = [UIColor blackColor];
    UIColor *toColor2 = [UIColor whiteColor];

    UIColor *labelTextColor = [UIColor redColor];

    self.layer.borderColor = [[UIColor blueColor] CGColor];
    self.layer.borderWidth = 2;
 //   self.backgroundColor = [UIColor lightGrayColor];

    UILabel *checkingTopLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, _width, _height/2)];
    checkingTopLabel.text = @"Checking";
    checkingTopLabel.font = [UIFont fontWithName:@"Courier" size:labelFontSize];
    checkingTopLabel.textColor = labelTextColor;

    checkingTopLabel.textAlignment = NSTextAlignmentCenter;
    checkingTopLabel.layer.cornerRadius = 25;
    checkingTopLabel.clipsToBounds = YES;

    checkingTopLabel.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    checkingTopLabel.layer.borderWidth = 2;

    UILabel *checkingBottomLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, _height/2, _width, _height/2)];
    checkingBottomLabel.text = @"Hold\nYour Cards";
    checkingBottomLabel.font = [UIFont fontWithName:@"Courier" size:labelFontSize];
    checkingBottomLabel.textColor = labelTextColor;
    checkingBottomLabel.lineBreakMode = NSLineBreakByWordWrapping;
    checkingBottomLabel.numberOfLines = 0;
    checkingBottomLabel.textAlignment = NSTextAlignmentCenter;
    checkingBottomLabel.layer.cornerRadius = 25;
    checkingBottomLabel.clipsToBounds = YES;

    checkingBottomLabel.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    checkingBottomLabel.layer.borderWidth = 2;

    [self addSubview:checkingTopLabel];
    [self addSubview:checkingBottomLabel];

    CABasicAnimation *spinning = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
    //for backward text
   // spinning.toValue = [NSNumber numberWithFloat:2*M_PI];
    //only forward text
    spinning.toValue = [NSNumber numberWithFloat:.5*M_PI];

    spinning.autoreverses = YES;
    spinning.duration = spinDuration;
    spinning.repeatCount = HUGE_VALF;

    CABasicAnimation *colorAnimation = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];

    colorAnimation.duration = colorDuration;
    colorAnimation.fromValue = (id)fromColor.CGColor;
    colorAnimation.toValue = (id)toColor.CGColor;
    colorAnimation.repeatCount = HUGE_VALF;
    colorAnimation.autoreverses = YES;

    CABasicAnimation *colorAnimation2 = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];

    colorAnimation2.duration = colorDuration;
    colorAnimation2.fromValue = (id)fromColor2.CGColor;
    colorAnimation2.toValue = (id)toColor2.CGColor;
    colorAnimation2.repeatCount = HUGE_VALF;
    colorAnimation2.autoreverses = YES;

    [checkingTopLabel.layer addAnimation:spinning forKey:nil];
    [checkingTopLabel.layer addAnimation:colorAnimation forKey:nil];

    [checkingBottomLabel.layer addAnimation:spinning forKey:nil];
    [checkingBottomLabel.layer addAnimation:colorAnimation2 forKey:nil];

}

-(void)patternWithImage: (NSString *)imageID frames:(NSInteger)frames duration:(float)duration widthMultiplier:(float)widthMult heightMultiplier: (float)heightMult xPosition: (float)xPos yPosition: (float)yPos{
    //COMPLETE

    self.layer.borderColor = [[UIColor blueColor] CGColor];
    self.layer.borderWidth = 2;
    self.backgroundColor = [UIColor cyanColor];

    UILabel *labelHold = [[UILabel alloc] initWithFrame:CGRectMake(_width*.1, _height*.8, _width*.8, _height*.2)];
    labelHold.text = @"Hold Cards";
    labelHold.backgroundColor = [UIColor clearColor];
    labelHold.textColor = [UIColor redColor];
    labelHold.font = [UIFont fontWithName:@"Arial" size:_height*.2];
    labelHold.layer.borderColor = [[UIColor redColor] CGColor];
    labelHold.layer.borderWidth = 3;
    labelHold.textAlignment =NSTextAlignmentCenter;
    labelHold.numberOfLines = 0;
    labelHold.layer.cornerRadius = _height*.2/5;
    labelHold.clipsToBounds = YES;

    [self addSubview:labelHold];
    [self bringSubviewToFront:labelHold];

    NSString *imageName;
    //NSMutableArray *arrayImages = [[NSMutableArray alloc] init];
    NSMutableArray *arrayImages = [NSMutableArray array];

    for (int x=1; x<=frames; x++) {
        imageName = [NSString stringWithFormat:@"%@%i",imageID,x];

        //[arrayImages addObject:[UIImage imageNamed:imageName]];

        [arrayImages addObject:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:imageName ofType:@"png"]]];

    }

    UIImageView *animationView = [[UIImageView alloc] initWithFrame:CGRectMake(xPos,yPos, _width*widthMult, _height*heightMult)];
    animationView.animationImages = arrayImages;
    animationView.animationDuration = duration;
    [self addSubview:animationView];
    [animationView startAnimating];

    [self bringSubviewToFront:labelHold];

     }

-(void)newBaby{

    float babyWidth = _width/5;
    float babyHeight = babyWidth;
    float moveUpRange = _height*0.05;
    float moveDownRange = _height*-.05;
    float moveRightRange = 100.0f;
    float moveLeftRange =  -100.0f;

    float startTime = 5;

    float XstartBaby1 = _width/2- babyWidth/2;
    float XstartBaby2 = _width/4- babyWidth/2;
    float XstartBaby3 = _width*3/4- babyWidth/2;
    float YstartBaby1 = _height * .7;

    self.layer.borderColor = [[UIColor blueColor] CGColor];
    self.layer.borderWidth = 2;
    self.backgroundColor = [UIColor cyanColor];

    UIGraphicsBeginImageContext(self.frame.size);
    [[UIImage imageNamed:@"stageBaby.png"] drawInRect:self.bounds];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    self.backgroundColor = [UIColor colorWithPatternImage:image];

    CABasicAnimation *fadeIn = [CABasicAnimation animationWithKeyPath:@"opacity"];
    fadeIn.duration = 0.1f;
    fadeIn.fromValue = [NSNumber numberWithFloat:0.0f];
    fadeIn.toValue = [NSNumber numberWithFloat:1.0f];
    [fadeIn setBeginTime:CACurrentMediaTime()+2];
    fadeIn.removedOnCompletion = YES;
    fadeIn.fillMode = kCAFillModeForwards;

    CABasicAnimation *fadeOut = [CABasicAnimation animationWithKeyPath:@"opacity"];
    fadeOut.duration = 5.0f;
    fadeOut.fromValue = [NSNumber numberWithFloat:1.0f];
    fadeOut.toValue = [NSNumber numberWithFloat:0.0f];
    [fadeOut setBeginTime:CACurrentMediaTime()+5];
    fadeOut.removedOnCompletion = YES;
    fadeOut.fillMode = kCAFillModeForwards;

    CABasicAnimation *moveUp = [CABasicAnimation animationWithKeyPath:@"transform.translation.y" ];
    [moveUp setByValue:[NSNumber numberWithFloat:moveUpRange]];
    moveUp.removedOnCompletion = NO;

    CABasicAnimation *moveDown = [CABasicAnimation animationWithKeyPath:@"transform.translation.y"];
    [moveUp setByValue:[NSNumber numberWithFloat:moveDownRange]];
    moveDown.removedOnCompletion = NO;

    CAKeyframeAnimation *shrink = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
    shrink.values =@[@1,@.75];
    shrink.autoreverses = NO;

    CAKeyframeAnimation *enlarge = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
    enlarge.values = @[@1,@1.25];
    enlarge.autoreverses = NO;

    CABasicAnimation *moveLeft = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
    [moveLeft setByValue:[NSNumber numberWithFloat:moveLeftRange]];
    moveLeft.autoreverses = NO;

    CABasicAnimation *moveRight = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
    [moveRight setByValue:[NSNumber numberWithFloat:moveRightRange]];
    moveRight.autoreverses = NO;

    CAKeyframeAnimation *rotation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation"];
    rotation.values = @[@0,@(M_PI*4)];
    rotation.autoreverses = YES;
    rotation.repeatCount = 0;

    _babyImages = [NSMutableArray array];

    for (int i= 1; i<15; i++) {
        NSString *objectName = [NSString stringWithFormat:@"baby%d",i];
        [_babyImages addObject:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:objectName ofType:@"png"]]];

        //Using imageWithContentsOfFile instead of imageNamed to allow memory usage to clear

    }

    _baby1Frame = [[UIImageView alloc] initWithFrame:CGRectMake(XstartBaby1, YstartBaby1, babyWidth, babyHeight)];
    _baby1Frame.animationImages = _babyImages;
    _baby1Frame.animationDuration = 3;
    [_baby1Frame startAnimating];

    _baby2Frame = [[UIImageView alloc] initWithFrame:CGRectMake(XstartBaby2, YstartBaby1, babyWidth, babyHeight)];
    _baby2Frame.animationImages = _babyImages;
    _baby2Frame.animationDuration = 3;
    [_baby2Frame startAnimating];

    _baby3Frame = [[UIImageView alloc] initWithFrame:CGRectMake(XstartBaby3, YstartBaby1, babyWidth, babyHeight)];
    _baby3Frame.animationImages = _babyImages;
    _baby3Frame.animationDuration = 3;
    [_baby3Frame startAnimating];

    [self addSubview:_baby1Frame];
    [self addSubview:_baby2Frame];
    [self addSubview:_baby3Frame];

    CAAnimationGroup *group1 = [[CAAnimationGroup alloc] init];
    [group1 setAnimations: [NSArray arrayWithObjects: moveLeft, nil]];
    [group1 setDuration:3.0];
    [group1 setBeginTime:CACurrentMediaTime()+1+startTime];
    group1.fillMode = kCAFillModeForwards;
    group1.removedOnCompletion = NO;

   CAAnimationGroup *group2 = [[CAAnimationGroup alloc] init];
    [group2 setAnimations:[NSArray arrayWithObjects:moveRight,nil]];
    [group2 setDuration:3.0];
    [group2 setBeginTime:CACurrentMediaTime()+4+startTime];
    group2.fillMode = kCAFillModeForwards;
    group2.removedOnCompletion = NO;

    CAAnimationGroup *group3 = [[CAAnimationGroup alloc] init];
    [group3 setAnimations:[NSArray arrayWithObjects:moveRight,nil]];
    [group3 setDuration:3.0];
   [group3 setBeginTime:CACurrentMediaTime()+7+startTime];
    group3.fillMode = kCAFillModeForwards;
    group3.removedOnCompletion = NO;

    CAAnimationGroup *group4 = [[CAAnimationGroup alloc] init];
    [group4 setAnimations:[NSArray arrayWithObjects:moveLeft,nil]];
    [group4 setDuration:3.0];
    [group4 setBeginTime:CACurrentMediaTime()+10+startTime];
    group4.fillMode = kCAFillModeForwards;
    group4.removedOnCompletion = NO;

    CAAnimationGroup *group5 = [[CAAnimationGroup alloc]init];
    [group5 setAnimations:[NSArray arrayWithObjects:shrink,moveUp,nil]];
    [group5 setDuration:3.0];
    [group5 setBeginTime:CACurrentMediaTime()+13+startTime];
    group5.fillMode = kCAFillModeForwards;
    group5.removedOnCompletion = NO;

    CAAnimationGroup *group6 = [[CAAnimationGroup alloc]init];
    [group6 setAnimations:[NSArray arrayWithObjects:moveLeft,nil]];
    [group6 setDuration:2.0];
    [group6 setBeginTime:CACurrentMediaTime()+16+startTime];
     group6.fillMode = kCAFillModeForwards;
     group6.removedOnCompletion = NO;

    CAAnimationGroup *group7 = [[CAAnimationGroup alloc]init];
    [group7 setAnimations:[NSArray arrayWithObjects:moveRight,nil]];
    [group7 setDuration:2.0];
    [group7 setBeginTime:CACurrentMediaTime()+19+startTime];
    group7.fillMode = kCAFillModeForwards;
    group7.removedOnCompletion = NO;

    CAAnimationGroup *group8 = [[CAAnimationGroup alloc]init];
    [group8 setAnimations:[NSArray arrayWithObjects:moveRight,nil]];
    [group8 setDuration:2.0];
    [group8 setBeginTime:CACurrentMediaTime()+21+startTime];
    group8.fillMode = kCAFillModeForwards;
    group8.removedOnCompletion = NO;

    CAAnimationGroup *group9 = [[CAAnimationGroup alloc]init];
    [group9 setAnimations:[NSArray arrayWithObjects:moveLeft,nil]];
    [group9 setDuration:2.0];
    [group9 setBeginTime:CACurrentMediaTime()+23+startTime];
    group9.fillMode = kCAFillModeForwards;
    group9.removedOnCompletion = NO;

   [_baby1Frame.layer addAnimation:group1 forKey:nil];
   [_baby1Frame.layer addAnimation:group2 forKey:nil];
   [_baby1Frame.layer addAnimation:group3 forKey:nil];
   [_baby1Frame.layer addAnimation:group4 forKey:nil];
   [_baby1Frame.layer addAnimation:group5 forKey:nil];
   [_baby1Frame.layer addAnimation:group6 forKey:nil];
   [_baby1Frame.layer addAnimation:group7 forKey:nil];
   [_baby1Frame.layer addAnimation:group8 forKey:nil];
   [_baby1Frame.layer addAnimation:group9 forKey:nil];

    [_baby2Frame.layer addAnimation:group1 forKey:nil];
    [_baby2Frame.layer addAnimation:group2 forKey:nil];
    [_baby2Frame.layer addAnimation:group3 forKey:nil];
    [_baby2Frame.layer addAnimation:group4 forKey:nil];
    [_baby2Frame.layer addAnimation:group5 forKey:nil];

    [_baby3Frame.layer addAnimation:group1 forKey:nil];
    [_baby3Frame.layer addAnimation:group2 forKey:nil];
    [_baby3Frame.layer addAnimation:group3 forKey:nil];
    [_baby3Frame.layer addAnimation:group4 forKey:nil];
    [_baby3Frame.layer addAnimation:group5 forKey:nil];
  }

#pragma mark BALL CODES

-(void) ballDrop {

    _gameOver = 0;

        float pegSize = _width/20;

    self.backgroundColor = [UIColor yellowColor];

    _banner.alpha = 1;
    _banner = [[UILabel alloc] initWithFrame:CGRectMake(_width*.25,_height*.05, _width*.5, _height*.2)];
    _banner.text = @"Pick The Color";
    _banner.textColor = [UIColor blueColor];
    _banner.font = [UIFont fontWithName:@"Chalkboard SE" size:_height*.1];
    _banner.textAlignment = NSTextAlignmentCenter;

    [self addSubview:_banner];

    _animator = [[UIDynamicAnimator alloc] initWithReferenceView:self];

    //tap gesture

    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)];
    [self addGestureRecognizer:tapGesture];

    //Gravity

    _gravityBehavior = [[UIGravityBehavior alloc] initWithItems:@[]];
    _gravityBehavior.magnitude = 1;
    [_animator addBehavior:_gravityBehavior];

    //Collision

    _collisionBehavior = [[UICollisionBehavior alloc] initWithItems:@[]];
    _collisionBehavior.translatesReferenceBoundsIntoBoundary = YES;

    [_animator addBehavior:_collisionBehavior];

    //Bounce

    _bounceBehavior = [[UIDynamicItemBehavior alloc] initWithItems:@[ ] ];
    _bounceBehavior.elasticity = 1;
    [_animator addBehavior:_bounceBehavior];

    _bounceBehaviorDense = [[UIDynamicItemBehavior alloc] initWithItems:@[ ] ];
    _bounceBehaviorDense.density = 100000;
    [_animator addBehavior:_bounceBehaviorDense];

    [_pushBehavior removeItem:_ball];

    _ballReleasePointX = 400;

    //set up grid

    for (int count =1; count <20; count ++) {
        int ylevel = 0;
        int xlevel = 0;
        int xstart = self.bounds.origin.x;
        int xgap = _width/7;

        if (count<=6) {
            ylevel = _height*.3;
            xlevel = xstart + xgap *count;
            if (count&2) {
                _obstacleColor = [UIColor cyanColor];
            }
            else {_obstacleColor = [UIColor magentaColor];}
        }
        if (count>6 && count <=12){
            ylevel  = _height*.5;
            xlevel  =  xstart + xgap * (count-7)+xgap;
            if( count&1){
                _obstacleColor = [UIColor cyanColor];}
        }else {
            _obstacleColor = [UIColor magentaColor];
        }

        if (count>12) {
            ylevel = _height*.7;
            xlevel  = (xstart + xgap) + (xgap * (count-13.5));

            if (count&1) {
                _obstacleColor = [UIColor magentaColor];
            }
            else {
                _obstacleColor = [UIColor cyanColor];
            }

        }

        UIView *obstacles = [[UIView alloc] initWithFrame:CGRectMake(xlevel, ylevel, pegSize,pegSize)];

        CGAffineTransform affineTransform = CGAffineTransformMakeRotation(M_PI_4);
        obstacles.transform = affineTransform;

        obstacles.backgroundColor = _obstacleColor;

        [self addSubview:obstacles];
        [_collisionBehavior addItem:obstacles];
        [_bounceBehaviorDense addItem:obstacles];

    }

    //add the boxes,
    float boxHeight = _height*.15;
    float boxYValue = _height-boxHeight;
    float fontSize = boxHeight * .4;

    _labelDads = [[UILabel alloc] initWithFrame:CGRectMake(0, boxYValue, _width/4, boxHeight)];
    _labelDads.backgroundColor =[UIColor blueColor];
    _labelDads.text = @"Blue";
    _labelDads.font = [UIFont fontWithName:@"Chalkboard SE" size:fontSize];
    _labelDads.textColor = [UIColor whiteColor];
    _labelDads.textAlignment = NSTextAlignmentCenter;
    _labelDads.numberOfLines = 0;

    _labelLower = [[UILabel alloc] initWithFrame:CGRectMake(_width*.25, boxYValue, _width/4, boxHeight)];
    _labelLower.backgroundColor =[UIColor redColor];
    _labelLower.text = @"Red";
    _labelLower.font = [UIFont fontWithName:@"Chalkboard SE" size:fontSize];
    _labelLower.textColor = [UIColor whiteColor];
    _labelLower.textAlignment = NSTextAlignmentCenter;
    _labelLower.numberOfLines = 0;

    _labelMiddle = [[UILabel alloc] initWithFrame:CGRectMake(_width*.5, boxYValue, _width/4, boxHeight)];
    _labelMiddle.backgroundColor =[UIColor greenColor];
    _labelMiddle.text = @"Green";
    _labelMiddle.font = [UIFont fontWithName:@"Chalkboard SE" size:fontSize];
    _labelMiddle.textColor = [UIColor whiteColor];
    _labelMiddle.textAlignment = NSTextAlignmentCenter;
    _labelMiddle.numberOfLines = 0;

    _labelMoms = [[UILabel alloc] initWithFrame:CGRectMake(_width*.75, boxYValue, _width/4, boxHeight)];
    _labelMoms.backgroundColor =[UIColor orangeColor];
    _labelMoms.text = @"Orange";
    _labelMoms.font = [UIFont fontWithName:@"Chalkboard SE" size:fontSize];
    _labelMoms.textColor = [UIColor whiteColor];
    _labelMoms.textAlignment = NSTextAlignmentCenter;
    _labelMoms.numberOfLines = 0;

    [self addSubview:_labelDads];
    [self addSubview:_labelLower];
    [self addSubview:_labelMiddle];
    [self addSubview:_labelMoms];

    [self releaseBall];

}

-(void)releaseBall {

    int high = _width*.8;
    int low = _width*.2;

    _ballReleasePointX = arc4random() % (high-low+1) + low;

    [self timingMethod];
    //[_bounceBehaviorDense removeItem:_ball];
    _bounceBehavior.elasticity = 1;

    float kballSize = _width/20;

    _ball = [[UIView alloc] initWithFrame:CGRectMake(_ballReleasePointX - kballSize/2, 0, kballSize, kballSize)];

    _ball.layer.borderColor = [[UIColor blackColor] CGColor];
    _ball.layer.borderWidth = 1;

    _ball.backgroundColor = [UIColor darkGrayColor];
    _ball.layer.cornerRadius = kballSize/2;
    _ball.layer.masksToBounds = YES;

    _ball.alpha = 1;
    [self addSubview:_ball];
    [_gravityBehavior addItem:_ball];
    [_collisionBehavior addItem:_ball];
    [_pushBehavior addItem:_ball];
    [_bounceBehavior addItem:_ball];

    [self bringSubviewToFront:_labelDads];
    [self bringSubviewToFront:_labelLower];
    [self bringSubviewToFront:_labelMiddle];
    [self bringSubviewToFront:_labelMoms];

    _collisionBehavior.collisionDelegate = self;

}

-(void)timingMethod {

    //be sure to use [ballTimer invalidate] when moving to winner program!!

    ballTimer = [NSTimer scheduledTimerWithTimeInterval:.1
                                                 target:self
                                               selector:@selector(checkPosition)
                                               userInfo:nil repeats:YES];
}

-(void)checkPosition {

    if (_ball.frame.origin.y>_height*.75 && _ball.frame.origin.x<=_width*.25-_ball.frame.size.width/2) {
        _pointsDads = _pointsDads + 1;
        _strPointsDads = [NSString stringWithFormat:@"Blue: %d",_pointsDads];
        _labelDads.text = _strPointsDads;

        _banner.alpha = 1;
        _banner.text = @"Blue!";
        _banner.backgroundColor =[UIColor blueColor];
        _banner.textColor = [UIColor whiteColor];

        [_ball removeFromSuperview];
        [ballTimer invalidate];
        ballTimer = NULL;
        if (_pointsDads<5) {
            [self releaseBall];
        }
        else {
            _banner.text = @"Blue Wins";
            _gameOver = 1;
        }

    }

    if (_ball.frame.origin.y>_height*.75 && _ball.frame.origin.x>_width*.25 && _ball.frame.origin.x <= _width*.5-_ball.frame.size.width/2) {
        _pointsLower = _pointsLower + 1;
        _strPointsLower = [NSString stringWithFormat:@"Red: %d",_pointsLower];
        _labelLower.text = _strPointsLower;

        _banner.alpha = 1;
        _banner.text = @"Red!";
        _banner.backgroundColor =[UIColor redColor];
        _banner.textColor = [UIColor whiteColor];

        [_ball removeFromSuperview];

        [_ball removeFromSuperview];
        [ballTimer invalidate];
        ballTimer = NULL;

        if (_pointsLower<5) {
            [self releaseBall];
        }
        else {
            _banner.text = @"Red Wins";
            _gameOver = 1;
        }

    }

    if (_ball.frame.origin.y>_height*.75 && _ball.frame.origin.x>_width*.5 && _ball.frame.origin.x <= _width*.75-_ball.frame.size.width/2) {
        _pointsMiddle = _pointsMiddle + 1;
        _strPointsMiddle = [NSString stringWithFormat:@"Green: %d",_pointsMiddle];
        _labelMiddle.text = _strPointsMiddle;

        _banner.alpha = 1;
        _banner.text = @"Green!";
        _banner.backgroundColor =[UIColor greenColor];
        _banner.textColor = [UIColor whiteColor];

        [_ball removeFromSuperview];
        [ballTimer invalidate];
        ballTimer = NULL;

        if (_pointsMiddle<5) {
            [self releaseBall];
        }
        else {
            _banner.text = @"Green Wins";
            _gameOver = 1;
        }

    }
    if (_ball.frame.origin.y>_height*.75 && _ball.frame.origin.x>_width*.75 && _ball.frame.origin.x <= _width-_ball.frame.size.width/2) {
        _pointsMoms = _pointsMoms + 1;
        _strPointsMoms = [NSString stringWithFormat:@"Orange: %d",_pointsMoms];
        _labelMoms.text = _strPointsMoms;

        _banner.alpha = 1;
        _banner.text = @"Orange!";
        _banner.backgroundColor =[UIColor orangeColor];
        _banner.textColor = [UIColor whiteColor];

        [_ball removeFromSuperview];
        [ballTimer invalidate];
        ballTimer = NULL;

        if (_pointsMoms<5) {
            [self releaseBall];
        }
        else {
            _banner.text = @"Orange Wins";
            _gameOver =1;
        }

    }
    if (_gameOver == 0)  {
        [UIView animateWithDuration:3 animations:^{
            self->_banner.alpha = 0;
        }];
    }

}

-(void)onTap:(UIGestureRecognizer *)gesture {
    if (gesture.state == UIGestureRecognizerStateEnded) {

        [self pushBall];

    }
}

-(void)pushBall{

    _pushBehavior = [[UIPushBehavior alloc] initWithItems:@[] mode:UIPushBehaviorModeInstantaneous];
    _pushBehavior.magnitude =0.5;
    _pushBehavior.angle = M_2_PI/2;
    [_pushBehavior addItem:_ball];

    [_animator addBehavior:_pushBehavior];

}

@end


text:
/**
 * Job description configuration package.
 */
@XmlSchema(namespace = "org.spotter.shared.configuration", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package org.spotter.shared.configuration;

import javax.xml.bind.annotation.XmlSchema;

redpajama_set_name: RedPajamaGithub


text:
// Auto generated from makesdna dna.c
#ifndef __BULLET_BTRIGIDBODYDOUBLEDATA__H__
#define __BULLET_BTRIGIDBODYDOUBLEDATA__H__

// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btCollisionObjectDoubleData.h"
#include "bullet_btMatrix3x3DoubleData.h"
#include "bullet_btVector3DoubleData.h"

namespace Bullet {

    // ---------------------------------------------- //
    class btRigidBodyDoubleData
    {
    public:
        btCollisionObjectDoubleData m_collisionObjectData;
        btMatrix3x3DoubleData m_invInertiaTensorWorld;
        btVector3DoubleData m_linearVelocity;
        btVector3DoubleData m_angularVelocity;
        btVector3DoubleData m_angularFactor;
        btVector3DoubleData m_linearFactor;
        btVector3DoubleData m_gravity;
        btVector3DoubleData m_gravity_acceleration;
        btVector3DoubleData m_invInertiaLocal;
        btVector3DoubleData m_totalForce;
        btVector3DoubleData m_totalTorque;
        double m_inverseMass;
        double m_linearDamping;
        double m_angularDamping;
        double m_additionalDampingFactor;
        double m_additionalLinearDampingThresholdSqr;
        double m_additionalAngularDampingThresholdSqr;
        double m_additionalAngularDampingFactor;
        double m_linearSleepingThreshold;
        double m_angularSleepingThreshold;
        int m_additionalDamping;
        char m_padding[4];
    };
}

#endif//__BULLET_BTRIGIDBODYDOUBLEDATA__H__


text:
namespace boost {
namespace histogram {
namespace detail {

template <class A, class... Us>
optional_index at(const A& axes, const std::tuple<Us...>& args) noexcept {
  optional_index idx{0}; // offset not used by linearize_index
  mp11::mp_for_each<mp11::mp_iota_c<sizeof...(Us)>>(
      [&, stride = static_cast<std::size_t>(1)](auto i) mutable {
        stride *= linearize_index(idx, stride, axis_get<i>(axes),
                                  static_cast<axis::index_type>(std::get<i>(args)));
      });
  return idx;
}

template <class A, class U>
optional_index at(const A& axes, const U& args) noexcept {
  optional_index idx{0};
  using std::begin;
  for_each_axis(axes, [&, it = begin(args),
                       stride = static_cast<std::size_t>(1)](const auto& a) mutable {
    stride *= linearize_index(idx, stride, a, static_cast<axis::index_type>(*it++));
  });
  return idx;
}

} // namespace detail
} // namespace histogram
} // namespace boost

#endif


text:
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE321_Hard_Coded_Cryptographic_Key__w32_char_61b.c
Label Definition File: CWE321_Hard_Coded_Cryptographic_Key__w32.label.xml
Template File: sources-sink-61b.tmpl.c
*/
/*
 * @description
 * CWE: 321 Use of Hard-coded Cryptographic Key
 * BadSource:  Copy a hardcoded value into cryptoKey
 * GoodSource: Read cryptoKey from the console
 * Sinks:
 *    BadSink : Hash cryptoKey and use the value to encrypt a string
 * Flow Variant: 61 Data flow: data returned from one function to another in different source files
 *
 * */

#include "std_testcase.h"

#define CRYPTO_KEY "Hardcoded"

#include <windows.h>
#include <wincrypt.h>

/* Link with the Advapi32.lib file for Crypt* functions */
#pragma comment (lib, "Advapi32")

#ifndef OMITBAD

char * CWE321_Hard_Coded_Cryptographic_Key__w32_char_61b_badSource(char * cryptoKey)
{
    /* FLAW: Use a hardcoded value for the hash input causing a hardcoded crypto key in the sink */
    strcpy(cryptoKey, CRYPTO_KEY);
    return cryptoKey;
}

#endif /* OMITBAD */

#ifndef OMITGOOD

/* goodG2B() uses the GoodSource with the BadSink */
char * CWE321_Hard_Coded_Cryptographic_Key__w32_char_61b_goodG2BSource(char * cryptoKey)
{
    {
        size_t cryptoKeyLen = strlen(cryptoKey);
        /* if there is room in cryptoKey, read into it from the console */
        if(100-cryptoKeyLen > 1)
        {
            /* FIX: Obtain the hash input from the console */
            if (fgets(cryptoKey+cryptoKeyLen, (int)(100-cryptoKeyLen), stdin) == NULL)
            {
                printLine("fgets() failed");
                /* Restore NUL terminator if fgets fails */
                cryptoKey[cryptoKeyLen] = '\0';
            }
            /* The next 3 lines remove the carriage return from the string that is
             * inserted by fgets() */
            cryptoKeyLen = strlen(cryptoKey);
            if (cryptoKeyLen > 0)
            {
                cryptoKey[cryptoKeyLen-1] = '\0';
            }
        }
    }
    return cryptoKey;
}

#endif /* OMITGOOD */


text:
package mimepattern

//#cgo pkg-config: cairo
//#include <cairo/cairo.h>
import "C"

type mime string

//These are the MIME types libcairo supports for embedding.
const (
	//PNG is the Portable Network Graphics image file format (ISO/IEC 15948).
	//
	//Originally CAIRO_MIME_TYPE_PNG.
	PNG mime = "image/png"
	//JPEG is the Joint Photographic Experts Group (JPEG) image coding standard
	//(ISO/IEC 10918-1).
	//
	//Originally CAIRO_MIME_TYPE_JPEG.
	JPEG mime = "image/jpeg"
	//JP2 is the Joint Photographic Experts Group (JPEG) 2000 image coding standard
	//(ISO/IEC 15444-1).
	//
	//Originally CAIRO_MIME_TYPE_JP2.
	JP2 mime = "image/jp2"

	uri mime = "text/x-uri"
)

func (m mime) valid() bool {
	switch m {
	case PNG, JPEG, JP2:
		return true
	}
	return false
}

func (m mime) s() string {
	return string(m)
}

var m2c = map[mime]*C.char{
	PNG:  C.CString(PNG.s()),
	JPEG: C.CString(JPEG.s()),
	JP2:  C.CString(JP2.s()),
	uri:  C.CString(uri.s()),
}

func (m mime) c() (cs *C.char) {
	return m2c[m]
}


text:
"""
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

Written (W) 2013 Heiko Strathmann
Written (W) 2013 Dino Sejdinovic
"""

echo collecting list of to be stopped jobs
qstat | grep ucabhst | awk '{printf "qdel %s\n",$1}' > temp.sh

echo stopping jobs
sh temp.sh

echo cleaning up
rm temp.sh


text:
package Paws::Config::GetResourceConfigHistoryResponse;
  use Moose;
  has ConfigurationItems => (is => 'ro', isa => 'ArrayRef[Paws::Config::ConfigurationItem]', traits => ['NameInRequest'], request_name => 'configurationItems' );
  has NextToken => (is => 'ro', isa => 'Str', traits => ['NameInRequest'], request_name => 'nextToken' );

  has _request_id => (is => 'ro', isa => 'Str');

### main pod documentation begin ###

=head1 NAME

Paws::Config::GetResourceConfigHistoryResponse

=head1 ATTRIBUTES

=head2 ConfigurationItems => ArrayRef[L<Paws::Config::ConfigurationItem>]

A list that contains the configuration history of one or more
resources.

=head2 NextToken => Str

The string that you use in a subsequent request to get the next page of
results in a paginated response.

=head2 _request_id => Str

=cut

1;


text:
<?php
/**
 * User: Alex Gusev <alex@flancer64.com>
 */

namespace Praxigento\Odoo\Api\Web\Product\Replicate\Save;

/**
 * Save product inventory data to Magento (push replication).
 *
 * (Define getters explicitly to use with Swagger tool)
 * (Define setters explicitly to use with Magento JSON2PHP conversion tool)
 */
class Request
    extends \Praxigento\Core\Api\App\Web\Request
{

    /**
     * @return \Praxigento\Odoo\Api\Web\Product\Replicate\Save\Request\Data
     */
    public function getData()
    {
        $result = parent::get(self::DATA);
        return $result;
    }

    /**
     * @param \Praxigento\Odoo\Api\Web\Product\Replicate\Save\Request\Data $data
     * @return void
     */
    public function setData($data)
    {
        parent::set(self::DATA, $data);
    }
}


text:
<?php

/**
 * API Class, K1.lib.
 *
 * Class for define API REST
 * @author J0hnD03 <alejandro.trujillo@klan1.com>
 * @version 0.1
 * @package api
 */

namespace k1lib\api;

use \k1lib\urlrewrite\url;
use \k1lib\crudlexs\class_db_table;

const K1LIB_API_USE_MAGIC_HEADER = TRUE;
const K1LIB_API_DISABLE_MAGIC_HEADER = FALSE;
const K1LIB_API_USE_TOKEN = TRUE;
const K1LIB_API_DISABLE_TOKEN = FALSE;

class api {

    protected $allow_methods = 'POST,GET,PUT,DELETE';

    // DB conection object

    /**
     * @var \k1lib\db\PDO_k1
     */
    protected $db = NULL;
    protected $do_debug = FALSE;

    /**
     *
     * @var \k1lib\crudlexs\class_db_table
     */
    protected $debug_table = FALSE;
    // MAGIC HEADER
    protected $magic_header = NULL;
    protected $use_magic_header = FALSE;
    // TOKEN
    protected $token = NULL;
    protected $use_token = TRUE;
    // INPUT
    protected $request_method = NULL;
    protected $input_data = NULL;
    // OUTPUT

    /**
     * @var boolean
     */
    protected $do_send_response = TRUE;

    /**
     * @var boolean
     */
    protected $read_input_return_array = TRUE;
    /*
     * @var array
     */
    protected $reponse_data = [];

    public function __construct($use_token = FALSE, $use_magic_header = FALSE) {
        /**
         * OUT PUT BUFFER START
         */
        if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
            ob_start('ob_gzhandler');
        } else {
            ob_start();
        }

        header('Access-Control-Allow-Methods: ' . $this->allow_methods);
        header("Access-Control-Allow-Origin: *");
        header("Access-Control-Allow-Headers: X-K1app-Api-Token,X-K1app-Magic-header,X-K1app-Api-Request-mode");

        /**
         * API config
         */
        $this->use_magic_header = $use_magic_header;
        $this->use_token = $use_token;
        $this->request_method = $_SERVER['REQUEST_METHOD'];
    }

    public function exec($send_response = TRUE) {
        $this->do_send_response = $send_response;
        // Clear all possible previous output buffer
        switch ($_SERVER['REQUEST_METHOD']) {
            case 'GET':
                return $this->get();
            case 'POST':
                return $this->post();
            case 'PUT':
                return $this->put();
            case 'DELETE':
                return $this->delete();
        }
    }

    protected function read_input() {
        $http_headers = getallheaders();
        /**
         * TODO: implements token
         */
        if ($this->use_token) {
            $this->api_token = $http_headers['X-K1app-Api-Token'];
            if (empty($this->api_token)) {
                $this->send_response(401, [$http_headers], ['message' => 'Invalid token']);
                return FALSE;
            }
        }
        /**
         * TODO: implements the magic header
         */
        if ($this->use_magic_header) {
            $this->magic_header = $http_headers['X-K1app-Magic-Header'];
            if (empty($this->magic_header)) {
                $this->send_response(401, [$http_headers], ['message' => 'x-magic-value is not fount with the correct magic value']);
                return FALSE;
            }
        }
        // IF EVERYTHING ITS OK, THEN LOAD THE DATA
        $input_data = json_decode(file_get_contents("php://input"), $this->read_input_return_array);
        if ($input_data) {
            $this->input_data = $input_data;
        } else {
            $this->input_data = NULL;
        }
        if ($this->do_debug) {
            header('X-k1app-using-debug: yes');
            $error = null;
            $this->debug_table->insert_data(
                    [
                        'api_node' => $_SERVER['QUERY_STRING'],
                        'data' => $_SERVER['REQUEST_METHOD'] . ':' . file_get_contents("php://input"),
                        'direction' => 'in',
                        'user_ip' => $_SERVER['REMOTE_ADDR'],
                        'user_agent' => $_SERVER['HTTP_USER_AGENT'],
                        'http_headers' => print_r(getallheaders(), TRUE),
                    ]
                    , $error);
            if ($error) {
                header('X-k1app-debug-error: ' . $error);
            }
        }
    }

    public function get_input() {
        return $this->input_data;
    }

    public function send_response($code, $data, $extra = null) {
        http_response_code($code);
        /**
         * TODO: make selectable the allow methods
         */
        header("Content-Type: application/json; charset=utf-8");
        header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
        header("Last-Modified: {now} GMT");
        header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate");

        /**
         * HTTP STATUS OUT SELECTION
         */
        $local_response_data = [];
        if ($code >= 200 && $code <= 299) {
            $local_response_data['status'] = 'success';
        } elseif ($code >= 400) {
            $this->send_response = TRUE;
            $local_response_data['status'] = 'error';
        }
        $local_response_data['data'] = $data;
        if ($extra) {
            $local_response_data['extra'] = $extra;
        }

        /**
         * OUTPUT BUFFER
         */
        $php_out = ob_get_contents();
        ob_end_clean();
        if (!empty($php_out)) {
            $this->reponse_data['phpOut'] = $php_out;
        }

        /**
         * FINAL API OUTPUT
         */
        $response_array = array_merge($local_response_data, $this->reponse_data);

        if ($this->do_send_response) {
            $response = json_encode($response_array, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
            if ($this->do_debug) {
                header('X-k1app-using-debug: yes');
                $error = null;
                $this->debug_table->insert_data(
                        [
                            'api_node' => url::get_this_url(),
                            'data' => $response,
                            'direction' => 'out',
                            'user_ip' => $_SERVER['REMOTE_ADDR'],
                            'user_agent' => $_SERVER['HTTP_USER_AGENT'],
                        ]
                        , $error);
                if ($error) {
                    header('X-k1app-debug-error: ' . $error);
                }
            }
            echo $response;
            die();
        } else {
            return $response_array;
        }
    }

    public function get() {
        $this->read_input();
    }

    public function post() {
        $this->read_input();
    }

    public function put() {
        $this->read_input();
    }

    public function delete() {
        $this->read_input();
    }

    protected function check_input($array_to_check) {
        return $array_to_check;
    }

    function set_db(\k1lib\db\PDO_k1 $db) {
        $this->db = $db;
    }

    protected function get_url_value() {
        return url::set_url_rewrite_var(url::get_url_level_count(), 'level_' . url::get_url_level_count());
    }

    public function do_debug($table_name = 'debug_log') {
        if ($this->db) {
            $this->do_debug = true;
            $this->debug_table = new class_db_table($this->db, $table_name);
        }
    }

    function set_do_send_response($send_response) {
        $this->send_response = $send_response;
    }

}


text:
package thredds.inventory;

import com.google.common.base.MoreObjects;
import org.slf4j.Logger;
import ucar.nc2.time.CalendarDate;
import ucar.nc2.util.CloseableIterator;
import java.util.ArrayList;
import java.util.List;

/**
 * Collection defined by a list of files, with a [start, end) date range
 *
 * @author caron
 * @since 12/23/2014
 */
public class CollectionListRange extends CollectionAbstract {
  private final List<MFile> mfiles = new ArrayList<>();
  private final CalendarDate startDate, endDate;

  public CollectionListRange(String collectionName, String root, CalendarDate startDate, CalendarDate endDate,
      Logger logger) {
    super(collectionName, logger);
    setRoot(root);
    this.startDate = startDate;
    this.endDate = endDate;
  }

  public CalendarDate getStartDate() {
    return startDate;
  }

  public CalendarDate getEndDate() {
    return endDate;
  }

  public void addFile(MFile mfile) {
    mfiles.add(mfile);
  }

  @Override
  public Iterable<MFile> getFilesSorted() {
    return mfiles;
  }

  @Override
  public CloseableIterator<MFile> getFileIterator() {
    return new MFileIterator(mfiles.iterator(), null);
  }

  @Override
  public void close() {}

  @Override
  public String toString() {
    return MoreObjects.toStringHelper(this).add("collectionName", collectionName).add("startDate", startDate)
        .add("endDate", endDate).toString();
  }
}


text:
title: "Home"
permalink: /
layout: default
classes:
  - home
---

    <meta itemprop="headline" content="Home">
    <meta itemprop="description" content="Luminaire Consultancy">

We are a York based evaluation and research consultancy dedicated to helping organisations demonstrate the value of the projects and services they deliver. We carry out tailor made evaluations and applied research to support service sustainability and development.

Evaluation

To enable you to effectively communicate the difference your work has made, we provide a wide range of evaluation services.

Read More

Research

Working across private, public and third sectors we use qualitative and quantitive techniques to examine and explore your research questions.

Read More

Advice

For organisations completing their own evaluations and research, we can provide tailored support and guidance.

Read More


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--
  #%L
  igniter
  %%
  Copyright (C) 2013 Adam Bien
  %%
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#L%
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>ch.theband.benno</groupId>
    <artifactId>probeplaner</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>probeplaner</name>
    <url>https://github.com/saxmaster79/probeplaner</url>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>com.airhacks</groupId>
            <artifactId>afterburner.fx</artifactId>
            <version>1.6.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>
        <dependency>
          <groupId>org.apache.pdfbox</groupId>
          <artifactId>pdfbox</artifactId>
          <version>[2.0.12,)</version>
        </dependency>
        <dependency>
            <groupId>com.miglayout</groupId>
            <artifactId>miglayout-javafx</artifactId>
            <version>LATEST</version>
        </dependency>
        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>1.4.8</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <!-- POI : Excel library -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.17</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.17</version>
        </dependency>
    </dependencies>
    <build>
        <defaultGoal>clean package</defaultGoal>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <excludeScope>system</excludeScope>
                            <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
                            <outputDirectory>${project.build.directory}/classes</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <id>package-jar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${env.JAVA_HOME}/bin/javafxpackager</executable>
                            <arguments>
                                <argument>-createjar</argument>
                                <argument>-nocss2bin</argument>
                                <argument>-appclass</argument>
                                <argument>ch.theband.benno.probeplaner.App</argument>
                                <argument>-srcdir</argument>
                                <argument>${project.build.directory}/classes</argument>
                                <argument>-outdir</argument>
                                <argument>.</argument>
                                <argument>-outfile</argument>
                                <argument>${project.artifactId}-app</argument>
                                <argument>-v</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.fxml</include>
                    <include>**/*.css</include>
                    <include>**/*.properties</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
        </resources>
    </build>
    <properties>
        <maven.compiler.source>1.9</maven.compiler.source>
        <maven.compiler.target>1.9</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>


text:
package infodynamics.measures.continuous;

/**
 *
This specifies the interface for implementations of
 *  the transfer entropy (see Schreiber, PRL, 2000)
 *  and local transfer entropy (see Lizier et al, PRE, 2008).
 *  This is the apparent transfer entropy; i.e.
 *  we compute the transfer that appears to come from a single
 *  source variable, without examining any other potential sources
 *  (see Lizier et al, PRE, 2008).

 *
 *
Specifically, this specifies the interface for computing
 * the transfer entropy for continuous-valued variables.

 *
 * @see "Schreiber, Physical Review Letters 85 (2) pp.461-464, 2000;
 *  download
 *  (for definition of transfer entropy)"
 * @see "Lizier, Prokopenko and Zomaya, Physical Review E 77, 026110, 2008;
 * download
 *  (for definition of local transfer entropy and qualification
 *  of naming it as apparent transfer entropy)"
 *
 * @author Joseph Lizier, email,
 * www
 *
 */
public interface TransferEntropyCalculator extends ChannelCalculator {

	/**
	 * Property name to specify the history length k
	 */
	public static final String K_PROP_NAME = "k_HISTORY";

	/**
	 * Initialise the calculator for re-use with new observations.
	 * A new history length k can be supplied here; all other parameters
	 * remain unchanged.
	 *
	 * @param k history length to be considered.
	 * @throws Exception
	 */
	public void initialise(int k) throws Exception;

}


text:
'use strict';

// See: https://github.com/sindresorhus/electron-boilerplate/blob/master/boilerplate/index.js

const {app, BrowserWindow, globalShortcut} = require('electron');

// Prevent window being garbage collected
let mainWindow;

function createMainWindow() {
  const win = new BrowserWindow({ width: 1024, height: 768 });
  win.loadURL(`file://${__dirname}/index.html`);
  win.on('closed', () => {
    mainWindow = null;
  });

  globalShortcut.register('F12', () => win.toggleDevTools());
  return win;
}

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('activate', () => {
  if (!mainWindow) {
    mainWindow = createMainWindow();
  }
});

app.on('ready', () => {
  mainWindow = createMainWindow();
});


text:
<?php

namespace Rezzza\GoogleGeocoder;

use Ivory\HttpAdapter\HttpAdapterInterface;
use Ivory\HttpAdapter\HttpAdapterException;

/**
 * @author Sébastien HOUZÉ <sebastien.houze@verylastroom.com>
 *
 * @see https://developers.google.com/maps/documentation/geocoding
 *
 */
class GoogleGeocodeClient
{
    const ENDPOINT_URL_GEOCODE = 'https://maps.googleapis.com/maps/api/geocode/json';
    const ENDPOINT_URL_PLACE_DETAILS = 'https://maps.googleapis.com/maps/api/place/details/json';
    const STATUS_OK = 'OK';

    private $apiKey;

    private $adapter;

    public function __construct(HttpAdapterInterface $adapter, $apiKey = null)
    {
        $this->adapter = $adapter;
        $this->apiKey = $apiKey;
    }

    public function executeQuery(array $queryParams)
    {
        $url = $this->buildUrl($queryParams);
        try {
            $response = $this->adapter->get($url);

            if ($response->getStatusCode() >= 400) {
                throw new Exception\GoogleGeocodeProtocolException(
                    $response->getReasonPhrase(),
                    $response->getStatusCode()
                );
            }

            $content = (string) $response->getBody();
            $json = json_decode($content, true);

            if (null === $json) {
                throw new Exception\GoogleGeocodeResponseDecodeException(
                    json_last_error_msg(), json_last_error()
                );
            }

            if (!array_key_exists('status', $json) || self::STATUS_OK !== $json['status']) {
                throw Exception\GoogleGeocodeException::fromStatusAndErrorMessage(
                    $json['status'],
                    array_key_exists('error_message', $json) ? $json['error_message'] : null
                );
            }

            return $json;
        } catch (HttpAdapterException $e) {
            throw new Exception\GoogleGeocodeProtocolException($e->getMessage(), $e->getCode(), $e);
        }
    }

    private function buildUrl(array $queryParams)
    {
        $queryString = http_build_query(
            array_merge(
                array_filter(
                    [
                        'key' => $this->apiKey
                    ]
                ),
                $queryParams
            )
        );

        return http_build_url(
            $this->guessEndpointUrl($queryParams),
            ['query' => $queryString]
        );
    }

    private function guessEndpointUrl($queryParams)
    {
        // Because google provide much more translated info
        // on placeDetails endpoint we switch to
        // Google place details compatible payload for
        // search by place id
        if (array_key_exists('placeid', $queryParams)) {
            return self::ENDPOINT_URL_PLACE_DETAILS;
        }

        return self::ENDPOINT_URL_GEOCODE;
    }
}


text:
import cPickle as pickle
import mock
import os
import unittest
from contextlib import closing
from gzip import GzipFile
from shutil import rmtree
from tempfile import mkdtemp
from test.unit import FakeLogger

from eventlet import spawn, Timeout, listen

from swift.common import utils
from swift.container import updater as container_updater
from swift.container.backend import ContainerBroker, DATADIR
from swift.common.ring import RingData
from swift.common.utils import normalize_timestamp

class TestContainerUpdater(unittest.TestCase):

    def setUp(self):
        utils.HASH_PATH_SUFFIX = 'endcap'
        utils.HASH_PATH_PREFIX = 'startcap'
        self.testdir = os.path.join(mkdtemp(), 'tmp_test_container_updater')
        rmtree(self.testdir, ignore_errors=1)
        os.mkdir(self.testdir)
        ring_file = os.path.join(self.testdir, 'account.ring.gz')
        with closing(GzipFile(ring_file, 'wb')) as f:
            pickle.dump(
                RingData([[0, 1, 0, 1], [1, 0, 1, 0]],
                         [{'id': 0, 'ip': '127.0.0.1', 'port': 12345,
                           'device': 'sda1', 'zone': 0},
                          {'id': 1, 'ip': '127.0.0.1', 'port': 12345,
                           'device': 'sda1', 'zone': 2}], 30),
                f)
        self.devices_dir = os.path.join(self.testdir, 'devices')
        os.mkdir(self.devices_dir)
        self.sda1 = os.path.join(self.devices_dir, 'sda1')
        os.mkdir(self.sda1)

    def tearDown(self):
        rmtree(os.path.dirname(self.testdir), ignore_errors=1)

    def test_creation(self):
        cu = container_updater.ContainerUpdater({
            'devices': self.devices_dir,
            'mount_check': 'false',
            'swift_dir': self.testdir,
            'interval': '1',
            'concurrency': '2',
            'node_timeout': '5',
        })
        self.assert_(hasattr(cu, 'logger'))
        self.assert_(cu.logger is not None)
        self.assertEquals(cu.devices, self.devices_dir)
        self.assertEquals(cu.interval, 1)
        self.assertEquals(cu.concurrency, 2)
        self.assertEquals(cu.node_timeout, 5)
        self.assert_(cu.get_account_ring() is not None)

    def test_run_once(self):
        cu = container_updater.ContainerUpdater({
            'devices': self.devices_dir,
            'mount_check': 'false',
            'swift_dir': self.testdir,
            'interval': '1',
            'concurrency': '1',
            'node_timeout': '15',
            'account_suppression_time': 0
        })
        cu.run_once()
        containers_dir = os.path.join(self.sda1, DATADIR)
        os.mkdir(containers_dir)
        cu.run_once()
        self.assert_(os.path.exists(containers_dir))
        subdir = os.path.join(containers_dir, 'subdir')
        os.mkdir(subdir)
        cb = ContainerBroker(os.path.join(subdir, 'hash.db'), account='a',
                             container='c')
        cb.initialize(normalize_timestamp(1), 0)
        cu.run_once()
        info = cb.get_info()
        self.assertEquals(info['object_count'], 0)
        self.assertEquals(info['bytes_used'], 0)
        self.assertEquals(info['reported_object_count'], 0)
        self.assertEquals(info['reported_bytes_used'], 0)

        cb.put_object('o', normalize_timestamp(2), 3, 'text/plain',
                      '68b329da9893e34099c7d8ad5cb9c940')
        cu.run_once()
        info = cb.get_info()
        self.assertEquals(info['object_count'], 1)
        self.assertEquals(info['bytes_used'], 3)
        self.assertEquals(info['reported_object_count'], 0)
        self.assertEquals(info['reported_bytes_used'], 0)

        def accept(sock, addr, return_code):
            try:
                with Timeout(3):
                    inc = sock.makefile('rb')
                    out = sock.makefile('wb')
                    out.write('HTTP/1.1 %d OK\r\nContent-Length: 0\r\n\r\n' %
                              return_code)
                    out.flush()
                    self.assertEquals(inc.readline(),
                                      'PUT /sda1/0/a/c HTTP/1.1\r\n')
                    headers = {}
                    line = inc.readline()
                    while line and line != '\r\n':
                        headers[line.split(':')[0].lower()] = \
                            line.split(':')[1].strip()
                        line = inc.readline()
                    self.assert_('x-put-timestamp' in headers)
                    self.assert_('x-delete-timestamp' in headers)
                    self.assert_('x-object-count' in headers)
                    self.assert_('x-bytes-used' in headers)
            except BaseException as err:
                import traceback
                traceback.print_exc()
                return err
            return None
        bindsock = listen(('127.0.0.1', 0))

        def spawn_accepts():
            events = []
            for _junk in range(2):
                sock, addr = bindsock.accept()
                events.append(spawn(accept, sock, addr, 201))
            return events

        spawned = spawn(spawn_accepts)
        for dev in cu.get_account_ring().devs:
            if dev is not None:
                dev['port'] = bindsock.getsockname()[1]
        cu.run_once()
        for event in spawned.wait():
            err = event.wait()
            if err:
                raise err
        info = cb.get_info()
        self.assertEquals(info['object_count'], 1)
        self.assertEquals(info['bytes_used'], 3)
        self.assertEquals(info['reported_object_count'], 1)
        self.assertEquals(info['reported_bytes_used'], 3)

    @mock.patch('os.listdir')
    def test_listdir_with_exception(self, mock_listdir):
        e = OSError('permission_denied')
        mock_listdir.side_effect = e
        cu = container_updater.ContainerUpdater({
            'devices': self.devices_dir,
            'mount_check': 'false',
            'swift_dir': self.testdir,
            'interval': '1',
            'concurrency': '1',
            'node_timeout': '15',
            'account_suppression_time': 0
        })
        cu.logger = FakeLogger()
        paths = cu.get_paths()
        self.assertEqual(paths, [])
        log_lines = cu.logger.get_lines_for_level('error')
        msg = ('ERROR:  Failed to get paths to drive partitions: '
               'permission_denied')
        self.assertEqual(log_lines[0], msg)

    @mock.patch('os.listdir', return_value=['foo', 'bar'])
    def test_listdir_without_exception(self, mock_listdir):
        cu = container_updater.ContainerUpdater({
            'devices': self.devices_dir,
            'mount_check': 'false',
            'swift_dir': self.testdir,
            'interval': '1',
            'concurrency': '1',
            'node_timeout': '15',
            'account_suppression_time': 0
        })
        cu.logger = FakeLogger()
        path = cu._listdir('foo/bar/')
        self.assertEqual(path, ['foo', 'bar'])
        log_lines = cu.logger.get_lines_for_level('error')
        self.assertEqual(len(log_lines), 0)

    def test_unicode(self):
        cu = container_updater.ContainerUpdater({
            'devices': self.devices_dir,
            'mount_check': 'false',
            'swift_dir': self.testdir,
            'interval': '1',
            'concurrency': '1',
            'node_timeout': '15',
        })
        containers_dir = os.path.join(self.sda1, DATADIR)
        os.mkdir(containers_dir)
        subdir = os.path.join(containers_dir, 'subdir')
        os.mkdir(subdir)
        cb = ContainerBroker(os.path.join(subdir, 'hash.db'), account='a',
                             container='\xce\xa9')
        cb.initialize(normalize_timestamp(1), 0)
        cb.put_object('\xce\xa9', normalize_timestamp(2), 3, 'text/plain',
                      '68b329da9893e34099c7d8ad5cb9c940')

        def accept(sock, addr):
            try:
                with Timeout(3):
                    inc = sock.makefile('rb')
                    out = sock.makefile('wb')
                    out.write('HTTP/1.1 201 OK\r\nContent-Length: 0\r\n\r\n')
                    out.flush()
                    inc.read()
            except BaseException as err:
                import traceback
                traceback.print_exc()
                return err
            return None

        bindsock = listen(('127.0.0.1', 0))

        def spawn_accepts():
            events = []
            for _junk in range(2):
                with Timeout(3):
                    sock, addr = bindsock.accept()
                    events.append(spawn(accept, sock, addr))
            return events

        spawned = spawn(spawn_accepts)
        for dev in cu.get_account_ring().devs:
            if dev is not None:
                dev['port'] = bindsock.getsockname()[1]
        cu.run_once()
        for event in spawned.wait():
            err = event.wait()
            if err:
                raise err
        info = cb.get_info()
        self.assertEquals(info['object_count'], 1)
        self.assertEquals(info['bytes_used'], 3)
        self.assertEquals(info['reported_object_count'], 1)
        self.assertEquals(info['reported_bytes_used'], 3)

if __name__ == '__main__':
    unittest.main()


text:
#ifndef SSTMAC_SOFTWARE_LIBRARIES_MPI_MPI_COMM_MPICOMM_H_INCLUDED
#define SSTMAC_SOFTWARE_LIBRARIES_MPI_MPI_COMM_MPICOMM_H_INCLUDED

#include <sumi/communicator.h>
#include <sstmac/common/node_address.h>
#include <sstmac/software/process/task_id.h>
#include <sstmac/software/process/app_id.h>
#include <sumi-mpi/mpi_comm/keyval_fwd.h>
#include <sumi-mpi/mpi_comm/mpi_group.h>
#include <sumi-mpi/mpi_integers.h>
#include <sumi-mpi/mpi_request_fwd.h>
#include <sprockit/unordered.h>
#include <sprockit/errors.h>
#include <string>
#include <map>

namespace sumi {

using sstmac::sw::app_id;
using sstmac::node_id;

/**
 * An MPI communicator handle.
 */
class mpi_comm : public communicator
{
 public:
  friend class mpi_api;

  enum topotypes {
    TOPO_NONE, TOPO_GRAPH, TOPO_CART
  };

  static const int proc_null = -1;

 public:
  mpi_comm();

  /// Hello.
  mpi_comm(
    MPI_Comm id,
    int rank,
    mpi_group* peers,
    app_id aid,
    bool del_grp = false,
    topotypes ty = TOPO_NONE);

  /// Goodbye.
  virtual
  ~mpi_comm();

  void
  set_name(std::string name) {
    name_ = name;
  }

  std::string
  name() const {
    return name_;
  }

  static void
  delete_statics();

  topotypes
  topo_type() const {
    return topotype_;
  }

  mpi_group*
  group() {
    return group_;
  }

  void
  dup_keyvals(mpi_comm* m);

  /// This is the null communicator.
  static mpi_comm* comm_null;

  std::string
  to_string() const;

  /// The rank of this peer in the communicator.
  int
  rank() const {
    return rank_;
  }

  /// The size of the communicator.
  int
  size() const;

  /// The identifier for this communicator.
  /// To be used to tag messages to/from this communicator.
  MPI_Comm
  id() const {
    return id_;
  }

  void
  set_keyval(keyval* k, void* val);

  void
  get_keyval(keyval* k, void* val, int* flag);

  app_id
  app() const {
    return aid_;
  }

  int
  comm_to_global_rank(int comm_rank) const {
    return int(peer_task(comm_rank));
  }

  int
  global_to_comm_rank(int global_rank) const;

  int
  nproc() const {
    return size();
  }

  //
  // Get a unique tag for a collective operation.
  //
  int
  next_collective_tag();

  /// The task index of the caller.
  task_id
  my_task() const;

  /// The task index of the given peer.
  task_id
  peer_task(int rank) const;

  /// Equality comparison.
  inline bool
  operator==(mpi_comm* other) const {
    return ((rank_ == other->rank_) && (id_ == other->id_));
  }

  /// Inequality comparison.
  inline bool
  operator!=(mpi_comm* other) const {
    return !this->operator==(other);
  }

  void
  add_request(int tag, mpi_request* req){
    ireqs_[tag] = req;
  }

  mpi_request*
  get_request(int tag) const {
    auto it = ireqs_.find(tag);
    if (it == ireqs_.end()){
      spkt_throw_printf(sprockit::value_error,
          "cannot find tag %d on comm %d for returning collective MPI_Request",
          tag, id_);
    }
    return it->second;
  }

 protected:
  friend std::ostream&
  operator<<(std::ostream &os, mpi_comm* comm);

 private:
  friend class mpi_comm_factory;

  void set_id(MPI_Comm id){
    id_ = id;
  }

  /// The tasks participating in this communicator.  This is only used for an mpicomm* which is NOT WORLD_COMM.
  mpi_group* group_;

  uint16_t next_collective_tag_;

  spkt_unordered_map<int, keyval*> keyvals_;

  app_id aid_;

  bool del_grp_;

  topotypes topotype_;

  std::string name_;

  std::map<int, mpi_request*> ireqs_;

  MPI_Comm id_;

 protected:
  int rank_;

};

/// Fairly self-explanatory.
std::ostream&
operator<<(std::ostream &os, mpi_comm* comm);

}

#endif


text:
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.refactoring.rename;

import com.intellij.psi.PsiElement;
import com.intellij.refactoring.rename.naming.AutomaticRenamer;
import com.intellij.refactoring.rename.naming.AutomaticRenamerFactory;
import com.intellij.usageView.UsageInfo;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.codeInsight.PyCodeInsightSettings;
import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.search.PyClassInheritorsSearch;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;

/**
 * @author yole
 */
public class PyInheritorRenameFactory implements AutomaticRenamerFactory {
  @Override
  public boolean isApplicable(@NotNull PsiElement element) {
    return element instanceof PyClass;
  }

  @Override
  public String getOptionName() {
    return PyBundle.message("refactoring.rename.inheritors");
  }

  @Override
  public boolean isEnabled() {
    return PyCodeInsightSettings.getInstance().RENAME_CLASS_INHERITORS;
  }

  @Override
  public void setEnabled(boolean enabled) {
    PyCodeInsightSettings.getInstance().RENAME_CLASS_INHERITORS = enabled;
  }

  @NotNull
  @Override
  public AutomaticRenamer createRenamer(PsiElement element, String newName, Collection<UsageInfo> usages) {
    return new PyInheritorRenamer((PyClass) element, newName);
  }

  public static class PyInheritorRenamer extends AutomaticRenamer {
    public PyInheritorRenamer(PyClass element, String newName) {
      myElements.addAll(PyClassInheritorsSearch.search(element, false).findAll());
      suggestAllNames(element.getName(), newName);
    }

    @Override
    public String getDialogTitle() {
      return PyBundle.message("refactoring.rename.inheritors.title");
    }

    @Override
    public String getDialogDescription() {
      return PyBundle.message("refactoring.rename.inheritor.classes.with.the.following.names.to");
    }

    @Override
    public String entityName() {
      return "Inheritor Class";
    }
  }
}


text:
package com.github.mkopylec.errorest.handling.errordata;

import com.github.mkopylec.errorest.logging.ErrorsLoggingList;
import com.github.mkopylec.errorest.logging.LoggingLevel;
import com.github.mkopylec.errorest.response.Error;
import org.springframework.http.HttpStatus;

import java.util.List;

import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric;

public class ErrorData {

    public static final int ERRORS_ID_LENGTH = 10;

    protected final String id;
    protected final LoggingLevel loggingLevel;
    protected final String requestMethod;
    protected final String requestUri;
    protected final HttpStatus responseStatus;
    protected final List<Error> errors;
    protected final Throwable throwable;

    protected ErrorData(String id, LoggingLevel loggingLevel, String requestMethod, String requestUri, HttpStatus responseStatus, List<Error> errors, Throwable throwable) {
        this.id = id;
        this.loggingLevel = loggingLevel;
        this.requestMethod = requestMethod;
        this.requestUri = requestUri;
        this.responseStatus = responseStatus;
        this.errors = errors;
        this.throwable = throwable;
    }

    public String getId() {
        return id;
    }

    public LoggingLevel getLoggingLevel() {
        return loggingLevel;
    }

    public boolean hasLoggingLevel(LoggingLevel level) {
        return loggingLevel == level;
    }

    public String getRequestMethod() {
        return requestMethod;
    }

    public String getRequestUri() {
        return requestUri;
    }

    public HttpStatus getResponseStatus() {
        return responseStatus;
    }

    public List<Error> getErrors() {
        return errors;
    }

    public Throwable getThrowable() {
        return throwable;
    }

    public static final class ErrorDataBuilder {

        protected String id;
        protected LoggingLevel loggingLevel;
        protected String requestMethod;
        protected String requestUri;
        protected HttpStatus responseStatus;
        protected List<Error> errors = new ErrorsLoggingList();
        protected Throwable throwable;

        private ErrorDataBuilder() {
            id = randomAlphanumeric(ERRORS_ID_LENGTH).toLowerCase();
        }

        public static ErrorDataBuilder newErrorData() {
            return new ErrorDataBuilder();
        }

        public ErrorDataBuilder withLoggingLevel(LoggingLevel loggingLevel) {
            this.loggingLevel = loggingLevel;
            return this;
        }

        public ErrorDataBuilder withRequestMethod(String requestMethod) {
            this.requestMethod = requestMethod;
            return this;
        }

        public ErrorDataBuilder withRequestUri(String requestUri) {
            this.requestUri = requestUri;
            return this;
        }

        public ErrorDataBuilder withResponseStatus(HttpStatus responseStatus) {
            this.responseStatus = responseStatus;
            return this;
        }

        public ErrorDataBuilder addError(Error error) {
            errors.add(error);
            return this;
        }

        public ErrorDataBuilder withThrowable(Throwable throwable) {
            this.throwable = throwable;
            return this;
        }

        public ErrorData build() {
            return new ErrorData(id, loggingLevel, requestMethod, requestUri, responseStatus, errors, throwable);
        }
    }
}


text:
package co.com.codesoftware.server.productos;

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;

/**
 *
Clase Java para buscaHistProdXSedeResponse complex type.
 *
 *
El siguiente fragmento de esquema especifica el contenido que se espera que haya en esta clase.
 *
 *

 * <complexType name="buscaHistProdXSedeResponse">
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="listaPrecios" type="{http://productos.server.codesoftware.com.co/}precioProdSimpleEntity" maxOccurs="unbounded" minOccurs="0"/>
 *       </sequence>
 *     </restriction>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "buscaHistProdXSedeResponse", propOrder = {
    "listaPrecios"
})
public class BuscaHistProdXSedeResponse {

    protected List<PrecioProdSimpleEntity> listaPrecios;

    /**
     * Gets the value of the listaPrecios property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the listaPrecios property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getListaPrecios().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link PrecioProdSimpleEntity }
     *
     *
     */
    public List<PrecioProdSimpleEntity> getListaPrecios() {
        if (listaPrecios == null) {
            listaPrecios = new ArrayList<PrecioProdSimpleEntity>();
        }
        return this.listaPrecios;
    }

}


text:
<?php
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace App\Tests;

use App\Entity\Service;
use App\Entity\ServiceAnalytics;
use App\Tests\ApiTestCase;
use Hautelook\AliceBundle\PhpUnit\RefreshDatabaseTrait;

class ServiceAnalyticsTest extends ApiTestCase
{
    // This trait provided by HautelookAliceBundle will take care of refreshing the database content to a known state before each test
    use RefreshDatabaseTrait;

    const KNOWN_SERVICE_NAME = 'Senior Center Fitness Discounts';

    public function testGetServiceAnalytics(): void
    {
        // Fake a response from Google Analytics with # page views doubling.
        $fakeAnalytics = static::$container->get("Google_Service_AnalyticsReporting");
        $fakeAnalytics->reports->withMetrics(array("PageViews" => array(42, 21)))->withEvents(array("LearnMore" => array(10, 0), "Share" => array(5, 10)));

        $serviceIri = static::findIriBy(Service::class, ['name' => static::KNOWN_SERVICE_NAME]);
        $this->client->request('GET', $serviceIri . "/analytics");

        $this->assertResponseIsSuccessful();
        $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
        $this->assertJsonContains([
            '@context' => '/api/contexts/ServiceAnalytics',
            '@type' => 'ServiceAnalytics',
            '@id' => $serviceIri . "/analytics",
            'metrics' => [
                ['name' => 'LearnMore', 'value' => 10, 'trend' => 0],
                ['name' => 'Share', 'value' => 5, 'trend' => -50],
                ['name' => 'PageViews', 'value' => 42, 'trend' => 100],
            ],
        ]);

        // Asserts that the returned JSON is validated by the JSON Schema generated for this resource by API Platform
        $this->assertMatchesResourceCollectionJsonSchema(ServiceAnalytics::class);
    }
}


text:
namespace boost { namespace spirit { namespace lex
{
    ///////////////////////////////////////////////////////////////////////////
    // forward declarations
    ///////////////////////////////////////////////////////////////////////////
    struct terminal_director;
    struct sequence;
    struct action;
    struct string_token_def;
    struct char_token_def;

    struct lexer_meta_grammar;

    template <typename Expr, typename Enable>
    struct is_valid_expr;

    template <typename Expr, typename Enable>
    struct expr_transform;

    ///////////////////////////////////////////////////////////////////////////
    //  main lexer_meta_grammar in the lex namespace
    ///////////////////////////////////////////////////////////////////////////

    struct token_def_meta_grammar
      : proto::or_<
            // token_def<>
            meta_grammar::terminal_rule<
                lex::domain,
                terminal_holder<proto::_, lex::token_def<proto::_, proto::_, proto::_> >,
                terminal_director
            >,
            // token_set
            meta_grammar::terminal_rule<
                lex::domain,
                terminal_holder<proto::_, lex::token_set<proto::_> >,
                terminal_director
            >
        >
    {
    };

    // 'x', L'x', "x", L"x", std::string, std::wstring
    struct literal_token_def_meta_grammar
      : proto::or_<
            meta_grammar::terminal_rule<
                lex::domain, char, char_token_def
            >,
            meta_grammar::terminal_rule<
                lex::domain, wchar_t, char_token_def
            >,
            meta_grammar::terminal_rule<
                lex::domain, char const*, string_token_def
            >,
            meta_grammar::terminal_rule<
                lex::domain, wchar_t const*, string_token_def
            >,
            meta_grammar::terminal_rule<
                lex::domain,
                std::basic_string<char, proto::_, proto::_>,
                string_token_def
            >,
            meta_grammar::terminal_rule<
                lex::domain,
                std::basic_string<wchar_t, proto::_, proto::_>,
                string_token_def
            >
        >
    {
    };

    struct action_lexer_meta_grammar
      : proto::or_<
            // semantic actions for tokens
            meta_grammar::binary_rule<
                lex::domain, proto::tag::subscript, action,
                token_def_meta_grammar, proto::when<proto::_, proto::_arg>
            >,
            meta_grammar::binary_rule<
                lex::domain, proto::tag::subscript, action,
                action_lexer_meta_grammar, proto::when<proto::_, proto::_arg>
            >
        >
    {
    };

    struct lexer_meta_grammar
      : proto::or_<
            // token_def<>, ' ', L' ', "...", L"...", std::string, std::wstring
            token_def_meta_grammar,
            literal_token_def_meta_grammar,
            // token_def[...]
            action_lexer_meta_grammar,
            // sequence delimited by '|'
            meta_grammar::binary_rule_flat<
                lex::domain, proto::tag::bitwise_or, sequence,
                lexer_meta_grammar
            >
        >
    {
    };

    ///////////////////////////////////////////////////////////////////////////
    //  These specializations non-intrusively hook into the Lex meta-grammar.
    //  (see lex/meta_grammar.hpp)
    ///////////////////////////////////////////////////////////////////////////
    template <typename Expr>
    struct is_valid_expr<
            Expr,
            typename enable_if<
                proto::matches<Expr, lexer_meta_grammar>
            >::type
        >
      : mpl::true_
    {
    };

    template <typename Expr>
    struct expr_transform<
            Expr,
            typename enable_if<
                proto::matches<Expr, lexer_meta_grammar>
            >::type
        >
      : mpl::identity<lexer_meta_grammar>
    {
    };

}}}

#endif