text:
<link rel="import" href="./truth-list.html">
<link rel="import" href="../time-pong-constant-behaviors/time-pong-constant-behaviors.html">

<dom-module id="time-pong-card-utility">
  <template>
    <truth-list id="truthList"></truth-list>
  </template>
  <script>
    (function() {
      'use strict';

      var _BOUNDS = {
        basic: 20,
        regular: 62,
        limited: 85,
        special: 97,
        rare: 100
      };

      Polymer({
        is: 'time-pong-card-utility',
        behaviors: [ConstantsBehavior],

        properties: {
          grandCardList: {
            type: Object
          },
          filteredCardList: {
            type: Object
          },
          lastFoundCard: {
            type: Object,
            value: function() {return {}}
          }
        },

        ready: function() {
          // TODO Fetch the card list from the db filtered by user config
          // We only wanted cards user has access too to be returned so that they can't change the code and access all cards
          // this.grandCardList = db.cards()

          // TODO Pluck out the card categories that don't match the user's config
          // this.filteredCardList = filterUnwantedDecks(this.grandCardList, user.config)
          this.grandCardList = tempCardsArray(); // TODO Remove once we're getting it from filteredFunction

          this.filteredCardList = tempCardsArray(); // TODO Remove once we're getting it from filteredFunction
        },

        getGrandList: function() {
          return _.cloneDeep(this.grandCardList);
        },

        /*
        @getRandomCard
        filters: {
          isSpellActive: Boolean
            whether a spell card is currently in play.
          isDrinking: Boolean
            Yay or nay
          restrictTo: Object
            Whether we restrict the card type being found to the passed obj. ie {type: 'action', rarity 'basic'}
        }
       */
        getRandomCard: function(filters) {
          var result =  Math.random() * 100;

          // First we set up filters.
          filters = filters || {};
          filters.previousCard = this.lastFoundCard;
          filters.restrictTo = filters.restrictTo || this.lastFoundCard.restrict || {};

          // Add a rarity filter
          // Special check to see if we draw a basic card.
          if (result < _BOUNDS.basic && _.get(this.lastFoundCard, 'rarity') !== 'basic' && !filters.restrictTo.multi) {
            filters.rarity = 'basic';
          } else if(result < _BOUNDS.regular) {
            filters.rarity = 'regular';
          } else if(result < _BOUNDS.limited) {
            filters.rarity = 'limited';
          } else if(result < _BOUNDS.special) {
            filters.rarity = 'special';
          } else if(result < _BOUNDS.rare) {
            filters.rarity = 'rare';
          } else {
            // Should never happen, but if we find no card, just spit out the basic.
            filters.rarity = 'basic';
          }

          this.lastFoundCard = getRandomArrayItem(getValidCards(this.filteredCardList, filters));

          if(this.lastFoundCard.type === 'dare') {
            var truth = this.$.truthList.getTruth();
            _.forEach(this.lastFoundCard.boldRules, function(rule) {
              if (rule.type === 'chicken') {
                rule.instruction = truth;
              }
            });
          }

          return this.lastFoundCard;
        }
      });

      function getValidCards(cards, filters) {
        // For debugging purposes. Grab a specific card.
        if (filters.id) return _.where(cards, {id: filters.id});

        var filteredCards =  _.filter(cards, function(card) {
          if (filters.rarity !== card.rarity) return false;
          if (filters.isDrinking && !card.forDrinkers) return false;
          if (!filters.isDrinking && !card.forNonDrinkers) return false;
          if (filters.restrictTo && !_.find([card], filters.restrictTo)) return false;
          // Is a spell card currently in play. If so, remove all other spells.
          if (filters.isSpellActive && card.type === 'spell') return false;

          // Finally return false if the card matches the previous card drawn.
          return card !== filters.previousCard;
        });

        return filteredCards;
      }

      function getRandomArrayItem(array) {
        var length = array ? array.length : 0;
        var index = Math.floor(Math.random() * length);
        return array[index];
      }

      function tempCardsArray() {

        //Card definition
        /*
        {
          creator: Plain string - who created the idea for this card

          created: Date created

          forDrinkers: Boolean - if this card should appear for drinkers (Optional)

          forNonDrinkers: Boolean - if this card should appear for non-drinkers (Optional)

          deck: String - The deck / set / expansion that this card came from
                [core, W&W, popCulture, nudity, orgasmic]

          rarity: String - the rarity level of this card
                [basic(Do not edit these), regular, limited, special, rare]

          type: String - The type of card
                [action, challenge, spell, curse, trait, dare, ability, global]

          duration: Number - If the card should last for X rounds, primarily for use with Spells. (Optional)

          title: String - The title of the card. Limited to X characters

          flavour: String - humerous flavour text for the card, themed around the card name or rules (Optional)

          multipleLosers: Boolean - whether or not this card makes sense if multiple people lost

          rules: Array[String] - List of instructions to do for the card (Optional)

          boldRules: Object {  - bottom rules, drink amount / challenge result etc (required)
            instruction: [String]
           }
        }
         */

        return [
          // ------------- BASIC
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            deck: 'W&W',
            rarity: 'basic',
            forDrinkers: true,
            card: 'default',
            type: 'action',
            image: 'the-witchs-cauldron',
            helpText: ['If The Witch\'s Cauldron does not exist, create it by placing an empty cup in the middle.'],
            title: 'The Witch\'s Cauldron',
            flavour: 'One toad\'s tongue with an owl\'s lung. Three cigarette butts and two squirrel nuts. Brew them for a bit, then skull that shit.',
            rules: ['Pour two shots of your drink into the cauldron.'],
            boldRules: [{instruction:'If the cauldron is full, skull it.'}]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forNonDrinkers: true,
            deck: 'core',
            rarity: 'basic',
            type: 'action',
            card: 'default',
            image: 'fetch',
            title: 'Fetch!',
            flavour: 'Who\'s a good doggy? You\'re a good doggy!',
            multipleLosers: true,
            rules: ['Pass the cup to your left, play continues while you\'re gone.'],
            boldRules: [{instruction:'If anyone wants a drink, you fetch it.'}]
          },
          // ------------ regular
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            card: 'default',
            image: 'drink-two',
            rarity: 'regular',
            type: 'action',
            title: 'Sharing is caring',
            flavour: 'Nobody wants to drink alone.',
            multipleLosers: true,
            rules: ['Choose a friend to share your losing experience.'],
            boldRules: [{instruction:'You both drink two.'}]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            type: 'action',
            card: 'default',
            image: 'drink-one',
            title: '',
            multipleLosers: true,
            boldRules: [{instruction:'You drink one.'}]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            type: 'action',
            card: 'default',
            image: 'drink-two',
            title: '',
            multipleLosers: true,
            boldRules: [{instruction:'You drink two.'}]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            type: 'action',
            card: 'default',
            image: 'delegate',
            title: 'Delegate',
            flavour: 'It\'s a hard job, but someone has to do it. Time to delegate.',
            multipleLosers: true,
            boldRules: [{instruction:'Choose someone to drink two.'}]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            type: 'action',
            card: 'default',
            image: 'give-and-take',
            title: 'Give and take',
            multipleLosers: true,
            boldRules: [
              {
                instruction: 'Give someone two drinks.'
              }, {
                instruction: 'You take one.'
              }
            ],
            flavour: 'You\'re going down, but at least you\'re taking someone with you.'
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            type: 'challenge',
            card: 'challenge',
            image: 'trick-shot',
            title: 'Trick Shot',
            rules: ['Take a shot, bouncing the ball off the wall, ceiling, floor or other 'tricky' surface.'],
            flavour: 'Bend it like Beckham.',
            boldRules: [
              {
                type: 'success',
                instruction: 'Choose someone to skull.'
              },
              {
                type: 'failure',
                instruction: 'You drink two.'
              }
            ]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            type: 'challenge',
            card: 'challenge',
            image: 'rim-job',
            title: 'Rim Job',
            rules: ['Take a normal shot. The ball must circle the cup rim before falling in.'],
            flavour: 'Be careful. It\'s an unfriendly rim.',
            boldRules: [
              {
                type: 'success',
                instruction: 'Choose someone to skull.'
              },
              {
                type: 'failure',
                instruction: 'You drink two.'
              }
            ]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            type: 'challenge',
            card: 'challenge',
            image: 'flip-cup',
            title: 'Flip Cup',
            rules: ['Place the cup upside down, half off the table with the ball behind it.', 'Flip the cup, landing it over the ball.'],
            flavour: '',
            boldRules: [
              {
                type: 'success',
                instruction: 'Choose someone to skull.'
              },
              {
                type: 'failure',
                instruction: 'You drink two.'
              }
            ]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            type: 'challenge',
            card: 'challenge',
            image: 'looks-can-kill',
            title: 'Looks can Kill',
            rules: ['Enter into a staring contest with another player of your choosing.'],
            flavour: '',
            boldRules: [
              {
                type: 'success',
                instruction: 'Your opponent drinks three.'
              },
              {
                type: 'failure',
                instruction: 'You drink three.'
              }
            ]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            card: 'default',
            image: 'return-to-sender',
            type: 'action',
            title: 'Return to sender',
            flavour: 'Must have got lost in transit.',
            rules: ['Return the cup to the last person who passed it to you this round.'],
            boldRules: [{
              instruction: 'They drink two.'
            }, {
              instruction: 'If no one passed it to you this round, skull your drink.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forNonDrinkers: true,
            forDrinkers: true,
            card: 'default',
            image: 'the-wizards-hat',
            deck: 'W&W',
            rarity: 'regular',
            type: 'trait',
            title: 'The Wizard\'s hat',
            flavour: 'With great power, comes great responsibility.',
            rules: ['You don the wizard's hat.',
              'If there are any disputes on rules or who had the cup when the timer went off, you decide.'],
            boldRules: [
              {hideFromNonDrinkers: true,
              instruction: 'You drink two.'}
            ]
          },

          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forNonDrinkers: true,
            forDrinkers: true,
            card: 'default',
            image: '', // todo add img
            deck: 'popCulture',
            rarity: 'regular',
            type: 'trait',
            title: 'He who must not be named',
            flavour: '',
            rules: ['Anyone that says your name, or an abbreviation of it must drink.'],
            boldRules: [
              {hideFromNonDrinkers: true,
                instruction: 'You drink two.'}
            ]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forNonDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            card: 'default',
            image: 'singing-cow',
            type: 'action',
            title: 'Moosic to our ears',
            flavour: 'Don\'t have a cow, man.',
            boldRules: [{
              instruction: 'Give us your best bovine imitation.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forNonDrinkers: true,
            deck: 'core',
            card: 'default',
            image: 'gift-drink',
            rarity: 'regular',
            type: 'action',
            title: 'Give',
            flavour: 'With some people it\'s all take and no give. But not you! You\'re the generous type.',
            multipleLosers: true,
            boldRules: [{
              instruction: 'Choose someone to drink two.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            card: 'ability',
            image: 'nosey',
            type: 'ability',
            title: 'You\'re so nosey!',
            rules: ['At any time you may put your finger on your nose.', 'The last person to follow you is punished.'],
            flavour: 'Eyes and ears and mouth and nose.',
            boldRules: [
              {
                instruction: 'You drink two.'
              }, {
                type: 'punishment',
                instruction: 'Drink four.'
              }
            ]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            card: 'ability',
            image: 'simon-says',
            type: 'ability',
            helpText: ['Don\'t know Simon Says? Just drink and skip this card.'],
            title: 'Simon Says',
            rules: ['At any time you may start a \'Simon Says\' game.', 'The first person(s) to fail is punished.'],
            flavour: 'Simon says drink. Simon says drink. Drink.',
            boldRules: [
              {
                instruction: 'You drink two.'
              }, {
                type: 'punishment',
                instruction: 'Drink four.'
              }
            ]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            card: 'default',
            image: 'the-witchs-curse',
            rarity: 'regular',
            type: 'curse',
            flavour: 'Think of a curse, and keep it quick. But make it annoying, that\'s the trick.',
            title: 'The Witch\'s Curse',
            rules: ['Create a curse of your choosing.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink two.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'regular',
            type: 'curse',
            card: 'default',
            image: 'anonymous',
            flavour: 'Address without their name to avoid your own shame.',
            title: 'A girl has no name', // Rename this?
            rules: ['You cannot use real or abbreviated names of people playing.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink two.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'regular',
            type: 'curse',
            card: 'default',
            image: 'orgasmic',
            flavour: 'What\'s that sound? You\'re in pleasure. Whenever you moan, be loud for good measure.',
            title: 'Orgasmic',
            rules: ['Before each drink, moan like you mean it.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink two.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'regular',
            type: 'curse',
            card: 'default',
            image: 'no-point',
            flavour: 'Lower your hands and keep them closed, for if fingers point you\'ll be exposed.',
            title: 'What's the point?',
            rules: ['You cannot point with your fingers.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink two.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            type: 'trait',
            card: 'default',
            image: 'lovers-lane',
            title: 'Lovers\' lane',
            flavour: 'You don\'t wanna know how many lovers\' used that bench before you.',
            rules: ['Choose a lover and sit with them.',
              'Whenever one drinks, so does the other.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'Take one drink.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            type: 'global',
            card: 'default',
            image: 'spilt-milk',
            title: 'Spilt Milk',
            flavour: 'I guess there\'s a point crying over spilt milk after all.',
            rules: ['You and anyone who has spilt a drink today'],
            boldRules: [{
              instruction: 'Drinks two.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            type: 'trait',
            card: 'default',
            image: 'snake-eyes',
            title: 'Snake Eyes',
            flavour: 'Sssstaring is rude. Sssstop it.',
            rules: ['Anyone you make eye contact with must drink.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink two.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'core',
            rarity: 'regular',
            type: 'trait',
            card: 'default',
            image: '',
            title: 'Spiked Questions',
            flavour: '',
            rules: ['Anyone that answers your question without another question must drink.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink two.'
            }]
          },
          // ------------ limited
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            card: 'default',
            image: 'lead-cup',
            rarity: 'limited',
            type: 'spell',
            duration: 3,
            flavour: 'Adbra kadabra alakazam! From plastic to lead, that\'s what he said.',
            title: 'Lead Cup',
            rules: ['You may only pass left.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink two.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'limited',
            type: 'curse',
            card: 'default',
            image: 'yoda',
            flavour: 'Learn to speak Yoda, you must. Widely accepted language, it is.',
            title: 'Yoda says',
            rules: ['Speak like Yoda, you must.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink three.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'limited',
            type: 'curse',
            card: 'default',
            image: 'tripple-dees',
            flavour: 'Double d\'s are good. Tripple d\'s are bad..',
            title: 'Tripple Dees',
            rules: ['Saying the words Drink, Drank, or Drunk is forbidden.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink three.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'limited',
            card: 'default',
            image: 'drink-three',
            type: 'action',
            title: '',
            multipleLosers: true,
            boldRules: [{
              instruction: 'You drink three.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'limited',
            card: 'default',
            image: 'drink-four',
            type: 'action',
            title: '',
            multipleLosers: true,
            boldRules: [{
              instruction: 'You drink four.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            deck: 'core',
            forNonDrinkers: true,
            rarity: 'limited',
            type: 'action',
            card: 'default',
            image: 'push-up',
            title: 'Drop and gimme',
            flavour: 'Girl look at that body. Girl look at that body. I work out!',
            multipleLosers: true,
            boldRules: [{
              instruction: 'Perform five push ups.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'limited',
            type: 'spell',
            card: 'default',
            image: 'rewind',
            duration: 3,
            title: 'Rewind',
            rules: ['Instead of passing left, pass to the right.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink three.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'limited',
            type: 'spell',
            card: 'default',
            image: 'free-throw',
            duration: 3,
            flavour: 'He shoots, he scoooooores!',
            title: 'Free throws',
            rules: ['Move the cup to the middle.',
              'Players must shoot the ball in without bouncing.'],
            primaryRule: {
              hideFromNonDrinkers: true,
              instruction: 'You drink three.'
            }
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'popCulture',
            rarity: 'limited',
            type: 'global',
            card: 'default',
            image: 'hodor',// todo add img
            title: 'Hold the Door',
            flavour: 'Hodor hodor, hodor. Hodor!?',
            rules: ['Pay tribute to Hodor by giving a eulogy to him, using only his vocabulary.'],
            boldRules: [{instruction:'Everyone toast and drink two.'}]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'limited',
            type: 'action',
            card: 'default',
            image: 'redemption',
            title: 'Redemption',
            rules: ['You have one shot to redeem yourself.'],
            flavour: 'Careful now. You risk bringing shame upon your family.',
            boldRules: [{
              instruction: 'If you miss, skull your drink.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'limited',
            type: 'action',
            card: 'default',
            image: 'doing-it-wrong',
            helpText: ['Place your lips on the far side of the cup. Tilt your head forward until you can take your drink.'],
            flavour: 'Oops. You\'ve gone full retard. You should never go full retard.',
            multipleLosers: true,
            title: 'You\'re doing it wrong',
            rules: ['Drink from the opposite side of the cup.'],
            boldRules: [{
              instruction: 'You drink three.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'limited',
            type: 'action',
            card: 'default',
            image: 'rehydrate',
            title: 'Rehydrate',
            multipleLosers: true,
            rules: ['Slow down, cowboy. You're looking a little tipsy!',
              'Get excluded from rounds while you drink a glass of water.'],
            flavour: 'Remember kids, always drink responsibly.'
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'limited',
            card: 'default',
            image: 'red-tops-blue-pants',
            type: 'global',
            title: 'Tops are red, pants are blue',
            flavour: 'Lookout! It\'s the fashion police.',
            boldRules: [{
              instruction: 'Anyone wearing these, drinks two with you.'
            }]
          },
          {
            creator: 'Dejan and Dragana',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'limited',
            card: 'default',
            image: 'hole-in-one',
            type: 'challenge',
            title: 'A hole in one',
            rules: ['You have one shot. Putt the ball in using your foot from a distance.'],
            flavour: 'Are you too good for your home?!',
            boldRules: [{
              type: 'success',
              instruction: 'Choose someone to skull.'
            },
            {
              type: 'failure',
              instruction: 'You drink three.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forNonDrinkers: true,
            forDrinkers: true,
            deck: 'core',
            rarity: 'limited',
            card: 'default',
            image: 'justin-bieber',
            type: 'perform',
            title: 'You\'re a Belieber',
            flavour: 'You can\'t butcher it more than he did.',
            rules: ['Sing the chorus of any Justin Bieber song.'],
            boldRules: [
            {
              hideFromNonDrinkers: true,
              instruction: 'You drink three.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'limited',
            type: 'spell',
            card: 'default',
            image: 'threes-a-crowd',
            duration: 3,
            flavour: 'Balls that play together, stay together.',
            restrict: {
              type: 'action',
              multipleLosers: true
            },
            title: 'Three\'s a crowd',
            rules: ['Add a ball for adjacent players.',
              'When all balls are sunk, pass the cup to anyone.',
              'All ball carriers perform the action.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink three.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'limited',
            type: 'spell',
            card: 'default',
            image: 'multiball',
            duration: 3,
            flavour: 'Nice balls you have there.',
            title: 'Multiball',
            rules: ['Add one ball to the game.',
              'When all balls are sunk, pass the cup to anyone.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink three.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'limited',
            type: 'spell',
            duration: 3,
            card: 'default',
            flavour: 'You. Shall. Not. PASS!',
            image: 'gatekeeper',
            title: 'The gatekeeper',
            rules: ['You are the Gatekeeper and may pass to anyone.',
              'Other players may only pass to you.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink two.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'limited',
            limit: 'action',
            type: 'spell',
            card: 'default',
            flavour: 'Cup hoarders will be punished severely.',
            image: 'double-trouble',
            duration: 3,
            title: 'Double trouble',
            restrict: {
              type: 'action',
              multipleLosers: true
            },
            rules: ['To start this spell, give the opposite player a ball and cup.',
              'Continue with two cups in play.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink two.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'core',
            rarity: 'limited',
            limit: 'action',
            card: 'default',
            flavour: 'Three inevitable things: Dying, taxes and someone drinking twice what they had too.',
            image: 'delay',
            duration: 1,
            restrict: {
              type: 'action',
              multipleLosers: true
            },
            type: 'spell',
            title: 'Delay the inevitable',
            rules: ['Only drinkers should participate next round.',
              'Double the values of the card drawn next.']
          },
          {
            creator: 'Tim Weightman',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'limited',
            type: 'challenge',
            card: 'challenge',
            image: 'hacky-sack',
            title: 'Hacky Sack',
            rules: ['One chance to bounce the ball off your feet five consecutive times.'],
            flavour: '',
            multipleLosers: true,
            boldRules: [
              {
                type: 'success',
                instruction: 'Choose someone to skull..'
              },
              {
                type: 'failure',
                instruction: 'You drink three.'
              }
            ]
          },

          // ------------ special
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'special',
            card: 'default',
            image: 'drink-five',
            type: 'action',
            multipleLosers: true,
            title: '',
            boldRules: [{
              instruction: 'You drink five.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'core',
            rarity: 'special',
            type: 'action',
            multipleLosers: true,
            card: 'default',
            image: 'paralyzed',
            title: 'Paralyzed',
            flavour: 'Your shoulder bone\'s connected to your - wrist bone. O-oh.',
            rules: ['Hold your drink in both hands. Drink without bending your arms.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink three.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'special',
            type: 'spell',
            card: 'default',
            flavour: 'Some call you The Punisher, others call you Bob.',
            image: 'punisher',
            duration: 1,
            title: 'The Punisher',
            rules: ['You are the only person who can play next round.', 'Each time you get the ball in, allocate one drink.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink three.'
            }]
          },
          {
            creator: 'Cute Ben',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'special',
            type: 'spell',
            card: 'default',
            flavour: 'Let\'s get ready tooo rummmmmmmble.',
            image: 'duel',
            duration: 1,
            title: 'Duel',
            rules: ['Choose any other player. You may only pass to each other next round.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink three.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'special',
            type: 'curse',
            card: 'default',
            flavour: 'If laughter\'s the best medicine, let\'s hope you\'re not sick.',
            image: 'laughter',
            title: 'Nothing\'s Funny',
            rules: ['laughing is forbidden.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You drink three.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            deck: 'core',
            forDrinkers: true,
            rarity: 'special',
            type: 'action',
            multipleLosers: true,
            card: 'default',
            flavour: 'One have-a-sippy..... Two have-a-sippy..... Three have-a-sippy.',
            image: 'sipping-situp',
            title: 'The sipping sit up',
            boldRules: [{
              instruction:'Perform three sit ups and drink once during each.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'core',
            rarity: 'special',
            type: 'dare',
            card: 'default',
            image: 'twerk',
            title: 'Twerk it like Miley',
            flavour: 'Shake it. Sh-sh-shake it like a polaroid picture.',
            rules: ['Stand up. Face away.', 'Now make Miley proud.'],
            boldRules: [{
                type: 'chicken',
                instruction: ''
              },
              {
                hideFromNonDrinkers: true,
                instruction: 'You drink three.'
              }
            ]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'special',
            type: 'action',
            multipleLosers: true,
            title: 'Skull',
            card: 'default',
            image: 'skull',
            flavour: '\'Cause fuck you and fuck your liver, that\'s why.'
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'special',
            type: 'action',
            multipleLosers: true,
            card: 'default',
            image: 'one-for-all',
            title: 'One for all',
            flavour: 'Your heroic efforts won\'t be forgotten... until this is drawn again.',
            boldRules: [{
              instruction: 'Drink one for each person playing.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'core',
            rarity: 'special',
            type: 'ability',
            card: 'default',
            image: 'jail-free',
            flavour: 'When you have one of those \'Nope!\' moments.',
            title: 'Get out of jail free',
            rules: ['Use this ability to get out of a rule on any card']
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'special',
            type: 'action',
            title: 'Thirsty',
            card: 'default',
            image: 'thirsty',
            flavour: 'We\'re nothing if not conciderate. Let\'s quench that thirst.',
            rules: ['Fill your drink.',
              'When the timer starts next round, start drinking.',
              'Only stop when the timer rings, or you have finished your drink.']
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'popCulture',
            rarity: 'special',
            type: 'challenge',
            card: 'default',
            image: 'spicey',
            title: 'Mmmm, Spicey!',
            rules: ['Five seconds to name five spice girls.'],
            flavour: 'Cumin, Paprika, Cinnamon, Nutmeg, Saffron.',
            boldRules: [{
              type: 'success',
              instruction: 'Everyone else drinks five.'
            },
            {
              type: 'failure',
              instruction: 'You skull.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'special',
            type: 'challenge',
            title: 'Kobe!',
            card: 'default',
            image: 'kobe',
            flavour: 'Some guys were born with natural ball skills.',
            rules: ['Place the cup at a distance and take a shot without bouncing.'],
            boldRules: [{
              type: 'success',
              instruction: 'Everybody else drinks two.'
            }, {
              type: 'failure',
              instruction: 'You drink three.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'core',
            rarity: 'special',
            type: 'dare',
            card: 'default',
            image: 'kiss',
            title: 'Smooches',
            rules: ['Kiss the adjacent person on the lips.'],
            flavour: 'Pucker up. This one could be sloppy!',
            boldRules: [{
              type: 'chicken',
              instruction: ''
            },
              {
                hideFromNonDrinkers: true,
                instruction: 'You drink three.'
              }
            ]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'W&W',
            rarity: 'rare',
            type: 'action',
            flavour: 'A little bit of piss and a little bit of poo. Mix it up and there\'s a brew for you.',
            card: 'default',
            image: 'potion',
            title: 'The Witch\'s Potion',
            rules: ['The three players to your left pour a portion of their drink into one cup.',
              'Top it up with your own drink.'],
            boldRules: [{
              instruction: 'Now skull.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'rare',
            type: 'global',
            card: 'default',
            image: 'racist',
            flavour: 'I\'m not really racist. I want you all to drink equally.',
            title: 'That\'s just racist.',
            boldRules: [{
              instruction: 'You, and anyone matching your skin colour, skulls their drink.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'rare',
            type: 'action',
            card: 'default',
            image: 'sharon',
            title: 'Our friend, Sharon',
            multipleLosers: true,
            flavour: 'Did you hear about what our friend Sharon did with her friend Cory in the chicken shed last Christmas? I hear there were cocks involved!',
            boldRules: [{
              instruction: 'Drink if you know a Sharon.'
            },{
              instruction: 'Skull if you don\'t.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forNonDrinkers: true,
            deck: 'core',
            rarity: 'rare',
            type: 'action',
            title: 'Now that\'s hot!',
            card: 'default',
            image: 'chilli',
            multipleLosers: true,
            flavour: 'Things are really starting to heat up now.',
            rules: ['Find and bite a hot chilli.',
              'If no chilli can be found, take a sip of hot sauce.',
              'If no hot sauce exists, share a hot story from your past.']
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forNonDrinkers: true,
            deck: 'core',
            rarity: 'rare',
            type: 'action',
            image: 'gross',
            multipleLosers: true,
            card: 'default',
            title: 'Host\'s most gross',
            flavour: 'Delicious AND nutritious.',
            rules: ['The host of the house chooses something from their cupboard.',
              'Take a bite of it.']
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'rare',
            type: 'action',
            image: 'two-grills',
            card: 'default',
            title: 'Two grills, one cup',
            rules: ['Pick another person and combine drinks to fill a cup.'],
            boldRules: [{
              instruction: 'Both of you skull by drinking from the cup at the same time.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'rare',
            type: 'global',
            image: 'waterfall',
            card: 'default',
            flavour: '',
            title: 'Waterfall',
            rules: ['Everyone refills their cups.',
              'When timer starts, everyone drinks.',
              'No one stops until the timer stops, even if you control a ball.']
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'rare',
            type: 'global',
            image: 'no-mercy',
            card: 'default',
            title: 'No mercy',
            flavour: 'You\'re drunk, and you\'re drunk. You\'re also drunk. And you, you\'re extra drunk.',
            boldRules: [{
              instruction: 'Everyone skulls.'
            }, {
              instruction: 'Last person to finish skulls another.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'rare',
            type: 'global',
            image: 'apocolypse',    // Todo add img
            card: 'default',
            title: 'Apocolypse',
            flavour: '.',
            boldRules: [{
              instruction: 'Everyone skulls.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            forNonDrinkers: true,
            deck: 'W&W',
            rarity: 'rare',
            type: 'curse',
            card: 'default',
            flavour: 'What good\'s a phone call, if you cannot talk?',
            image: 'mute',
            title: 'Sounds of Silence',
            rules: ['You cannot make any sound with your mouth.'],
            boldRules: [{
              hideFromNonDrinkers: true,
              instruction: 'You skull.'
            }]
          },
          {
            creator: 'Jake Turner',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'W&W',
            rarity: 'rare',
            type: 'action',
            card: 'default',
            flavour: '',
            image: 'kamikaze',
            title: 'Kamikaze',
            multipleLosers: true,
            boldRules: [{
              instruction: 'You skull.'
            },{
              instruction: 'Choose someone to skull.'
            }]
          },
          {
            creator: 'Tim Weightman',
            created: '08/05/2016',
            forDrinkers: true,
            deck: 'core',
            rarity: 'rare',
            type: 'challenge',
            card: 'challenge',
            image: 'ball-mouth',
            title: 'Right in the Kisser',
            rules: ['Take a shot, no bouncing, aiming for the mouth of the person opposite.'],
            flavour: 'Yeah, put put your balls in their mouth!',
            boldRules: [
              {
                type: 'success',
                instruction: 'Both people choose others to skull.'
              },
              {
                type: 'failure',
                instruction: 'Both people skull.'
              }
            ]
          }
        ];
      }
    })();
  </script>
</dom-module>


text:
'''
Created on Nov 2, 2013

@author: Daniel Gill
'''

import nltk
from nltk.probability import FreqDist as FD
from nltk.probability import SimpleGoodTuringProbDist as SGT
import corpus
import os
import ngram_iter

pjoin = lambda x: os.path.join(os.path.join('.', 'res'), x)
training_dir = pjoin('training_data')
tri_data  = pjoin("trigrams.txt")
bi_data = pjoin("bigrams.txt")
uni_data = pjoin("unigrams.txt")

ngram = {'uni':(uni_data, sp_itertools.uni_iter, 1), 'bi':(bi_data, sp_itertools.bi_iter, 2), 'tri':(tri_data, sp_itertools.tri_iter, 3)}

def get_sgt(seq):
    fd = FD()
    for ngram in seq:
        fd.inc(ngram)

    return SGT(fd)

def retrieve_data(path):
    fd = FD()
    with open(path) as data:
        for line in data:
            split_data = line.split("||")
            freq = split_data.pop()
            fd.inc(tuple(split_data), int(freq))

    return SGT(fd)

def write_data(fd, path):
    with open(path, "w+") as out:
        for ngram, count in fd.iteritems():
            seq = list(ngram)
            seq.append(str(count))
            out.write("||".join(seq) + '\n')

class ProbCalc(object):
    def __init__(self, ngram='tri', force_new_data=False):
        ngram = ngram.lower()[:3]
        if ngram not in ngram.keys():
            raise UnsupportedNgramError(ngram + "grams are not supported.")

        data, iterator, self.length = ngram[ngram]
        if os.path.exists(data) and not force_new_data:
            self.pd = retrieve_data(data)
        else:
            self.pd = get_sgt(iterator(sp_corpus.process_dir(training_dir)))
            write_data(self.pd.freqdist(), data)

    def prob(self, x):
        if len(x) < self.length:
            raise UnsupportedNgramError("ProbCalc calibrated for ngrams of length " +
                    str(self.length) + ", not " + len(x) + ".")

        return self.pd.prob(tuple(x))

class UnsupportedNgramError(Exception):
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return repr(self.value)

redpajama_set_name: RedPajamaGithub


text:
import * as React from 'react';
import {
	Expandable,
	ExpandableItem,
	ExpandableItemButton,
	ExpandableItemContainer,
	ExpandableItemContent,
	ExpandableItemText
} from './Expandable';

import { mount } from 'enzyme';

describe('Expandable', () => {
	test('renders correctly', () => {
		const func = jest.fn();

		const tree = mount(
			<Expandable onClickItem={func}>
				<ExpandableItem activeId={1}>
					<ExpandableItemContainer>
						<ExpandableItemText>{`Title for item with index 1`}</ExpandableItemText>
						<ExpandableItemButton />
					</ExpandableItemContainer>
					<ExpandableItemContent p={15}>

{`Content for item with index 1`}

					</ExpandableItemContent>
				</ExpandableItem>
				<ExpandableItem activeId={2}>
					<ExpandableItemContainer>
						<ExpandableItemText>{`Title for item with index 2`}</ExpandableItemText>
						<ExpandableItemButton />
					</ExpandableItemContainer>
					<ExpandableItemContent p={15}>

{`Content for item with index 2`}

					</ExpandableItemContent>
				</ExpandableItem>
				<ExpandableItem activeId={3}>
					<ExpandableItemContainer>
						<ExpandableItemText>{`Title for item with index 3`}</ExpandableItemText>
						<ExpandableItemButton />
					</ExpandableItemContainer>
					<ExpandableItemContent p={15}>

{`Content for item with index 3`}

					</ExpandableItemContent>
				</ExpandableItem>
				<ExpandableItem activeId={4}>
					<ExpandableItemContainer>
						<ExpandableItemText>{`Title for item with index 4`}</ExpandableItemText>
						<ExpandableItemButton />
					</ExpandableItemContainer>
					<ExpandableItemContent p={15}>

{`Content for item with index 4`}

					</ExpandableItemContent>
				</ExpandableItem>
			</Expandable>
		);

		expect(tree).toMatchSnapshot();
	});

	test('shows expanded item 2 content', () => {
		const func = jest.fn();

		const tree = mount(
			<Expandable onClickItem={func} activeItem={2}>
				<ExpandableItem activeId={1}>
					<ExpandableItemContainer>
						<ExpandableItemText>{`Title for item with index 1`}</ExpandableItemText>
						<ExpandableItemButton />
					</ExpandableItemContainer>
					<ExpandableItemContent p={15}>{`Content for item with index 1`}</ExpandableItemContent>
				</ExpandableItem>
				<ExpandableItem activeId={2}>
					<ExpandableItemContainer>
						<ExpandableItemText>{`Title for item with index 2`}</ExpandableItemText>
						<ExpandableItemButton />
					</ExpandableItemContainer>
					<ExpandableItemContent p={15}>{`Content for item with index 2`}</ExpandableItemContent>
				</ExpandableItem>
			</Expandable>
		);

		expect(tree.find(ExpandableItemContent).length).toEqual(2);
		expect(tree.find(ExpandableItemContent).last().text()).toEqual('Content for item with index 2');
	});

	test('calls on click item function when clicking on the item container', () => {
		const func = jest.fn();

		const tree = mount(
			<Expandable onClickItem={func} activeItem={2}>
				<ExpandableItem activeId={1}>
					<ExpandableItemContainer>
						<ExpandableItemText>{`Title for item with index 1`}</ExpandableItemText>
						<ExpandableItemButton />
					</ExpandableItemContainer>
					<ExpandableItemContent p={15}>{`Content for item with index 1`}</ExpandableItemContent>
				</ExpandableItem>
				<ExpandableItem activeId={2}>
					<ExpandableItemContainer>
						<ExpandableItemText>{`Title for item with index 2`}</ExpandableItemText>
						<ExpandableItemButton />
					</ExpandableItemContainer>
					<ExpandableItemContent p={15}>{`Content for item with index 2`}</ExpandableItemContent>
				</ExpandableItem>
			</Expandable>
		);

		tree.find(ExpandableItemContainer).first().simulate('click');
		expect(func).toHaveBeenCalled();
	});
});


text:
{{define "contentNavbar"}}

  Ulbora CMS V3
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">

  </button>

          Content

          List
          Add

        Logout

{{end}}


text:
"""
@brief      test tree node (time=1s)
"""

import sys
import os
import unittest

from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import get_temp_folder
from pyquickhelper.texthelper.html_helper import html_in_frame

class TestHtmlHelper(unittest.TestCase):

    def test_html_in_frame(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        ht = html_in_frame("
title
")
        body = "" + ht + ""
        self.assertIn("data:text/html;base64,PGgxPnRpdGxlPC9oMT4=", ht)
        temp = get_temp_folder(__file__, "temp_html_in_frame")
        tempf = os.path.join(temp, "out.html")
        with open(tempf, "w") as f:
            f.write(body)

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


text:
<form ng-submit='$ctrl.editPost($ctrl.edittedPost.id)'>

    Title
    <input ng-model='$ctrl.edittedPost.title' id="title" class="form-control" required>

    Body
    <textarea ng-model='$ctrl.edittedPost.body' id="body" class="form-control" required></textarea>

    Author
    <input ng-model='$ctrl.edittedPost.author' id="author" class="form-control" required>

    Image URL
    <input ng-model='$ctrl.edittedPost.image_url' id="image-url" class="form-control" required>

    <button type="submit" class="btn btn-primary">
      Edit Post
    </button>

</form>


text:
'use strict';

/* global browser */
/* global element */
/* global by */

describe('Controller: FluidGridCtrl', function () {
  var items,
    firstItem;

  beforeEach(function () {
    browser.get('test.html');
    browser.driver.manage()
      .window()
      .setSize(1000, 1000);
    items = element.all(by.css('[fluid-grid-item]'));
    firstItem = items.get(0);
  });

  it('should have a page with elements', function () {
    element.all(by.repeater('item in standardItems')).then(function (items) {
      expect(items.length).toEqual(11);
    });

    browser.findElement(by.css('h2:first-child')).then(function (el) {
      return el.getText().then(function (text) {
        expect(text).toBe('Standard Items');
      });
    });
  });

  it('should allow the user to enter a size', function () {
    var width = 0;

    firstItem.getSize().then(function (size) {
      expect(size.width).toBeGreaterThan(0);
      width = size.width;
    }).then(function () {
      return firstItem.findElement(by.model('item.sizeX'));
    }).then(function (input) {
      return input.sendKeys('2').then(function () {
        input.sendKeys(protractor.Key.TAB);
      });
    }).then(function () {
      return firstItem.getSize();
    }).then(function (size) {
      expect(size.width).toBeGreaterThan(width);
    });
  });

  it('should resize the row widths and heights', function () {
    browser.driver.manage().window().setSize(1200, 1200);
    firstItem.getSize().then(function (size) {
      expect(size.width).toBe(307);
      expect(size.height).toBe(143);
    });
    //		.then(function() {
    //			browser.driver.manage().window().setSize(1000, 1000);
    //			firstItem.getSize().then(function(size) {
    //				expect(size.width).toBe(271);
    //				expect(size.height).toBe(126);
    //			});
    //		});
  });
});


text:
package main

import (
	"crypto/sha1"
	"encoding/hex"
	"encoding/json"
	"fmt"
	"io"
	"os"
	"strconv"
	"sync"

	"github.com/progrium/duplex-hub/Godeps/_workspace/src/golang.org/x/net/websocket"
)

type Endpoint struct {
	sync.Mutex
	path     string
	secret   string
	upstream *websocket.Conn
	counter  int
	clients  map[string]io.Writer
}

func (e *Endpoint) AddClient(conn io.Writer) string {
	e.Lock()
	defer e.Unlock()
	e.counter++
	h := sha1.New()
	h.Write([]byte(os.Getenv("TOKEN")))
	h.Write([]byte(strconv.Itoa(e.counter)))
	routeKey := hex.EncodeToString(h.Sum(nil))
	e.clients[routeKey] = conn
	return routeKey
}

func (e *Endpoint) DropClient(routeKey string) {
	e.Lock()
	defer e.Unlock()
	delete(e.clients, routeKey)
}

func (e *Endpoint) SendUpstream(msg interface{}) error {
	frame, err := json.Marshal(&msg)
	if err != nil {
		// TODO: what happens on upstream encode error
		panic(err)
	}
	if os.Getenv("DEBUG") != "" {
		fmt.Println("<<<", string(frame))
	}
	_, err = e.upstream.Write(frame)
	return err
}


text:
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    //创建视图
    SpreadOutButton *disView = [[SpreadOutButton alloc]init];
    disView.frame = CGRectMake(100, 100, 50, 50);
    disView.borderRect = self.view.frame;

    //添加按钮
    NSMutableArray *marr = [NSMutableArray array];
    for (int i = 0; i< 8; i++) {
        UIButton *btn = [UIButton new];
        NSString *name = [NSString stringWithFormat:@"found_icons_%d",i];
        [btn setBackgroundImage:[UIImage imageNamed:name] forState:UIControlStateNormal];
        [marr addObject:btn];
    }
    disView.btns = marr;

    [self.view addSubview:disView];

}

@end


text:
/*
	Validate Messages using AJV (Another JSON Validator)
	See documentation for usage : https://github.com/epoberezkin/ajv
*/
var Ajv = require('ajv')
var ajv = Ajv({'allErrors': true, 'format': 'full', 'async': true})

var messageSchema = {
  '$async': true,
  'type': 'object',
  'properties': {
    'id': {
      'type': 'string',
      'maxLength': 64,
      'pattern': '^[a-zA-Z0-9]+$' // include minLength in pattern
    },
    'timestamp': {
      'type': 'string',
      'format': 'date-time' // RFC3339
    },
    'sensorType': {
      // int32
      'type': 'number',
      'minimum': -2147483648,
      'maximum': 2147483647,
      'multipleOf': 1
    },
    'value': {
      // int64
      'type': 'number',
      'minimum': -9223372036854775808,
      'maximum': 9223372036854775807,
      'multipleOf': 1
    }
  },
  'required': ['id', 'timestamp', 'sensorType', 'value']
}

// could use compileAsync to load message schema from file (see http://epoberezkin.github.io/ajv/#asynchronous-compilation)
var validate = ajv.compile(messageSchema)

module.exports = {
  // validate message data
  validate: function (message, callback) {
    validate(message).then(function (valid) {
      // validation succes
      callback(null)
    })
      .catch(function (err) {
        // throw non validation related errors
        if (!(err instanceof Ajv.ValidationError)) throw err
        // return validation error
        callback(err)
      })
  }
}


text:
require 'rails_admin/support/i18n'

module RailsAdmin
  module Support
    class Datetime
      # Ruby format options as a key and momentjs format options as a value
      MOMENTJS_TRANSLATIONS = {
        '%a' => 'ddd',        # The abbreviated weekday name ("Sun")
        '%A' => 'dddd',       # The  full  weekday  name ("Sunday")
        '%b' => 'MMM',        # The abbreviated month name ("Jan")
        '%B' => 'MMMM',       # The  full  month  name ("January")
        '%d' => 'DD',         # Day of the month (01..31)
        '%-d' => 'D',         # Day of the month (1..31)
        '%D' => 'MM/DD/YY',   # American date format mm/dd/yy
        '%e' => 'D',          # Day of the month (1..31)
        '%F' => 'YY-MM-DD',   # ISO 8601 date format
        '%H' => 'HH',         # Hour of the day, 24-hour clock (00..23)
        '%I' => 'hh',         # Hour of the day, 12-hour clock (01..12)
        '%m' => 'MM',         # Month of the year (01..12)
        '%-m' => 'M',         # Month of the year (1..12)
        '%M' => 'mm',         # Minute of the hour (00..59)
        '%p' => 'A',          # Meridian indicator ('AM' or 'PM')
        '%S' => 'ss',         # Second of the minute (00..60)
        '%Y' => 'YYYY',       # Year with century
        '%y' => 'YY',         # Year without a century (00..99)
      }.freeze

      class << self
        include RailsAdmin::Support::I18n

        def delocalize(date_string, format)
          return date_string if ::I18n.locale.to_s == 'en'
          format.to_s.scan(/%[AaBbp]/) do |match|
            case match
            when '%A'
              english = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
              day_names.each_with_index { |d, i| date_string = date_string.gsub(/#{d}/, english[i]) }
            when '%a'
              english = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
              abbr_day_names.each_with_index { |d, i| date_string = date_string.gsub(/#{d}/, english[i]) }
            when '%B'
              english = [nil, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][1..-1]
              month_names.each_with_index { |m, i| date_string = date_string.gsub(/#{m}/, english[i]) }
            when '%b'
              english = [nil, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][1..-1]
              abbr_month_names.each_with_index { |m, i| date_string = date_string.gsub(/#{m}/, english[i]) }
            when '%p'
              date_string = date_string.gsub(/#{::I18n.t('date.time.am', default: "am")}/, 'am')
              date_string = date_string.gsub(/#{::I18n.t('date.time.pm', default: "pm")}/, 'pm')
            end
          end
          date_string
        end

        def normalize(date_string, format)
          return unless date_string
          delocalize(date_string, format)
          parse_date_string(date_string)
        end

        # Parse normalized date strings using time zone
        def parse_date_string(date_string)
          ::Time.zone.parse(date_string)
        end
      end

      attr_reader :strftime_format

      def initialize(strftime_format)
        @strftime_format = strftime_format
      end

      # Ruby to javascript formatting options translator
      def to_momentjs
        strftime_format.gsub(/\w[^.(!?%)\W]{1,}/, '[\0]').gsub(/%(\w|\-\w)/) do |match|
          MOMENTJS_TRANSLATIONS[match]
        end
      end

      # Delocalize a l10n datetime strings
      def delocalize(value)
        self.class.delocalize(value, strftime_format)
      end

      def parse_string(value)
        return if value.blank?
        return value if %w(DateTime Date Time).include?(value.class.name)
        return if (delocalized_value = delocalize(value)).blank?

        begin
          # Adjust with the correct timezone and daylight savint time
          datetime_with_wrong_tz = ::DateTime.strptime(delocalized_value, strftime_format.gsub('%-d', '%d'))
          Time.zone.parse(datetime_with_wrong_tz.strftime('%Y-%m-%d %H:%M:%S'))
        rescue ArgumentError
          nil
        end
      end
    end
  end
end


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Uses of Package org.apache.flume.node (Apache Flume 1.7.0 API)</title>
<meta name="date" content="2016-10-12">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Uses of Package
org.apache.flume.node

Packages that use org.apache.flume.node

Package
Description

org.apache.flume.node

Classes in org.apache.flume.node used by org.apache.flume.node

Class and Description

AbstractConfigurationProvider

AbstractZooKeeperConfigurationProvider

ZooKeeper based configuration implementation provider.

ConfigurationProvider

MaterializedConfiguration

MaterializedConfiguration represents the materialization of a Flume
 properties file.

PropertiesFileConfigurationProvider

 A configuration provider that uses properties file for specifying
 configuration.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Copyright © 2009-2016 Apache Software Foundation. All Rights Reserved.


text:
@interface FlutterRestorationPlugin : NSObject
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)initWithChannel:(FlutterMethodChannel*)channel
             restorationEnabled:(BOOL)waitForData NS_DESIGNATED_INITIALIZER;

@property(nonatomic, strong) NSData* restorationData;
- (void)markRestorationComplete;
- (void)reset;
@end
#endif  // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERRESTORATIONPLUGIN_H_


text:
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2013.05.22 at 03:29:00 PM CEST
//

package org.oscm.saml2.api.model.metadata;

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.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

/**
 *

 * Java class for SPSSODescriptorType complex type.
 *
 *

 * The following schema fragment specifies the expected content contained within
 * this class.
 *
 *

 * <complexType name="SPSSODescriptorType">
 *   <complexContent>
 *     <extension base="{urn:oasis:names:tc:SAML:2.0:metadata}SSODescriptorType">
 *       <sequence>
 *         <element ref="{urn:oasis:names:tc:SAML:2.0:metadata}AssertionConsumerService" maxOccurs="unbounded"/>
 *         <element ref="{urn:oasis:names:tc:SAML:2.0:metadata}AttributeConsumingService" maxOccurs="unbounded" minOccurs="0"/>
 *       </sequence>
 *       <attribute name="AuthnRequestsSigned" type="{http://www.w3.org/2001/XMLSchema}boolean" />
 *       <attribute name="WantAssertionsSigned" type="{http://www.w3.org/2001/XMLSchema}boolean" />
 *       <anyAttribute processContents='lax' namespace='##other'/>
 *     </extension>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SPSSODescriptorType", propOrder = {
        "assertionConsumerService", "attributeConsumingService" })
public class SPSSODescriptorType extends SSODescriptorType {

    @XmlElement(name = "AssertionConsumerService", required = true)
    protected List<IndexedEndpointType> assertionConsumerService;
    @XmlElement(name = "AttributeConsumingService")
    protected List<AttributeConsumingServiceType> attributeConsumingService;
    @XmlAttribute(name = "AuthnRequestsSigned")
    protected Boolean authnRequestsSigned;
    @XmlAttribute(name = "WantAssertionsSigned")
    protected Boolean wantAssertionsSigned;

    /**
     * Gets the value of the assertionConsumerService 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 assertionConsumerService property.
     *
     *

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

     * getAssertionConsumerService().add(newItem);
     *

     *
     *
     *

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

    /**
     * Gets the value of the attributeConsumingService 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 attributeConsumingService property.
     *
     *

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

     * getAttributeConsumingService().add(newItem);
     *

     *
     *
     *

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

    /**
     * Gets the value of the authnRequestsSigned property.
     *
     * @return possible object is {@link Boolean }
     *
     */
    public Boolean isAuthnRequestsSigned() {
        return authnRequestsSigned;
    }

    /**
     * Sets the value of the authnRequestsSigned property.
     *
     * @param value
     *            allowed object is {@link Boolean }
     *
     */
    public void setAuthnRequestsSigned(Boolean value) {
        this.authnRequestsSigned = value;
    }

    /**
     * Gets the value of the wantAssertionsSigned property.
     *
     * @return possible object is {@link Boolean }
     *
     */
    public Boolean isWantAssertionsSigned() {
        return wantAssertionsSigned;
    }

    /**
     * Sets the value of the wantAssertionsSigned property.
     *
     * @param value
     *            allowed object is {@link Boolean }
     *
     */
    public void setWantAssertionsSigned(Boolean value) {
        this.wantAssertionsSigned = value;
    }

}


text:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="me.pratama.examplematerial.ui.RecyclerViewActivity">
    <item android:id="@+id/action_settings" android:title="@string/action_settings"
        android:orderInCategory="100" app:showAsAction="never" />
</menu>


text:
<?php

namespace NilPortugues\Validator\Attribute\Collection;

use NilPortugues\Validator\AbstractValidator;
use NilPortugues\Validator\Validator;

/**
 * Class CollectionAttribute
 * @package NilPortugues\Validator\Attribute\CollectionAttribute
 */
class CollectionAttribute extends AbstractValidator
{
    /**
     * @param string    $propertyName
     * @param Validator $validator
     * @param array     $errorMessages
     * @param array     $functionMap
     */
    public function __construct($propertyName, Validator $validator, array &$errorMessages, array &$functionMap)
    {
        parent::__construct($propertyName, $validator, $errorMessages, $functionMap);

        $this->addCondition(__METHOD__);
    }

    /**
     * @param \NilPortugues\Validator\AbstractValidator $valueValidator
     * @param \NilPortugues\Validator\AbstractValidator $keyValidator
     *
     * @return $this
     */
    public function each(AbstractValidator $valueValidator, AbstractValidator $keyValidator = null)
    {
        $this->addCondition(__METHOD__, [$valueValidator, $keyValidator], [], true);

        return $this;
    }

    /**
     * @param \NilPortugues\Validator\AbstractValidator $keyValidator
     *
     * @return $this
     */
    public function hasKeyFormat(AbstractValidator $keyValidator)
    {
        $this->addCondition(__METHOD__, [$keyValidator], [], true);

        return $this;
    }

    /**
     * @param mixed $needle
     * @param bool  $strict
     *
     * @return $this
     */
    public function endsWith($needle, $strict = false)
    {
        $this->addCondition(__METHOD__, [$needle, $strict]);

        return $this;
    }

    /**
     * @param mixed $needle
     * @param bool  $strict
     *
     * @return $this
     */
    public function contains($needle, $strict = false)
    {
        $this->addCondition(__METHOD__, [$needle, $strict]);

        return $this;
    }

    /**
     * @param $keyName
     *
     * @return $this
     */
    public function hasKey($keyName)
    {
        $this->addCondition(__METHOD__, [$keyName]);

        return $this;
    }

    /**
     * @param integer $length
     *
     * @return $this
     */
    public function hasLength($length)
    {
        $this->addCondition(__METHOD__, [$length]);

        return $this;
    }

    /**
     * @return $this
     */
    public function isNotEmpty()
    {
        $this->addCondition(__METHOD__);

        return $this;
    }

    /**
     * @param      $needle
     * @param bool $strict
     *
     * @return $this
     */
    public function startsWith($needle, $strict = false)
    {
        $this->addCondition(__METHOD__, [$needle, $strict]);

        return $this;
    }
}


text:
<!DOCTYPE html>

      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>No ARIA markup</title>

Placeholder content


text:
package com.intellij.java.refactoring.inline;

import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.TargetElementUtil;
import com.intellij.java.refactoring.LightRefactoringTestCase;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.refactoring.BaseRefactoringProcessor;
import com.intellij.refactoring.MockInlineMethodOptions;
import com.intellij.refactoring.inline.InlineMethodProcessor;
import com.intellij.refactoring.inline.InlineOptions;
import com.intellij.refactoring.util.InlineUtil;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

public class InlineMethodTest extends LightRefactoringTestCase {
  @NotNull
  @Override
  protected String getTestDataPath() {
    return JavaTestUtil.getJavaTestDataPath();
  }

  public void testInlineParms() {
    doTest();
  }

  public void testInlineWithQualifier() {
    doTest();
  }

  public void testInlineWithQualifierFromSuper() { doTest(); }
  public void testTry() {
    doTest();
  }

  public void testTrySynchronized() {
    doTest();
  }

  public void testStaticSynchronized() {
    doTest();
  }

  public void testSuperInsideHierarchy() {
    doTest();
  }

  public void testSideEffect() { doTest(); }

  public void testInlineWithTry() { doTest(); }

  public void testVoidWithReturn() { doTest(); }
  public void testVoidWithReturn1() { doTest(); }

  public void testScr10884() {
    doTest();
  }
  public void testFinalParameters() { doTest(); }
  public void testFinalParameters1() { doTest(); }

  public void testScr13831() { doTest(); }

  public void testNameClash() { doTest(); }

  public void testArrayAccess() { doTest(); }

  public void testConflictingField() { doTest(); }

  public void testCallInFor() { doTest(); }

  public void testSCR20655() { doTest(); }

  public void testFieldInitializer() { doTest(); }

  public void testMethodCallInOtherAnonymousOrInner() { doTest(); }

  public void testStaticFieldInitializer() { doTest(); }
  public void testSCR22644() { doTest(); }

  public void testCallUnderIf() { doTest(); }

  //This gives extra 'result' local variable, currently I don't see a way to cope with it, todo: think about addional inline possibilities
  //public void testLocalVariableResult() throws Exception { doTest(); }

  public void testSCR31093() { doTest(); }

  public void testSCR37742() { doTest(); }

  public void testChainingConstructor() { doTest(); }

  public void testChainingConstructor1() {
    BaseRefactoringProcessor.ConflictsInTestsException.setTestIgnore(true);
    try {
      doTest();
    }
    finally {
      BaseRefactoringProcessor.ConflictsInTestsException.setTestIgnore(false);
    }
  }

  public void testNestedCall() { doTest(); }

  public void testIDEADEV3672() { doTest(); }

  public void testIDEADEV5806() { doTest(); }

  public void testIDEADEV6807() { doTest(); }

  public void testIDEADEV12616() { doTest(); }

  public void testVarargs() { doTest(); }

  public void testVarargs1() { doTest(); }

  public void testFlatVarargs() {doTest();}
  public void testFlatVarargs1() {doTest();}

  public void testEnumConstructor() { doTest(); }

  public void testEnumConstantConstructorParameter() {  // IDEADEV-26133
    doTest();
  }

  public void testEnumConstantConstructorParameterComplex() {  // IDEADEV-26133
    doTest();
  }

  public void testEnumConstantConstructorParameterComplex2() {  // IDEADEV-26133
    doTest();
  }

  public void testEnumConstantConstructorWithArgs() {
    doTest();
  }

  public void testConstantInChainingConstructor() {   // IDEADEV-28136
    doTest();
  }

  public void testReplaceParameterWithArgumentForConstructor() {   // IDEADEV-23652
    doTest();
  }

  public void testTailCallReturn() {  // IDEADEV-27983
    doTest();
  }

  public void testTailCallSimple() {  // IDEADEV-27983
    doTest();
  }

  public void testTailComment() {   //IDEADEV-33638
    doTest();
  }

  public void testInferredType() {
    setLanguageLevel(LanguageLevel.JDK_1_7);
    doTest();
  }

  public void testReplaceGenericsInside() {
    doTest();
  }

  public void testStaticMethodWithoutParams() {
    doTest();
  }

  public void testWithSuperInside() {
    doTest();
  }

  public void testRawSubstitution() {
    doTest();
  }

  public void testSubstitution() {
    doTest();
  }

  public void testSubstitutionForWildcards() {
    doTest();
  }

  public void testParamNameConflictsWithLocalVar() {
    doTest();
  }

  public void testArrayTypeInferenceFromVarargs() {
    doTest();
  }

  public void testSuperMethodInAnonymousClass() {
    doTest();
  }

  public void testInlineAnonymousClassWithPrivateMethodInside() {
    doTest();
  }

  public void testChainedConstructor() {
    doTestInlineThisOnly();
  }

  public void testChainedConstructor1() {
    doTest();
  }

  public void testMethodUsedInJavadoc() {
    doTestConflict("Inlined method is used in javadoc");
  }

  public void testNotAStatement() {
    doTestConflict("Inlined result would contain parse errors");
  }

  public void testInSuperCall() {
    doTestConflict("Inline cannot be applied to multiline method in constructor call");
  }

  public void testMethodReferenceInsideMethodCall() {
    doTest();
  }

  private void doTestConflict(final String conflict) {
    try {
      doTest();
      fail("Conflict was not detected");
    }
    catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
      assertEquals(conflict, e.getMessage());
    }
  }

  public void testInlineRunnableRun() {
    doTestInlineThisOnly();
  }

  public void testPreserveLeadingTailingComments() {
    doTestInlineThisOnly();
  }

  public void testSkipEmptyMethod() {
    doTestInlineThisOnly();
  }

  public void testOneLineLambdaVoidCompatibleToBlock() {
    doTestInlineThisOnly();
  }

  public void testOneLineLambdaValueCompatibleToBlock() {
    doTestInlineThisOnly();
  }

  public void testOneLineLambdaVoidCompatibleOneLine() {
    doTestInlineThisOnly();
  }

  public void testOneLineLambdaValueCompatibleOneLine() {
    doTestInlineThisOnly();
  }

  public void testOnMethodReference() {
    doTestInlineThisOnly();
  }

  public void testOnLambda() {
    doTestInlineThisOnly();
  }

  public void testNonCodeUsage() {
    doTest(true);
  }

  public void testMethodInsideChangeIfStatement() {
    doTest();
  }

  public void testSameVarMethodNames() {
    doTest();
  }

  public void testThisNameConflict() {
    doTest();
  }

  public void testStringPlusOverload() {
    doTest();
  }

  public void testReturnStatementWithoutBraces() {
    doTestInlineThisOnly();
  }

  public void testUnresolvedArgPassedToSameNameParameter() {
    doTestInlineThisOnly();
  }

  public void testMakeTypesDenotable() {
    doTestInlineThisOnly();
  }

  public void testInlineIntoMethodRef() {
    doTestInlineThisOnly();
  }

  public void testInlineIntoConstructorRef() {
    doTestInlineThisOnly();
  }

  public void testSideEffectsInMethodRefQualifier() {
    doTestConflict("Inlined method is used in method reference with side effects in qualifier");
  }

  public void testUnableToInlineCodeBlockToSuper() {
    doTestConflict("Inline cannot be applied to multiline method in constructor call");
  }

  public void testRedundantCastOnMethodReferenceToLambda() {
    doTest();
  }

  public void testInaccessibleSuperCallWhenQualifiedInline() {
    doTestConflict("Inlined method calls super.bar() which won't be accessed in class B");
  }

  public void testInaccessibleSuperCallWhenQualifiedInInheritor() {
    doTestConflict("Inlined method calls super.foo() which won't be accessible on qualifier c");
  }

  public void testInaccessibleConstructorInInlinedMethod() {
    doTestConflict("Constructor SomeClass.SomeClass() that is used in inlined method is not accessible from call site(s) in method InlineWithPrivateConstructorAccessMain.main(String...)");
  }

  public void testPreserveResultedVariableIfInitializerIsNotSideEffectsFree() {
    doTestInlineThisOnly();
  }

  public void testExprLambdaExpandToCodeBlock() {
    doTestInlineThisOnly();
  }

  public void testSuperCallWhenUnqualifiedInline() {
    doTestInlineThisOnly();
  }

  public void testRemoveReturnForTailTypeSimpleWhenNoSideEffectsPossible() {
    doTestInlineThisOnly();
  }

  public void testDeleteOverrideAnnotations() {
    doTest();
  }

  public void testNegativeArguments() {
    doTest();
  }

  public void testInaccessibleFieldInSuperClass() {
    doTestConflict("Field A.i that is used in inlined method is not accessible from call site(s) in method B.bar()");
  }

  public void testPrivateFieldInSuperClassInSameFile() {
    doTest();
  }

  public void testInlineMultipleOccurrencesInFieldInitializer() {
    doTest();
  }

  public void testAvoidMultipleSubstitutionInParameterTypes() {
    doTest();
  }

  public void testRespectProjectScopeSrc() {
    doTest();
  }

  public void testRespectProjectScopeSrcConstructorCall() {
    doTest();
  }

  public void testChainedConstructorWithMultipleStatements() {
    doTestInlineThisOnly();
  }

  public void testThisExpressionValidationForLocalClasses() {
    doTestInlineThisOnly();
  }

  @Override
  protected Sdk getProjectJDK() {
    return getTestName(false).contains("Src") ? IdeaTestUtil.getMockJdk17() : super.getProjectJDK();
  }

  private void doTestInlineThisOnly() {
    @NonNls String fileName = "/refactoring/inlineMethod/" + getTestName(false) + ".java";
    configureByFile(fileName);
    performAction(new MockInlineMethodOptions(){
      @Override
      public boolean isInlineThisOnly() {
        return true;
      }
    }, false);
    checkResultByFile(fileName + ".after");
  }

  private void doTest() {
    doTest(false);
  }

  private void doTest(final boolean nonCode) {
    String name = getTestName(false);
    @NonNls String fileName = "/refactoring/inlineMethod/" + name + ".java";
    configureByFile(fileName);
    performAction(nonCode);
    checkResultByFile(fileName + ".after");
  }

  private void performAction(final boolean nonCode) {
    performAction(new MockInlineMethodOptions(), nonCode);
  }

  private void performAction(final InlineOptions options, final boolean nonCode) {
    PsiElement element = TargetElementUtil
      .findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED | TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED);
    final PsiReference ref = myFile.findReferenceAt(myEditor.getCaretModel().getOffset());
    if (ref instanceof PsiJavaCodeReferenceElement) {
      final PsiElement parent = ((PsiJavaCodeReferenceElement)ref).getParent();
      if (parent instanceof PsiNewExpression) {
        element = ((PsiNewExpression)parent).resolveConstructor();
      }
    }
    PsiReferenceExpression refExpr = ref instanceof PsiReferenceExpression ? (PsiReferenceExpression)ref : null;
    assertTrue(element instanceof PsiMethod);
    PsiMethod method = (PsiMethod)element.getNavigationElement();
    final boolean condition = InlineMethodProcessor.checkBadReturns(method) && !InlineUtil.allUsagesAreTailCalls(method);
    assertFalse("Bad returns found", condition);
    final InlineMethodProcessor processor =
      new InlineMethodProcessor(getProject(), method, refExpr, myEditor, options.isInlineThisOnly(), nonCode, nonCode,
                                !options.isKeepTheDeclaration());
    processor.run();
  }
}


text:
define(['../internal/baseFlatten', '../internal/isIterateeCall'], function(baseFlatten, isIterateeCall) {

  /**
   * Flattens a nested array. If `isDeep` is `true` the array is recursively
   * flattened, otherwise it is only flattened a single level.
   *
   * @static
   * @memberOf _
   * @category Array
   * @param {Array} array The array to flatten.
   * @param {boolean} [isDeep] Specify a deep flatten.
   * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
   * @returns {Array} Returns the new flattened array.
   * @example
   *
   * _.flatten([1, [2], [3, [[4]]]]);
   * // => [1, 2, 3, [[4]]];
   *
   * // using `isDeep`
   * _.flatten([1, [2], [3, [[4]]]], true);
   * // => [1, 2, 3, 4];
   */
  function flatten(array, isDeep, guard) {
    var length = array ? array.length : 0;
    if (guard && isIterateeCall(array, isDeep, guard)) {
      isDeep = false;
    }
    return length ? baseFlatten(array, isDeep) : [];
  }

  return flatten;
});


text:
<?php

namespace CaseStoreBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackValidator;
use Symfony\Component\Form\FormBuilderInterface;

/**
 *  @license 3-clause BSD
 *  @link https://github.com/CaseStore/CaseStore-Core
 */
class CaseStudyDocumentNewType extends AbstractType {

    public function buildForm(FormBuilderInterface $builder, array $options) {

        $builder->add('title', 'text', array(
            'required' => true,
            'label'=>'Title'
        ));

        $builder->add('file', 'file', array(
            'required' => true,
            'label'=>'Document'
        ));

        $builder->add('isCaseStudyUsersOnly', 'checkbox', array(
            'required' => false,
            'label'=>'Is for Involved Staff Only?'
        ));

    }

    public function getName() {
        return 'node';
    }

    public function getDefaultOptions(array $options) {
        return array(
            'data_class' => 'CaseStoreBundle\Entity\CaseStudyDocument',
        );
    }
}