text:
/*************************************************************************/
/*  cp_player_data_nna.cpp                                               */
/*************************************************************************/
/*                       This file is part of:                           */
/*                           GODOT ENGINE                                */
/*                    http://www.godotengine.org                         */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur.                 */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md)    */
/*                                                                       */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the       */
/* "Software"), to deal in the Software without restriction, including   */
/* without limitation the rights to use, copy, modify, merge, publish,   */
/* distribute, sublicense, and/or sell copies of the Software, and to    */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions:                                             */
/*                                                                       */
/* The above copyright notice and this permission notice shall be        */
/* included in all copies or substantial portions of the Software.       */
/*                                                                       */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
/*************************************************************************/

#include "cp_player_data.h"

void CPPlayer::process_NNAs() {

	int i;

	if (!song->has_instruments()) return;

	for (i = 0; i < CPPattern::WIDTH; i++) {

		Channel_Control *aux_chn_ctrl = &control.channel[i];

		if (aux_chn_ctrl->kick == KICK_NOTE) {

			bool k = false;

			if (aux_chn_ctrl->slave_voice != NULL) {

				Voice_Control *aux_voc_ctrl;

				aux_voc_ctrl = aux_chn_ctrl->slave_voice;

				if (aux_chn_ctrl->instrument_index == aux_chn_ctrl->slave_voice->instrument_index) { //maybe carry

					aux_chn_ctrl->carry.pan = aux_chn_ctrl->slave_voice->panning_envelope_ctrl;
					aux_chn_ctrl->carry.vol = aux_chn_ctrl->slave_voice->volume_envelope_ctrl;
					aux_chn_ctrl->carry.pitch = aux_chn_ctrl->slave_voice->pitch_envelope_ctrl;
					aux_chn_ctrl->carry.maybe = true;
				} else
					aux_chn_ctrl->carry.maybe = false;

				if (aux_voc_ctrl->NNA_type != CPInstrument::NNA_NOTE_CUT) {
					/* Make sure the old MP_VOICE channel knows it has no
					   master now ! */

					aux_chn_ctrl->slave_voice = NULL;
					/* assume the channel is taken by NNA */
					aux_voc_ctrl->has_master_channel = false;

					switch (aux_voc_ctrl->NNA_type) {
						case CPInstrument::NNA_NOTE_CONTINUE: {

						} break;
						case CPInstrument::NNA_NOTE_OFF: {

							aux_voc_ctrl->note_end_flags |= END_NOTE_OFF;

							if (!aux_voc_ctrl->volume_envelope_ctrl.active || aux_voc_ctrl->instrument_ptr->get_volume_envelope()->is_loop_enabled()) {
								aux_voc_ctrl->note_end_flags |= END_NOTE_FADE;
							}
						} break;
						case CPInstrument::NNA_NOTE_FADE: {

							aux_voc_ctrl->note_end_flags |= END_NOTE_FADE;
						} break;
					}
				}
			}

			if (aux_chn_ctrl->duplicate_check_type != CPInstrument::DCT_DISABLED) {
				int i;

				for (i = 0; i < control.max_voices; i++) {
					if (!mixer->is_voice_active(i) ||
							(voice[i].master_channel != aux_chn_ctrl) ||
							(aux_chn_ctrl->instrument_index != voice[i].instrument_index))
						continue;

					Voice_Control *aux_voc_ctrl;

					aux_voc_ctrl = &voice[i];

					k = false;
					switch (aux_chn_ctrl->duplicate_check_type) {
						case CPInstrument::DCT_NOTE:
							if (aux_chn_ctrl->note == aux_voc_ctrl->note)
								k = true;
							break;
						case CPInstrument::DCT_SAMPLE:
							if (aux_chn_ctrl->sample_ptr == aux_voc_ctrl->sample_ptr)
								k = true;
							break;
						case CPInstrument::DCT_INSTRUMENT:
							k = true;
							break;
					}
					if (k) {
						switch (aux_chn_ctrl->duplicate_check_action) {
							case CPInstrument::DCA_NOTE_CUT: {
								aux_voc_ctrl->fadeout_volume = 0;
							} break;
							case CPInstrument::DCA_NOTE_OFF: {

								aux_voc_ctrl->note_end_flags |= END_NOTE_OFF;

								if (!aux_voc_ctrl->volume_envelope_ctrl.active || aux_chn_ctrl->instrument_ptr->get_volume_envelope()->is_loop_enabled()) {

									aux_voc_ctrl->note_end_flags |= END_NOTE_FADE;
								}

							} break;
							case CPInstrument::DCA_NOTE_FADE: {
								aux_voc_ctrl->note_end_flags |= END_NOTE_FADE;
							} break;
						}
					}
				}
			}
		} /* if (aux_chn_ctrl->kick==KICK_NOTE) */
	}
}


text:
using v8::String;
using v8::FunctionTemplate;
using v8::Value;
using v8::Handle;
using v8::Local;
using Nan::Utf8String;
using Nan::GetFunction;
using Nan::New;
using Nan::Set;

static const uid_t uid_not_found = static_cast<uid_t>(-1);
static const gid_t gid_not_found = static_cast<gid_t>(-1);

static gid_t gid_by_name(const char* name) {
  struct group pwd;
  struct group* pp;
  char buf[8192];

  errno = 0;
  pp = NULL;

  if (getgrnam_r(name, &pwd, buf, sizeof(buf), &pp) == 0 && pp != NULL) {
    return pp->gr_gid;
  }

  return gid_not_found;
}

static gid_t gid_by_name(Local<Value> value) {
  if (value->IsUint32()) {
    return static_cast<gid_t>(value->Uint32Value());
  } else {
    Utf8String name(value);
    return gid_by_name(*name);
  }
}

static uid_t uid_by_name(const char* name) {
  struct passwd pwd;
  struct passwd* pp;
  char buf[8192];

  errno = 0;
  pp = NULL;

  if (getpwnam_r(name, &pwd, buf, sizeof(buf), &pp) == 0 && pp != NULL) {
    return pp->pw_uid;
  }

  return uid_not_found;
}

static uid_t uid_by_name(Local<Value> value) {
  if (value->IsUint32()) {
    return static_cast<uid_t>(value->Uint32Value());
  } else {
    Utf8String name(value);
    return uid_by_name(*name);
  }
}

NAN_METHOD(GetEUid) {
  info.GetReturnValue().Set(static_cast<uint32_t>(geteuid()));
}

NAN_METHOD(GetEGid) {
  info.GetReturnValue().Set(static_cast<uint32_t>(getegid()));
}

NAN_METHOD(SetEUid) {
  if (!info[0]->IsUint32() && !info[0]->IsString()) {
    return Nan::ThrowTypeError("seteuid argument must be a number or string");
  }

  uid_t uid = uid_by_name(info[0]);

  if (uid == uid_not_found) {
    return Nan::ThrowError("seteuid user id does not exist");
  }

  if (seteuid(uid)) {
    return Nan::ThrowError(Nan::ErrnoException(errno, "seteuid", "", NULL));
  }
}

NAN_METHOD(SetEGid) {
  if (!info[0]->IsUint32() && !info[0]->IsString()) {
    return Nan::ThrowTypeError("setguid argument must be a number or string");
  }

  gid_t gid = gid_by_name(info[0]);

  if (gid == gid_not_found) {
    return Nan::ThrowError("setegid user id does not exist");
  }

  if (setegid(gid)) {
    return Nan::ThrowError(Nan::ErrnoException(errno, "setegid", "", NULL));
  }
}

NAN_MODULE_INIT(Init) {
  Set(target, New<String>("geteuid").ToLocalChecked(),
    GetFunction(New<FunctionTemplate>(GetEUid)).ToLocalChecked());
  Set(target, New<String>("getegid").ToLocalChecked(),
    GetFunction(New<FunctionTemplate>(GetEGid)).ToLocalChecked());
  Set(target, New<String>("seteuid").ToLocalChecked(),
    GetFunction(New<FunctionTemplate>(SetEUid)).ToLocalChecked());
  Set(target, New<String>("setegid").ToLocalChecked(),
    GetFunction(New<FunctionTemplate>(SetEGid)).ToLocalChecked());
}

NODE_MODULE(effective, Init)

redpajama_set_name: RedPajamaGithub


text:
/* globals QUnit: false */

QUnit.module('filterPath');

QUnit.test('Link paths not location path', function(assert) {
  var locationPath = $.smoothScroll.filterPath(location.pathname);

  $('a[href*=#]').each(function() {
    assert.notEqual(locationPath, this.pathname);
  });
});

QUnit.module('scrollable');

QUnit.test('Returns first scrollable element (html,body)', function(assert) {
  var scrollable = $('html,body').firstScrollable();
  var scrollingElement = document.scrollingElement || document.body;

  assert.equal(scrollable.length, 1, 'One scrollable element is returned');
  assert.equal(scrollable[0], scrollingElement, 'Scrollable element matches document.scrollingElement or <body>');
});

QUnit.test('Returns scrollable element (div#scrollable)', function(assert) {
  var scrollable = $('#scrollable').scrollable();

  assert.equal(scrollable.length, 1, 'One scrollable element is returned');
  assert.equal(scrollable[0].id, 'scrollable', 'Scrollable element is <div id="scrollable">');
});

QUnit.module('$.smoothScroll');
QUnit.test('Scrolls the #scrollable element, or not.', function(assert) {
  var done = assert.async(2);

  $.smoothScroll({
    scrollElement: $('#scrollable'),
    scrollTarget: '#does-not-exist',
    speed: 200,
    afterScroll: function() {
      var scrollTop = $('#scrollable').scrollTop();

      assert.equal(scrollTop, 0, '#scrollable element does not scroll to non-existant element');

      // Trigger the next scroll, which should actually work
      $('#scrollit').trigger('click');
      done();
    }
  });

  $('#scrollit').bind('click', function(event) {
    event.preventDefault();
    $.smoothScroll({
      scrollElement: $('#scrollable'),
      scrollTarget: '#findme',
      speed: 200,
      afterScroll: function() {
        var scrollTop = $('#scrollable').scrollTop();

        assert.equal(scrollTop, 100, '#scrollable element scrolls');
        done();
      }
    });
  });
});

QUnit.test('Auto-focuses the scroll target element after scrolling', function(assert) {
  var done = assert.async(1);

  $.smoothScroll({
    scrollTarget: '#scrollable',
    speed: 100,
    autoFocus: true,
    afterScroll: function(opts) {
      assert.equal($(opts.scrollTarget)[0], document.activeElement, 'autofocus scrollTarget');
      done();
    }
  });
});

QUnit.test('Scrolls the #scrollable element to absolute or relative scroll position', function(assert) {
  var done = assert.async(3);

  var finalScroll = function() {
    $.smoothScroll({
      scrollElement: $('#scrollable'),
      speed: 100,
      afterScroll: function() {
        var scrollTop = $('#scrollable').scrollTop();

        assert.equal(scrollTop, 10, '#scrollable element scrolls back to 10');

        // Trigger the next scroll, which should actually work
        done();
      }
    }, 10);
  };

  $.smoothScroll({
    scrollElement: $('#scrollable'),
    speed: 100,
    afterScroll: function() {
      var scrollTop = $('#scrollable').scrollTop();

      assert.equal(scrollTop, 15, '#scrollable element scrolls to 15');

      // Trigger the next scroll, which should actually work
      $('#scrollit').trigger('click');
      done();
    }
  }, 15);

  $('#scrollit').bind('click', function(event) {
    event.preventDefault();

    $.smoothScroll({
      scrollElement: $('#scrollable'),
      speed: 100,
      afterScroll: function() {
        var scrollTop = $('#scrollable').scrollTop();

        assert.equal(scrollTop, 25, '#scrollable element scrolls "+=10" to 25');
        done();
        finalScroll();
      }
    }, '+=10');
  });
});


text:
import React, { PropTypes } from 'react';

const Star = props => {
  if (props.filled) {
    return <i className="fa fa-star" />;
  }
  return <i className="fa fa-star-o" />;
};

Star.propTypes = {
  filled: PropTypes.bool.isRequired
};

export default Star;


text:
import tkinter
import tkinter.font
import mbhandler

spin = ["|","/","-","\\"]
spinIndex = 0

mbhandler.init(output="raw")

root = tkinter.Tk()
root.title("Quiz")
frame = tkinter.Frame(root,width="200px",height="200px")
frame.grid_propagate(0)
frame.pack()

font = tkinter.font.Font(family='TeX Gyre Pagella', size=20)

b = tkinter.Button(frame, text="Click to start", font=font)
q = tkinter.Button(frame, text="Quit", font=font)

w = tkinter.Label(frame, justify=tkinter.RIGHT, text="Waiting ",font = font)
spinVar = tkinter.StringVar()
sp = tkinter.Label(frame, justify=tkinter.LEFT, textvariable=spinVar, font=font)
w.grid(sticky=tkinter.E,row=0)
sp.grid(sticky=tkinter.W,row=0,column=1)

m = tkinter.Label(frame, justify=tkinter.RIGHT, text="Team ",font = font)
mbVar = tkinter.StringVar()
mb = tkinter.Label(frame, justify=tkinter.LEFT, textvariable=mbVar,font = font)
m.grid(sticky=tkinter.E,row=0)
mb.grid(sticky=tkinter.W,row=0,column=1)

b.grid(sticky=tkinter.W,row=2)
q.grid(sticky=tkinter.SE,row=3)
w.grid_remove()
sp.grid_remove()
m.grid_remove()
mb.grid_remove()

def start():
    while not mbhandler.queue.empty():
        mbhandler.queue.get()
    b.grid_remove()
    m.grid_remove()
    mb.grid_remove()
    w.grid()
    sp.grid()
    root.after(100,update)

def update():
    if not mbhandler.queue.empty():
        msg = mbhandler.queue.get()
        mbVar.set(msg)
        b.config(text="Click to restart")
        w.grid_remove()
        sp.grid_remove()
        b.grid()
        m.grid()
        mb.grid()
        root.update()
    else:
        global spinIndex
        spinIndex += 1
        spinIndex %= 4
        spinVar.set(spin[spinIndex])
        root.update()
        root.after(100,update)

def finish():
    root.destroy()

b.config(command=start)
q.config(command=finish)

root.mainloop()


text:
<?php
namespace apache\shindig\common;

/**
 * Utility interface for managing signed, encrypted, and time stamped blobs.
 * Blobs are made up of name/value pairs.  Time stamps are automatically
 * included and checked.
 *
 */
abstract class BlobCrypter {

  /**
   * Time stamps, encrypts, and signs a blob.
   *
   * @param array $in name/value pairs to encrypt
   * @return string a base64 encoded blob
   *
   * @throws BlobCrypterException
   */
  abstract public function wrap(Array $in);

  /**
   * Unwraps a blob.
   *
   * @param string $in blob
   * @param int $maxAgeSec maximum age for the blob
   * @return array the name/value pairs, including the origin timestamp.
   *
   * @throws BlobExpiredException if the blob is too old to be accepted.
   * @throws BlobCrypterException if the blob can't be decoded.
   */
  abstract public function unwrap($in, $maxAgeSec);
}


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

<title>Uses of Package test</title>
<meta name="date" content="2013-04-14">
<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
test

Packages that use test

Package
Description

test

Classes in test used by test

Class and Description

WebBrowserTest2

WebBrowserTest2.chivserver

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes


text:
package org.zalando.stups.fullstop.plugin;

import org.joda.time.DateTime;

import java.nio.file.Paths;

/**
 * @author jbellmann
 */
class PrefixBuilder {

    /**
     * Builds the prefix that will be prepended to the 'bucketname'<br/>
     * Something like '123456789/eu-west-1/2015/06/12/'
     *
     * @param accountId
     * @param region             name of region
     * @param instanceLaunchTime
     * @return
     */
    static String build(final String accountId, final String region, final DateTime instanceLaunchTime) {
        return Paths.get(
                accountId, region, instanceLaunchTime.toString("YYYY"), instanceLaunchTime.toString("MM"),
                instanceLaunchTime.toString("dd")).toString() + "/";
    }

}


text:
android-views
=============

![Alt text](https://github.com/geftimov/android-views/blob/master/pictures/alert-dialog-fragment/alert-dialog-fragment.png?raw=true)

How to use
=============

```
        AlertDialogFragment alertDialogFragment = new AlertDialogFragment.Builder().
            message("what").
            positive("ok").
            negative("negative").
            build();

        alertDialogFragment.show(getFragmentManager(),"tag");
```


text:
var SnapFloor = require('../../math/snap/SnapFloor');
var SnapCeil = require('../../math/snap/SnapCeil');

/**
 * Returns the tiles in the given layer that are within the camera's viewport. This is used internally.
 *
 * @function Phaser.Tilemaps.Components.CullTiles
 * @private
 * @since 3.0.0
 *
 * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
 * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against.
 * @param {array} [outputArray] - An optional array to store the Tile objects within.
 *
 * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects.
 */
var CullTiles = function (layer, camera, outputArray, renderOrder)
{
    if (outputArray === undefined) { outputArray = []; }
    if (renderOrder === undefined) { renderOrder = 0; }

    outputArray.length = 0;

    var tilemap = layer.tilemapLayer.tilemap;
    var tilemapLayer = layer.tilemapLayer;

    var mapData = layer.data;
    var mapWidth = layer.width;
    var mapHeight = layer.height;

    //  We need to use the tile sizes defined for the map as a whole, not the layer,
    //  in order to calculate the bounds correctly. As different sized tiles may be
    //  placed on the grid and we cannot trust layer.baseTileWidth to give us the true size.
    var tileW = Math.floor(tilemap.tileWidth * tilemapLayer.scaleX);
    var tileH = Math.floor(tilemap.tileHeight * tilemapLayer.scaleY);

    var drawLeft = 0;
    var drawRight = mapWidth;
    var drawTop = 0;
    var drawBottom = mapHeight;

    if (!tilemapLayer.skipCull && tilemapLayer.scrollFactorX === 1 && tilemapLayer.scrollFactorY === 1)
    {
        //  Camera world view bounds, snapped for scaled tile size
        //  Cull Padding values are given in tiles, not pixels

        var boundsLeft = SnapFloor(camera.worldView.x - tilemapLayer.x, tileW, 0, true) - tilemapLayer.cullPaddingX;
        var boundsRight = SnapCeil(camera.worldView.right - tilemapLayer.x, tileW, 0, true) + tilemapLayer.cullPaddingX;
        var boundsTop = SnapFloor(camera.worldView.y - tilemapLayer.y, tileH, 0, true) - tilemapLayer.cullPaddingY;
        var boundsBottom = SnapCeil(camera.worldView.bottom - tilemapLayer.y, tileH, 0, true) + tilemapLayer.cullPaddingY;

        drawLeft = Math.max(0, boundsLeft);
        drawRight = Math.min(mapWidth, boundsRight);
        drawTop = Math.max(0, boundsTop);
        drawBottom = Math.min(mapHeight, boundsBottom);
    }

    var x;
    var y;
    var tile;

    if (renderOrder === 0)
    {
        //  right-down

        for (y = drawTop; y < drawBottom; y++)
        {
            for (x = drawLeft; mapData[y] && x < drawRight; x++)
            {
                tile = mapData[y][x];

                if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0)
                {
                    continue;
                }

                outputArray.push(tile);
            }
        }
    }
    else if (renderOrder === 1)
    {
        //  left-down

        for (y = drawTop; y < drawBottom; y++)
        {
            for (x = drawRight; mapData[y] && x >= drawLeft; x--)
            {
                tile = mapData[y][x];

                if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0)
                {
                    continue;
                }

                outputArray.push(tile);
            }
        }
    }
    else if (renderOrder === 2)
    {
        //  right-up

        for (y = drawBottom; y >= drawTop; y--)
        {
            for (x = drawLeft; mapData[y] && x < drawRight; x++)
            {
                tile = mapData[y][x];

                if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0)
                {
                    continue;
                }

                outputArray.push(tile);
            }
        }
    }
    else if (renderOrder === 3)
    {
        //  left-up

        for (y = drawBottom; y >= drawTop; y--)
        {
            for (x = drawRight; mapData[y] && x >= drawLeft; x--)
            {
                tile = mapData[y][x];

                if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0)
                {
                    continue;
                }

                outputArray.push(tile);
            }
        }
    }

    tilemapLayer.tilesDrawn = outputArray.length;
    tilemapLayer.tilesTotal = mapWidth * mapHeight;

    return outputArray;
};

module.exports = CullTiles;


text:
#include <GL/glew.h>
#include "Tangram.h"
#include "../../Engine/Shapes/Triangle.h"
#include "../../Engine/Shapes/Square.h"
#include "../../Engine/Shapes/Parallelogram.h"

#define VERTICES 0
#define COLORS 1

using json = nlohmann::json;

namespace ThreeEngine {

    Tangram::Tangram() : Engine(), shapeToShow(FISH) {}

    Tangram::~Tangram() = default;

    void Tangram::OnInit() {
        switch (shapeToShow) {
            case SAMPLE:
                Shapes();
                break;
            case TANGRAM:
                SimpleTangram();
                break;
            case HEART:
                Heart();
                break;
            case FISH:
                Fish();
                break;
        }
    }

    void Tangram::Shapes() {
        auto colorProgram = std::make_shared<ShaderProgram>("shaders/SimpleColor/program.json");
        colorProgram->Init();
        auto wireframeProgram = std::make_shared<ShaderProgram>("shaders/Wireframe/program.json");
        wireframeProgram->Init();

        Debug::Log(*colorProgram);
        Debug::Log(*wireframeProgram);

        { // Small triangle at the top right
            auto* triangle = new Triangle();
            triangle->transform = Matrix::TranslationMatrix({0.2f, 0.2f, 0, 0});
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = wireframeProgram;
        }
        { // Square
            GLfloat RGBA[6][4] = {
                    {1.0f, 0.0f, 0.0f, 1.0f},
                    {0.5f, 0.1f, 0.8f, 1.0f},
                    {0.0f, 0.0f, 1.0f, 1.0f},
                    {0.5f, 0.1f, 0.8f, 1.0f},
                    {0.3f, 0.1f, 0.8f, 1.0f},
                    {0.0f, 0.0f, 1.0f, 1.0f}
            };
            auto* square = new Square(RGBA);
            square->transform = Matrix::TranslationMatrix({-0.8f, 0, 0, 0});
            actors.push_back((IDrawable*) square);

            square->shaderProgram = colorProgram;
        }
        { // Parallelogram
            auto* parallelogram = new Parallelogram();
            parallelogram->transform = Matrix::TranslationMatrix(Vector({-1, -1, 0}));
            actors.push_back((IDrawable*) parallelogram);

            parallelogram->shaderProgram = colorProgram;
        }
    }

    void Tangram::SimpleTangram() {
        auto colorProgram = std::make_shared<ShaderProgram>("shaders/SimpleColor/program.json");
        colorProgram->Init();
        auto wireframeProgram = std::make_shared<ShaderProgram>("shaders/Wireframe/program.json");
        wireframeProgram->Init();
        Debug::Log(*colorProgram);
        Debug::Log(*wireframeProgram);

        Matrix viewM = Matrix::IdentityMatrix();

        { // Big triangle to the Left
            auto* triangle = new Triangle();
            Matrix2 transform2D =
                    (TMatrix<2, 2>) Matrix2::RotationMatrix(135) * Matrix2::ScaleMatrix(2, 2);
            triangle->transform = viewM *
                                  Matrix::TranslationMatrix({0.0f, 0.0f, 0, 0}) *
                                  Matrix(transform2D);
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = wireframeProgram;
        }
        { // Big triangle to the Top
            GLfloat RGBA[3][4] = {
                    {1.0f, 0.0f, 0.0f, 1.0f},
                    {1.0f, 1.0f, 0.0f, 1.0f},
                    {1.0f, 0.0f, 1.0f, 1.0f}
            };
            auto* triangle = new Triangle(RGBA);
            Matrix2 transform2D =
                    (TMatrix<2, 2>) Matrix2::RotationMatrix(45) * Matrix2::ScaleMatrix(2, 2);
            triangle->transform = viewM *
                                  Matrix::TranslationMatrix({0.0f, 0.0f, 0, 0}) *
                                  Matrix(transform2D);
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = colorProgram;
        }
        { // Small triangle at the center
            GLfloat RGBA[3][4] = {
                    {1.0f, 0.0f, 1.0f, 1.0f},
                    {0.0f, 1.0f, 1.0f, 1.0f},
                    {0.0f, 0.0f, 1.0f, 1.0f}
            };
            auto* triangle = new Triangle(RGBA);
            Matrix2 transform2D = (TMatrix<2, 2>) Matrix2::RotationMatrix(-135);
            triangle->transform = viewM * Matrix(transform2D);
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = colorProgram;
        }
        { // Small triangle at the top right
            auto* triangle = new Triangle();
            Matrix2 transform2D = (TMatrix<2, 2>) Matrix2::RotationMatrix(-45);
            triangle->transform =
                    viewM * Matrix::TranslationMatrix({0.5f, 0.5f, 0, 0}) *
                    Matrix(transform2D);
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = wireframeProgram;
        }
        { // Medium triangle to the bottom right
            auto* triangle = new Triangle();
            Matrix2 transform2D =
                    (TMatrix<2, 2>) Matrix2::RotationMatrix(90) *
                    Matrix2::ScaleMatrix(1.414f, 1.414f);
            triangle->transform =
                    viewM * Matrix::TranslationMatrix({1.0f, -1.0f, 0, 0}) * Matrix(transform2D);
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = colorProgram;
        }
        { // Square
            GLfloat RGBA[6][4] = {
                    {1.0f, 0.0f, 0.0f, 1.0f},
                    {0.5f, 0.1f, 0.8f, 1.0f},
                    {0.0f, 0.0f, 1.0f, 1.0f},
                    {0.5f, 0.1f, 0.8f, 1.0f},
                    {0.3f, 0.1f, 0.8f, 1.0f},
                    {0.0f, 0.0f, 1.0f, 1.0f}
            };
            auto* square = new Square(RGBA);
            Matrix2 transform2D =
                    (TMatrix<2, 2>) Matrix2::RotationMatrix(-45);
            square->transform = viewM * Matrix(transform2D);
            actors.push_back((IDrawable*) square);

            square->shaderProgram = colorProgram;
        }
        { // Parallelogram
            auto* parallelogram = new Parallelogram();
            parallelogram->transform = viewM * Matrix::TranslationMatrix(Vector({-1, -1, 0}));
            actors.push_back((IDrawable*) parallelogram);

            parallelogram->shaderProgram = colorProgram;
        }
    }

    void Tangram::Heart() {
        // Backface culling with front face detected using Counter Clockwise hand
        glDisable(GL_CULL_FACE);

        auto colorProgram = std::make_shared<ShaderProgram>("shaders/SimpleColor/program.json");
        colorProgram->Init();
        auto wireframeProgram = std::make_shared<ShaderProgram>("shaders/Wireframe/program.json");
        wireframeProgram->Init();
        Debug::Log(*colorProgram);
        Debug::Log(*wireframeProgram);

        Matrix viewM = Matrix(Matrix2::ScaleMatrix(.6f, .6f));

        { // Big triangle to the Left
            auto* triangle = new Triangle();
            Matrix2 transform2D =
                    (TMatrix<2, 2>) Matrix2::RotationMatrix(-135) * Matrix2::ScaleMatrix(2, 2);
            triangle->transform = viewM *
                                  Matrix::TranslationMatrix({-.5f, 1.0f, 0, 0}) *
                                  Matrix(transform2D);
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = wireframeProgram;
        }
        { // Parallelogram
            auto* parallelogram = new Parallelogram();
            Matrix2 transform2D =
                    (TMatrix<2, 2>) Matrix2::ScaleMatrix(-1, 1);
            parallelogram->transform =
                    viewM * Matrix::TranslationMatrix(Vector({1.5, 0, 0})) * Matrix(transform2D);
            actors.push_back((IDrawable*) parallelogram);

            parallelogram->shaderProgram = colorProgram;
        }
        { // Small triangle at the top right
            auto* triangle = new Triangle();
            Matrix2 transform2D = (TMatrix<2, 2>) Matrix2::RotationMatrix(-135);
            triangle->transform =
                    viewM * Matrix::TranslationMatrix({0.5f, 1, 0, 0}) *
                    Matrix(transform2D);
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = wireframeProgram;
        }
        { // Medium triangle
            auto* triangle = new Triangle();
            Matrix2 transform2D =
                    (TMatrix<2, 2>) Matrix2::RotationMatrix(180) *
                    Matrix2::ScaleMatrix(1.414f, 1.414f);
            triangle->transform =
                    viewM * Matrix::TranslationMatrix({-0.5f, 0, 0, 0}) * Matrix(transform2D);
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = colorProgram;
        }
        { // Small triangle at the center
            GLfloat RGBA[3][4] = {
                    {1.0f, 0.0f, 1.0f, 1.0f},
                    {0.0f, 1.0f, 1.0f, 1.0f},
                    {0.0f, 0.0f, 1.0f, 1.0f}
            };
            auto* triangle = new Triangle(RGBA);
            Matrix2 transform2D = (TMatrix<2, 2>) Matrix2::RotationMatrix(135);
            triangle->transform =
                    viewM * Matrix::TranslationMatrix({0, -.5f, 0, 0}) * Matrix(transform2D);
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = colorProgram;
        }
        { // Big triangle to the Top
            GLfloat RGBA[3][4] = {
                    {1.0f, 0.0f, 0.0f, 1.0f},
                    {1.0f, 1.0f, 0.0f, 1.0f},
                    {1.0f, 0.0f, 1.0f, 1.0f}
            };
            auto* triangle = new Triangle(RGBA);
            Matrix2 transform2D =
                    (TMatrix<2, 2>) Matrix2::RotationMatrix(45) * Matrix2::ScaleMatrix(2, 2);
            triangle->transform =
                    viewM * Matrix::TranslationMatrix({0.5f, -1.0f, 0, 0}) * Matrix(transform2D);
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = colorProgram;
        }
        { // Square
            GLfloat RGBA[6][4] = {
                    {1.0f, 0.0f, 0.0f, 1.0f},
                    {0.5f, 0.1f, 0.8f, 1.0f},
                    {0.0f, 0.0f, 1.0f, 1.0f},
                    {0.5f, 0.1f, 0.8f, 1.0f},
                    {0.3f, 0.1f, 0.8f, 1.0f},
                    {0.0f, 0.0f, 1.0f, 1.0f}
            };
            auto* square = new Square(RGBA);
            Matrix2 transform2D =
                    (TMatrix<2, 2>) Matrix2::RotationMatrix(-45);
            square->transform =
                    viewM * Matrix::TranslationMatrix({-0.5f, -1.0f, 0, 0}) * Matrix(transform2D);
            actors.push_back((IDrawable*) square);

            square->shaderProgram = wireframeProgram;
        }
    }

    void Tangram::Fish() {
        // Backface culling with front face detected using Counter Clockwise hand
        glDisable(GL_CULL_FACE);

        auto colorProgram = std::make_shared<ShaderProgram>("shaders/SimpleColor/program.json");
        colorProgram->Init();
        auto wireframeProgram = std::make_shared<ShaderProgram>("shaders/Wireframe/program.json");
        wireframeProgram->Init();
        Debug::Log(*colorProgram);
        Debug::Log(*wireframeProgram);

        Matrix viewM = Matrix(Matrix2::ScaleMatrix(.6f, .6f));

        { // Medium triangle
            auto* triangle = new Triangle();
            Matrix2 transform2D =
                    (TMatrix<2, 2>) Matrix2::RotationMatrix(-45) *
                    Matrix2::ScaleMatrix(1.414f, 1.414f);
            triangle->transform =
                    viewM * Matrix::TranslationMatrix({-1.5f, 0, 0, 0}) * Matrix(transform2D);
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = colorProgram;
        }
        { // Big triangle to the Left
            auto* triangle = new Triangle();
            Matrix2 transform2D =
                    (TMatrix<2, 2>) Matrix2::RotationMatrix(-90) * Matrix2::ScaleMatrix(2, 2);
            triangle->transform =
                    viewM * Matrix::TranslationMatrix({-.8f, .7071f * 2, 0, 0}) *
                    Matrix(transform2D);
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = wireframeProgram;
        }
        { // Big triangle to the Top
            GLfloat RGBA[3][4] = {
                    {1.0f, 0.0f, 0.0f, 1.0f},
                    {1.0f, 1.0f, 0.0f, 1.0f},
                    {1.0f, 0.0f, 1.0f, 1.0f}
            };
            auto* triangle = new Triangle(RGBA);
            Matrix2 transform2D =
                    (TMatrix<2, 2>) Matrix2::ScaleMatrix(2, 2);
            triangle->transform =
                    viewM * Matrix::TranslationMatrix({-.8f, -.7071f * 2, 0, 0}) *
                    Matrix(transform2D);
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = colorProgram;
        }
        { // Square
            GLfloat RGBA[6][4] = {
                    {1.0f, 0.0f, 0.0f, 1.0f},
                    {0.5f, 0.1f, 0.8f, 1.0f},
                    {0.0f, 0.0f, 1.0f, 1.0f},
                    {0.5f, 0.1f, 0.8f, 1.0f},
                    {0.3f, 0.1f, 0.8f, 1.0f},
                    {0.0f, 0.0f, 1.0f, 1.0f}
            };
            auto* square = new Square(RGBA);
            Matrix2 transform2D =
                    (TMatrix<2, 2>) Matrix2::RotationMatrix(-45);
            square->transform =
                    viewM * Matrix::TranslationMatrix({-0.8f, 0.0f, 0, 0}) * Matrix(transform2D);
            actors.push_back((IDrawable*) square);

            square->shaderProgram = colorProgram;
        }
        { // Parallelogram
            auto* parallelogram = new Parallelogram();
            Matrix2 transform2D =
                    (TMatrix<2, 2>) Matrix2::RotationMatrix(-135) * Matrix2::ScaleMatrix(-1, 1);
            parallelogram->transform =
                    viewM * Matrix::TranslationMatrix(Vector({.2f, 0, 0})) * Matrix(transform2D);
            actors.push_back((IDrawable*) parallelogram);

            parallelogram->shaderProgram = colorProgram;
        }
        { // Small triangle at the top right
            auto* triangle = new Triangle();
            Matrix2 transform2D = (TMatrix<2, 2>) Matrix2::RotationMatrix(180);
            triangle->transform =
                    viewM * Matrix::TranslationMatrix({0.7071f + .2f, 0, 0, 0}) *
                    Matrix(transform2D);
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = wireframeProgram;
        }
        { // Small triangle at the center
            GLfloat RGBA[3][4] = {
                    {1.0f, 0.0f, 1.0f, 1.0f},
                    {0.0f, 1.0f, 1.0f, 1.0f},
                    {0.0f, 0.0f, 1.0f, 1.0f}
            };
            auto* triangle = new Triangle(RGBA);
            triangle->transform =
                    viewM * Matrix::TranslationMatrix({0.7071f + .2f, -.7071f, 0, 0});
            actors.push_back((IDrawable*) triangle);

            triangle->shaderProgram = colorProgram;
        }
    }

} /* namespace Divisaction */


text:
<!DOCTYPE html>
<html>
	<head>
		<title>mid_Exer01: PHP and MySQL interactions</title>

			<!--DON'T DELETE. contains styles for this page -->
		<link rel="stylesheet" href="https://dl.dropboxusercontent.com/s/yxbyyl56tdwz1wq/mid_Act01b.css">

	</head>
	<body>

			<?php
				include('config.php');

				if(isset($_POST['del']))
				{

 /* place your scripts here */
					$ID = $_POST['del'];
					$qry = "DELETE FROM dbtable01a WHERE ID = $ID";
					$sel = "SELECT * FROM dbtable01a WHERE ID = $ID";

					$result = $conn -> query($sel);

					if($row = $result -> fetch_assoc())
					{
						if($conn -> query($qry))
						{
							echo "Deletion succesful, redirecting in 3 seconds!";
						}
					}else echo "ERROR! ID not found, redirecting in 3 seconds!";
					header("Refresh: 3; url=mid_Exer01.php");

				}

				$conn->close();

			?>

	</body>
</html>


text:
<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <include layout="@layout/toolbar" />

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="72dp"
        app:cardCornerRadius="5dp"
        app:cardElevation="5dp">

        <android.support.design.widget.CoordinatorLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/detail_image_view"
                android:layout_width="match_parent"
                android:layout_height="240dp"
                android:scaleType="fitXY"
                android:src="@drawable/bg4" />

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/detail_fab"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/fab_margin"
                android:src="@drawable/ic_close_white_24dp"
                app:fabSize="normal"
                app:layout_anchor="@id/detail_image_view"
                app:layout_anchorGravity="bottom|end" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="256dp"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_gravity="center"
                    android:layout_marginEnd="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_weight="1"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/detail_book_id"
                        style="@style/BookDetailTextView"
                        android:text="BookId" />

                    <TextView
                        android:id="@+id/detail_cooker_id"
                        style="@style/BookDetailTextView"
                        android:text="CookerId" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_gravity="center"
                    android:layout_marginEnd="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_weight="1"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/detail_cooker_name"
                        style="@style/BookDetailTextView"
                        android:text="Cooker Name" />

                    <TextView
                        android:id="@+id/detail_cooker_location"
                        style="@style/BookDetailTextView"
                        android:text="CookerLocation" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_gravity="center"
                    android:layout_marginEnd="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_weight="1"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/detail_cooker_status"
                        style="@style/BookDetailTextView"
                        android:text="Cooker Status" />

                    <TextView
                        android:id="@+id/detail_rice_weight"
                        style="@style/BookDetailTextView"
                        android:text="Rice Weight" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_gravity="center"
                    android:layout_marginEnd="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_weight="1"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/detail_people_count"
                        style="@style/BookDetailTextView"
                        android:text="People Count" />

                    <TextView
                        android:id="@+id/detail_taste"
                        style="@style/BookDetailTextView"
                        android:text="Taste" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_gravity="center"
                    android:layout_marginEnd="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_weight="1"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/detail_time"
                        style="@style/BookDetailTextView"
                        android:layout_weight="1"
                        android:drawableLeft="@drawable/ic_access_time_red_500_24dp"
                        android:drawablePadding="16dp"
                        android:text="18:00" />

                    <TextView
                        android:id="@+id/detail_holder"
                        style="@style/BookDetailTextView"
                        android:text="" />
                </LinearLayout>

            </LinearLayout>
        </android.support.design.widget.CoordinatorLayout>

    </android.support.v7.widget.CardView>
</android.support.design.widget.CoordinatorLayout>


text:
package io.netty.handler.codec.http2;

import io.netty.handler.codec.AsciiString;
import io.netty.handler.codec.BinaryHeaders;
import io.netty.handler.codec.DefaultBinaryHeaders;

public class DefaultHttp2Headers extends DefaultBinaryHeaders implements Http2Headers {

    public DefaultHttp2Headers() {
    }

    @Override
    public Http2Headers add(AsciiString name, AsciiString value) {
        super.add(name, value);
        return this;
    }

    @Override
    public Http2Headers add(AsciiString name, Iterable<AsciiString> values) {
        super.add(name, values);
        return this;
    }

    @Override
    public Http2Headers add(AsciiString name, AsciiString... values) {
        super.add(name, values);
        return this;
    }

    @Override
    public Http2Headers add(BinaryHeaders headers) {
        super.add(headers);
        return this;
    }

    @Override
    public Http2Headers set(AsciiString name, AsciiString value) {
        super.set(name, value);
        return this;
    }

    @Override
    public Http2Headers set(AsciiString name, Iterable<AsciiString> values) {
        super.set(name, values);
        return this;
    }

    @Override
    public Http2Headers set(AsciiString name, AsciiString... values) {
        super.set(name, values);
        return this;
    }

    @Override
    public Http2Headers set(BinaryHeaders headers) {
        super.set(headers);
        return this;
    }

    @Override
    public Http2Headers setAll(BinaryHeaders headers) {
        super.setAll(headers);
        return this;
    }

    @Override
    public Http2Headers clear() {
        super.clear();
        return this;
    }

    @Override
    public Http2Headers forEachEntry(final BinaryHeaders.BinaryHeaderVisitor visitor) {
        super.forEachEntry(visitor);
        return this;
    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Http2Headers)) {
            return false;
        }

        return super.equals((BinaryHeaders) o);
    }

    @Override
    public Http2Headers method(AsciiString value) {
        set(PseudoHeaderName.METHOD.value(), value);
        return this;
    }

    @Override
    public Http2Headers scheme(AsciiString value) {
        set(PseudoHeaderName.SCHEME.value(), value);
        return this;
    }

    @Override
    public Http2Headers authority(AsciiString value) {
        set(PseudoHeaderName.AUTHORITY.value(), value);
        return this;
    }

    @Override
    public Http2Headers path(AsciiString value) {
        set(PseudoHeaderName.PATH.value(), value);
        return this;
    }

    @Override
    public Http2Headers status(AsciiString value) {
        set(PseudoHeaderName.STATUS.value(), value);
        return this;
    }

    @Override
    public AsciiString method() {
        return get(PseudoHeaderName.METHOD.value());
    }

    @Override
    public AsciiString scheme() {
        return get(PseudoHeaderName.SCHEME.value());
    }

    @Override
    public AsciiString authority() {
        return get(PseudoHeaderName.AUTHORITY.value());
    }

    @Override
    public AsciiString path() {
        return get(PseudoHeaderName.PATH.value());
    }

    @Override
    public AsciiString status() {
        return get(PseudoHeaderName.STATUS.value());
    }
}


text:
Rails.application.routes.draw do
  resources :posts
  resources :authors
end


text:
<?php

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// Early exit if the class already exists
if ( class_exists( 'Kirki_Controls_MultiCheck_Control' ) ) {
	return;
}

class Kirki_Controls_MultiCheck_Control extends WP_Customize_Control {

	public $type = 'multicheck';

	public function enqueue() {

		wp_enqueue_script( 'kirki-multicheck', trailingslashit( kirki_url() ).'includes/controls/multicheck/kirki-multicheck.js', array( 'jquery' ) );
		wp_enqueue_style( 'kirki-multicheck', trailingslashit( kirki_url() ).'includes/controls/multicheck/style.css' );

	}

	public function render_content() {

		if ( empty( $this->choices ) ) {
			return;
		}
		?>

		<?php if ( ! empty( $this->label ) ) : ?>
			<?php echo esc_html( $this->label ); ?>
		<?php endif; ?>

		<?php if ( ! empty( $this->description ) ) : ?>
			<?php echo $this->description; ?>
		<?php endif; ?>

		<?php $multi_values = ( ! is_array( $this->value() ) ) ? explode( ',', $this->value() ) : $this->value(); ?>

			<?php foreach ( $this->choices as $value => $label ) : ?>

						<input type="checkbox" value="<?php echo esc_attr( $value ); ?>" <?php checked( in_array( $value, $multi_values ) ); ?> />
						<?php echo esc_html( $label ); ?>

			<?php endforeach; ?>

		<input type="hidden" <?php $this->link(); ?> value="<?php echo esc_attr( implode( ',', $multi_values ) ); ?>" />
	<?php }
}


text:
title: UCS Integration
category: feature
authors: apuimedo, danken
wiki_category: Feature
wiki_title: Features/UCS Integration
wiki_revision_count: 7
wiki_last_updated: 2014-05-05
feature_name: Cisco UCS integration
feature_modules: engine,network,vdsm
feature_status: Partially Released
---

# UCS Integration

## Summary

Cisco's Unified Computing System (UCS) is a solution for managing a lot of datacenter aspects, from blade's firmware to network cards number and addresses on the hosts and the VMs. It has a management service (UCS-M) that allows the administrator to easily set up configurations to apply to the hardware of the datacenter.

UCS hosts have network cards that can expose N pseudo physical Network Interface Cards, optionally (and usually) as ethernet cards. Those pseudo ethernet cards are called Virtual Functions (VFs) and when they are not configured they are blank devices, i.e., they lack mac address and any connectivity to the network fabric. One particular benefit of the virtual functions is that they can be connected to the guest's operating system offering a superior network performance, since the Host OS is not involved and parts are hardware accelerated.

In terms of networking the configuration for a nic is set in UCS-M in entities called vNic Templates. A vNic template allows you to specify network attributes for the nics created from it such as: - Quality of Service, - VLANs: One can specify the default tag and the tags it should let through, - MTU, - MAC Pool: The network administrator can define several pools of MAC addresses in UCS-M from which a template can draw addresses from.

When a vNic Template applies only to host nics it is called vNic profile. When it also applies to VM vNics an entity is created in UCS-M called \*Port Profile\*.

## Owner

*   Name: [ Antoni Segura Puimedon](User:APuimedo)
*   Email: apuimedo aT redhat.com

## Current oVirt UCS-M networking integration state

Nowadays the virtual functions are reported to Engine as regular nics. VFs that have not been configured via UCS-M to have a mac address and connectivity are still reported, despite their uselessness for Host networking.

There is a Vdsm hook, [vdsm-hook-vmfex](http://resources.ovirt.org/releases/3.3/rpm/EL/6/noarch/vdsm-hook-vmfex-4.13.0-11.el6.noarch.rpm) that after being installed on each host, takes action upon VM creation and migration that:

*   Sets up a pool of virtual functions (thanks to the pool, migration is possible. As far as there are unused devices in the pool, we can assign a vnic to a virtual function).
*   Assigns the Engine-specified MAC address to a virtual function from the pool.
*   Specifies a *Port Profile* the virtual function should adopt.
*   Creates a macvtap device connected to the virtual function and replaces the VM nic definition with it.

For the hook to work, one must manually specify the VM custom properties with

      {'XX:XX:XX:XX:XX:XX': 'port_profile_name1',
       'YY:YY:YY:YY:YY:YY': 'port_profile_name2'}

This implies that the administrator must manually copy the port profile names from UCS-M and the MAC addresses assigned by the engine and write the above dictionary.

## Current status

Level IV completed and released.

## Integration levels

Considering the current level of integration (using the current vdsm-hook-vmfex) as level 3. The proposed levels of this feature are:

### Level IV: "A New Hook"

This level of integration consists of reworking the existing vdsm-hook-vmfex so that the oVirt administrator can set up the integration at the guest device level instead of at the VM level. The advantage of this is that only the port profile will need to be specified (since the MAC address is already part of the VM's NIC properties given by the Engine).

Things done:

*   [Filter out unused virtual functions from being reported as nics](http://gerrit.ovirt.org/#/c/22559/).
*   [Clone and refactor the current hook to use custom device properties and to run "before_device_create" and "before_device_hotplug"](http://gerrit.ovirt.org/#/c/22529/).

You can get the hook resulting from this integration level [here](http://plain.resources.ovirt.org/releases/3.4/rpm/el6/noarch/vdsm-hook-vmfex-dev-4.14.6-0.el6.noarch.rpm)

#### Installation

*   Use the engine-config to append the appropriate custom property:

       sudo engine-config -s CustomDeviceProperties=
       '{type=interface;prop={vmfex=^[a-zA-Z0-9_ ---]+$}}'

*   Verify that the vmfex_dev custom device propertes were properly added:

         sudo engine-config -g CustomDeviceProperties

#### Usage

*   Define an oVirt vNIC profile and set one of its custom properites to "vmfex" with the value of the name of UCS port profile. For instance:

            vmfex: myPortProfileId

*   Attach the oVirt vNIC profile to a VM vNIC. When the VM runs, the vNIC with the vmfex custom device, the xml definition of which might originally look like:

<!-- -->

    <interface type='bridge'>
        <mac address='<mac>'/>
        <model type='virtio'/>
        <source bridge='<logical network>'/>
    </interface>

will be transformed into:

    <interface type='network'>
        <mac address='<mac>'/>
        <source network='direct-pool'/>
        <virtualport type='802.1Qbh'>
            <parameters profileid='<Port Profile id>'/>
        </virtualport>
        <model type='virtio'/>
    </interface>

### Level V: "The Network provider strikes back"

This level of integration builds on top of the work that was laid out for the Neutron integration, i.e., Network providers, so that we can use the UCS-M API (it exposes all entities via XML HTTP requests) to retrieve the port profiles defined in the system. These port profiles would be available for selection in the VM nic creation dialog.

Things to be done:

*   Implement a Network provider that talks to UCS-M via its XML RPC.
*   Make the scheduler aware of virtual function availability for scheduling VMs that use the integration. (This could be retrieved from the hosts' Vdsm or maybe from UCS-M as part of the vnic-conn-policy, specifically its dynamic eth attribute. The former has the benefit of helping non-UCS sriov setups.).

### Level VI: "The return of the Port Profile"

This level of integration would make it possible for the oVirt Engine to go from simply retrieving Port Profiles to exporting oVirt networks to UCS-M as Port Profiles.

*   Define a good matching abstraction between oVirt's QoS and UCS's.
*   Extend the network provider for creating profiles in UCS-M.

### Level VII: "Working title: The rise of the Host"

It is left for future planning, but the basic idea would be to be able to use the networks of the UCS Network provider from level V and apply them to host virtual functions from the oVirt API/GUI.

<Category:Feature> <Category:Networking>


text:
package com.odobo.vertx3.serviceproxy.handler;

/**
 * User: plenderyou
 * Date: 19/10/15
 * Time: 09:08
 *
 * Standard response interface
 *
 */
public interface ServiceHandler<T> extends FailHandler {
    void ok(final T value);
}


text:
#include "query_optimizer/logical/Aggregate.hpp"

#include <string>
#include <vector>

#include "query_optimizer/OptimizerTree.hpp"
#include "query_optimizer/expressions/AttributeReference.hpp"
#include "query_optimizer/expressions/ExpressionUtil.hpp"
#include "query_optimizer/expressions/NamedExpression.hpp"
#include "query_optimizer/expressions/PatternMatcher.hpp"
#include "utility/Cast.hpp"

#include "glog/logging.h"

namespace quickstep {
namespace optimizer {
namespace logical {

namespace E = ::quickstep::optimizer::expressions;

LogicalPtr Aggregate::copyWithNewChildren(
    const std::vector<LogicalPtr> &new_children) const {
  DCHECK_EQ(getNumChildren(), new_children.size());
  return Create(new_children[0], grouping_expressions_, aggregate_expressions_);
}

std::vector<E::AttributeReferencePtr> Aggregate::getOutputAttributes() const {
  std::vector<E::AttributeReferencePtr> output_attributes(
      E::ToRefVector(grouping_expressions_));
  const std::vector<E::AttributeReferencePtr> aggregate_output_attributes =
      E::ToRefVector(aggregate_expressions_);
  output_attributes.insert(output_attributes.end(),
                           aggregate_output_attributes.begin(),
                           aggregate_output_attributes.end());
  return output_attributes;
}

std::vector<E::AttributeReferencePtr> Aggregate::getReferencedAttributes() const {
  std::vector<E::AttributeReferencePtr> referenced_attributes;
  for (const E::NamedExpressionPtr &grouping_expression :
       grouping_expressions_) {
    const std::vector<E::AttributeReferencePtr> referenced_attributes_in_expression =
        grouping_expression->getReferencedAttributes();
    referenced_attributes.insert(referenced_attributes.end(),
                                 referenced_attributes_in_expression.begin(),
                                 referenced_attributes_in_expression.end());
  }
  for (const E::AliasPtr &aggregate_expression :
       aggregate_expressions_) {
    const std::vector<E::AttributeReferencePtr> referenced_attributes_in_expression =
        aggregate_expression->getReferencedAttributes();
    referenced_attributes.insert(referenced_attributes.end(),
                                 referenced_attributes_in_expression.begin(),
                                 referenced_attributes_in_expression.end());
  }
  return referenced_attributes;
}

LogicalPtr Aggregate::copyWithNewInputExpressions(
    const std::vector<E::ExpressionPtr> &input_expressions) const {
  DCHECK_EQ(grouping_expressions_.size() + aggregate_expressions_.size(),
            input_expressions.size());

  std::vector<E::NamedExpressionPtr> new_grouping_expressions;
  for (std::vector<E::ExpressionPtr>::size_type index = 0;
       index < grouping_expressions_.size();
       ++index) {
    E::NamedExpressionPtr grouping_expression;
    E::SomeNamedExpression::MatchesWithConditionalCast(input_expressions[index],
                                                       &grouping_expression);
    DCHECK(grouping_expression != nullptr);
    new_grouping_expressions.emplace_back(grouping_expression);
  }

  std::vector<E::AliasPtr> new_aggregate_expressions;
  for (std::vector<E::ExpressionPtr>::size_type index = grouping_expressions_.size();
       index < input_expressions.size();
       ++index) {
    E::AliasPtr aggregate_expression;
    E::SomeAlias::MatchesWithConditionalCast(input_expressions[index], &aggregate_expression);
    DCHECK(aggregate_expression != nullptr);
    new_aggregate_expressions.emplace_back(aggregate_expression);
  }

  return Create(input_, new_grouping_expressions, new_aggregate_expressions);
}

void Aggregate::getFieldStringItems(
    std::vector<std::string> *inline_field_names,
    std::vector<std::string> *inline_field_values,
    std::vector<std::string> *non_container_child_field_names,
    std::vector<OptimizerTreeBaseNodePtr> *non_container_child_fields,
    std::vector<std::string> *container_child_field_names,
    std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const {
  non_container_child_field_names->push_back("input");
  non_container_child_fields->push_back(input_);

  container_child_field_names->push_back("grouping_expressions");
  container_child_fields->push_back(
      CastSharedPtrVector<OptimizerTreeBase>(grouping_expressions_));
  container_child_field_names->push_back("aggregate_expressions");
  container_child_fields->push_back(
      CastSharedPtrVector<OptimizerTreeBase>(aggregate_expressions_));
}

}  // namespace logical
}  // namespace optimizer
}  // namespace quickstep


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <title>MartSearch</title>

    <link rel="stylesheet" href="css/martsearch.css" type="text/css" media="screen" charset="utf-8" />

    <link type="text/css" rel="Stylesheet" href="js/utils/blackbirdjs/blackbird.css" />

MartSearch alpha

            WARNING: It appears that you do not have javascript
            enabled in your browser.  Unfortunately this portal will not function
            without javascript enabled.  Please
            enable
            javascript in your browser and refresh the page.

Search

Browse

Configure

Help

About

            <form id="mart_search" action="search" method="get" accept-charset="utf-8">
              <input type="text" name="query" value="" id="query" size="50" />
              <input type="submit" value="Search" />

              Enter gene symbols, gene or product identifiers or any other search term described in the help section.
            </form>

Browse our data by...

          Powered by MartSearch


text:
require 'digest'
class String # :nodoc:

  def hexdigest # :nodoc:
    Digest::SHA1.hexdigest(self)
  end

end


text:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;

namespace Microsoft.CodeAnalysis.CSharp.Completion.KeywordRecommenders
{
    internal class EndRegionKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
    {
        public EndRegionKeywordRecommender()
            : base(SyntaxKind.EndRegionKeyword, isValidInPreprocessorContext: true, shouldFormatOnCommit: true)
        {
        }

        protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
        {
            return context.IsPreProcessorKeywordContext;
        }
    }
}


text:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.main;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;

/**
 *
 * @author Ryan
 */
@Path("lists")
public class ListResource {

    public ListResource() {
        System.out.println("LIST RESOURCE CREATED!");
    }

    @GET
    public Response index() {
        return Response.ok("Howdy!").build();
    }
}


text:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package facebook.classes;

import java.util.Date;

/**
 *
 * @author Fellipe Rey
 */
public class Comments {

    private String name;
    private String id;
    private Date postDate;
    private String message;

    public Comments(String name, String id, Date postDate, String message){
        this.name = name;
        this.id = id;
        this.postDate = postDate;
        this.message = message;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Date getPostDate() {
        return postDate;
    }

    public void setPostDate(Date postDate) {
        this.postDate = postDate;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

}


text:
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

	<item android:drawable="@drawable/appwidget_dark_bg_pressed" android:state_pressed="true"/>
	<item android:drawable="@drawable/appwidget_dark_bg_focused" android:state_enabled="true" android:state_focused="true" android:state_window_focused="true"/>
	<item android:drawable="@drawable/appwidget_dark_bg"/>

</selector>


text:
package org.apache.pig.builtin;

import java.io.IOException;
import java.util.List;
import java.util.ArrayList;

import org.apache.pig.impl.logicalLayer.FrontendException;
import org.apache.pig.FuncSpec;
import org.apache.pig.data.Tuple;
import org.apache.pig.impl.logicalLayer.schema.Schema;
import org.apache.pig.data.DataType;

/**
* base class for math udfs that return Double value
*/
public abstract class DoubleBase extends Base{
    // each derived class provides the computation here
    abstract Double compute(Double input);

    /**
     * java level API
     * @param input expects a tuple with a single Double value
     * @return output returns a Double value
     */
    public Double exec(Tuple input) throws IOException {
        if (input == null || input.size() == 0)
            return null;

        try {
            Double val = (Double)input.get(0);
            return (val == null ? null : compute(val));
        } catch (Exception e){
            throw new IOException("Caught exception processing input of " + this.getClass().getName(), e);
        }
    }

    /* (non-Javadoc)
     * @see org.apache.pig.EvalFunc#getArgToFuncMapping()
     */
    @Override
    public List<FuncSpec> getArgToFuncMapping() throws FrontendException {
        List<FuncSpec> funcList = new ArrayList<FuncSpec>();
        funcList.add(new FuncSpec(this.getClass().getName(), new Schema(new Schema.FieldSchema(null, DataType.DOUBLE))));

        return funcList;
    }

}


text:
{% include slides/slideStart.html classes=include.classes id=include.id lightbackground=include.lightbackground header=include.header %}

              {% if include.header %}

                {% if include.superheader %}
{{ include.superheader }}
{% endif %}
                {{ include.header }}
                {% if include.subheader %}
{{ include.subheader }}
{% endif %}

              {% endif %}

              {% if include.details %}

{{ include.details }}

              {% endif %}
              {% if include.buttonText and include.buttonUrl %}
              {{ include.buttonText }}
              {% endif %}

{% include slides/slideEnd.html background=include.background backgroundTop=include.backgroundTop %}


text:
FROM tedross/demo-base
MAINTAINER Ted Ross <tross@apache.org>
ADD physician_app.py /physician_app.py
CMD python /physician_app.py


text:
// Copyright (C) 2009-2012 Lorenzo Caminiti
// Distributed under the Boost Software License, Version 1.0
// (see accompanying file LICENSE_1_0.txt or a copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Home at http://www.boost.org/libs/local_function

#include "addable.hpp"
#include <boost/local_function.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/concept_check.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <algorithm>

int main(void) {
    int sum = 0, factor = 10;

    void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum) (int num) ) {
        BOOST_CONCEPT_ASSERT((Addable<boost::remove_reference<
                BOOST_LOCAL_FUNCTION_TYPEOF(sum)>::type>));
        boost::remove_reference<BOOST_LOCAL_FUNCTION_TYPEOF(
                factor)>::type mult = factor * num;
        sum += mult;
    } BOOST_LOCAL_FUNCTION_NAME(add)

    add(6);
    BOOST_TEST(sum == 60);
    return boost::report_errors();
}


text:
from math import log, ceil
high = int(input("From 1 to wich number do you want the game to be? "))
print("Maximun number of guesses needed is '" + str(ceil(log(high, 2))) + "'")
low = 1
num = (high + low) // 2
tries = 0
while low != num or high != num:
	tries += 1
	answer = str(input("Is you number higher than '" + str(num) + "' [y/n] "))
	if answer == "y":
		low = num + 1
	elif answer == "n":
		high = num
	else:
		print("That is not a valid answer.")
	num = (high + low) // 2
print("Number of guesses '" + str(tries) + "'. Your number is '" + str(num) + "'.")


text:
DEFINE_NS_CORE

namespace Details
{
	template<class T>
	struct WeakReferenceContext
	{
		std::atomic<T*> ptr;

		WeakReferenceContext(T* ptr)
			:ptr(ptr)
		{

		}
	};
}

template<class T>
class WeakRef
{
public:
	WeakRef(const std::shared_ptr<Details::WeakReferenceContext<T>>& weakContext)
		:weakContext(weakContext)
	{

	}

	template<class TTarget = T>
	WRL::ComPtr<TTarget> Resolve() const noexcept
	{
		try
		{
			if (auto context = weakContext.lock())
				return static_cast<TTarget*>(context->ptr.load(std::memory_order_consume));
		}
		catch (...) {}
		return nullptr;
	}
private:
	std::weak_ptr<Details::WeakReferenceContext<T>> weakContext;
};

template<class T, class ...TArgs>
class WeakReferenceBase : public WRL::RuntimeClass<TArgs...>
{
public:
	WeakReferenceBase()
		:weakContext(std::make_shared<Details::WeakReferenceContext<T>>(static_cast<T*>(this)))
	{

	}

	STDMETHOD_(ULONG, AddRef)()
	{
		return InternalAddRef();
	}

	STDMETHODIMP_(ULONG) Release(void) override
	{
		ULONG ref = InternalRelease();
		if (ref == 0)
		{
			auto context = weakContext;
			if (context)
			{
				context->ptr.store(nullptr, std::memory_order_release);
				weakContext.reset();
			}
			if (GetRefCount() == 0)
			{
				delete this;

				auto module = ::Microsoft::WRL::GetModuleBase();
				if (module != nullptr)
				{
					module->DecrementObjectCount();
				}
			}
		}

		return ref;
	}

	WeakRef<T> AsWeak() const
	{
		return{ weakContext };
	}

	const std::shared_ptr<Details::WeakReferenceContext<T>>& GetWeakContext() const
	{
		return weakContext;
	}
protected:
	std::shared_ptr<Details::WeakReferenceContext<T>> weakContext;
};

END_NS_CORE


text:
Contributors
============

A total of 7 people contributed to this release.  People with a "+" by their
names contributed a patch for the first time.

* Aaron Meurer
* Bas van Beek
* Charles Harris
* Developer-Ecosystem-Engineering +
* Kevin Sheppard
* Sebastian Berg
* Warren Weckesser

Pull requests merged
====================

A total of 8 pull requests were merged for this release.

* `#19745 <https://github.com/numpy/numpy/pull/19745>`__: ENH: Add dtype-support to 3 `generic`/`ndarray` methods
* `#19955 <https://github.com/numpy/numpy/pull/19955>`__: BUG: Resolve Divide by Zero on Apple silicon + test failures...
* `#19958 <https://github.com/numpy/numpy/pull/19958>`__: MAINT: Mark type-check-only ufunc subclasses as ufunc aliases...
* `#19994 <https://github.com/numpy/numpy/pull/19994>`__: BUG: np.tan(np.inf) test failure
* `#20080 <https://github.com/numpy/numpy/pull/20080>`__: BUG: Correct incorrect advance in PCG with emulated int128
* `#20081 <https://github.com/numpy/numpy/pull/20081>`__: BUG: Fix NaT handling in the PyArray_CompareFunc for datetime...
* `#20082 <https://github.com/numpy/numpy/pull/20082>`__: DOC: Ensure that we add documentation also as to the dict for...
* `#20106 <https://github.com/numpy/numpy/pull/20106>`__: BUG: core: result_type(0, np.timedelta64(4)) would seg. fault.


text:
"""Helper module to run shell commands."""

import subprocess
import sys

from hwfutils.string_color import color_str_red as red
from hwfutils.string_color import color_str_yellow as yellow

# Run command as subprocess catching non-zero exit codes
def run_cmd(cmd, error_str, silent=False, fail_silent=False):
  """Runs the provided command (list of strings) in a separate process."""
  try:
    if not silent:
      print("Running command:")
      print(yellow(subprocess.list2cmdline(cmd)))
      subprocess.check_call(cmd)
    else:
      subprocess.check_call(cmd, stdout=subprocess.DEVNULL)
  except subprocess.CalledProcessError:
    if not fail_silent:
      print(red(error_str), file=sys.stderr)
      sys.exit(1)


text:
package ru.stqa.pft.mantis.tests;

import biz.futureware.mantis.rpc.soap.client.MantisConnectPortType;
import org.openqa.selenium.remote.BrowserType;
import org.testng.SkipException;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import ru.stqa.pft.mantis.appmanager.ApplicationManager;

import javax.xml.rpc.ServiceException;
import java.io.File;
import java.io.IOException;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.rmi.RemoteException;

/**
 * Created by Bond on 20.05.2017.
 */
public class TestBase {

  protected static ApplicationManager app;

  static {
    try {
      app = new ApplicationManager(System.getProperty("browser", BrowserType.CHROME));
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

  @BeforeSuite
  public void setUp() throws Exception {
    app.init();
    app.ftp().upload(new File("src/test/resources/config_inc.php"), "config_inc.php", "config_inc.php.bak");
  }

  public boolean isIssueOpened(int issueId) throws RemoteException, ServiceException, MalformedURLException {
    //String status =  mc.mc_project_get_categories("administrator", "root", BigInteger.valueOf(issue.getProject().getId()));
    String status = app.soap().issueStatus(issueId);
    if (!status.equals("closed")) {
      return true;
    }
    return false;
  }

  public void skipIfNotFixed(int issueId) throws RemoteException, ServiceException, MalformedURLException {
    if (isIssueOpened(issueId)) {
      throw new SkipException("Ignored because of issue " + issueId + "was not fixed");
    }
  }

  @AfterSuite(alwaysRun = true)
  public void tearDown() throws IOException {
    app.ftp().restore("config_inc.php.bak", "config_inc.php");
    app.stop();
  }

}


text:
require 'spec_helper'

describe ExamsController do

  describe "routing" do
    it "recognizes and generates #index" do
      { :get => "/exam_groups/1/exams" }.should \
        route_to(:controller => "exams", :action => "index", :exam_group_id => "1")
    end

    it "recognizes and generates #new" do
      { :get => "/exam_groups/1/exams/new" }.should \
        route_to(:controller => "exams", :action => "new", :exam_group_id => "1")
    end

    it "recognizes and generates #show" do
      { :get => "/exam_groups/1/exams/1" }.should \
        route_to(:controller => "exams", :action => "show", :id => "1", :exam_group_id => "1")
    end

    it "recognizes and generates #edit" do
      { :get => "/exam_groups/1/exams/1/edit" }.should \
        route_to(:controller => "exams", :action => "edit", :id => "1", :exam_group_id => "1")
    end

    it "recognizes and generates #create" do
      { :post => "/exam_groups/1/exams" }.should \
        route_to(:controller => "exams", :action => "create", :exam_group_id => "1")
    end

    it "recognizes and generates #update" do
      { :put => "/exam_groups/1/exams/1" }.should \
        route_to(:controller => "exams", :action => "update", :id => "1", :exam_group_id => "1")
    end

    it "recognizes and generates #destroy" do
      { :delete => "/exam_groups/1/exams/1" }.should \
        route_to(:controller => "exams", :action => "destroy", :id => "1", :exam_group_id => "1")
    end
  end
end


text:
<?xml version="1.0" encoding="UTF-8"?>
<MetaDataObject xmlns="http://v8.1c.ru/8.3/MDClasses" xmlns:app="http://v8.1c.ru/8.2/managed-application/core" xmlns:cfg="http://v8.1c.ru/8.1/data/enterprise/current-config" xmlns:cmi="http://v8.1c.ru/8.2/managed-application/cmi" xmlns:ent="http://v8.1c.ru/8.1/data/enterprise" xmlns:lf="http://v8.1c.ru/8.2/managed-application/logform" xmlns:style="http://v8.1c.ru/8.1/data/ui/style" xmlns:sys="http://v8.1c.ru/8.1/data/ui/fonts/system" xmlns:v8="http://v8.1c.ru/8.1/data/core" xmlns:v8ui="http://v8.1c.ru/8.1/data/ui" xmlns:web="http://v8.1c.ru/8.1/data/ui/colors/web" xmlns:win="http://v8.1c.ru/8.1/data/ui/colors/windows" xmlns:xen="http://v8.1c.ru/8.3/xcf/enums" xmlns:xpr="http://v8.1c.ru/8.3/xcf/predef" xmlns:xr="http://v8.1c.ru/8.3/xcf/readable" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1">
	<Catalog uuid="e6ae5164-fe3b-48fd-8180-f31941e35238">
		<InternalInfo>
			<xr:GeneratedType name="CatalogObject.ТипыИнформацииИнформационногоЦентра" category="Object">
				<xr:TypeId>625b39bf-394f-4756-b9d6-613fe602dfea</xr:TypeId>
				<xr:ValueId>9af54af6-fd9d-49c4-b5b0-bddfe2ebf59f</xr:ValueId>
			</xr:GeneratedType>
			<xr:GeneratedType name="CatalogRef.ТипыИнформацииИнформационногоЦентра" category="Ref">
				<xr:TypeId>6aafa7fe-248c-4747-b4c1-0e629ca6019b</xr:TypeId>
				<xr:ValueId>b90f1bb3-bfab-4f6c-97fa-e3604bb32b00</xr:ValueId>
			</xr:GeneratedType>
			<xr:GeneratedType name="CatalogSelection.ТипыИнформацииИнформационногоЦентра" category="Selection">
				<xr:TypeId>a6682870-43a1-489f-8207-32dec765d977</xr:TypeId>
				<xr:ValueId>419ef82e-66c1-4af0-a0bc-062b481c9183</xr:ValueId>
			</xr:GeneratedType>
			<xr:GeneratedType name="CatalogList.ТипыИнформацииИнформационногоЦентра" category="List">
				<xr:TypeId>b9058f8b-8846-42df-9f0b-1326eba01b29</xr:TypeId>
				<xr:ValueId>3fe76d86-3f71-474f-8ed3-4e9b61644cf4</xr:ValueId>
			</xr:GeneratedType>
			<xr:GeneratedType name="CatalogManager.ТипыИнформацииИнформационногоЦентра" category="Manager">
				<xr:TypeId>34f9ff2c-07f6-45e3-a653-15820bbc24f4</xr:TypeId>
				<xr:ValueId>b7b4cdde-1b2a-4179-8524-08769bee3ce5</xr:ValueId>
			</xr:GeneratedType>
		</InternalInfo>
		<Properties>
			<Name>ТипыИнформацииИнформационногоЦентра</Name>
			<Synonym>
				<v8:item>
					<v8:lang>ru</v8:lang>
					<v8:content>Типы информации информационного центра</v8:content>
				</v8:item>
			</Synonym>
			<Comment/>
			<Hierarchical>false</Hierarchical>
			<HierarchyType>HierarchyFoldersAndItems</HierarchyType>
			<LimitLevelCount>false</LimitLevelCount>
			<LevelCount>2</LevelCount>
			<FoldersOnTop>true</FoldersOnTop>
			<UseStandardCommands>true</UseStandardCommands>
			<Owners/>
			<SubordinationUse>ToItems</SubordinationUse>
			<CodeLength>9</CodeLength>
			<DescriptionLength>50</DescriptionLength>
			<CodeType>String</CodeType>
			<CodeAllowedLength>Variable</CodeAllowedLength>
			<CodeSeries>WholeCatalog</CodeSeries>
			<CheckUnique>true</CheckUnique>
			<Autonumbering>true</Autonumbering>
			<DefaultPresentation>AsDescription</DefaultPresentation>
			<StandardAttributes>
				<xr:StandardAttribute name="PredefinedDataName">
					<xr:LinkByType/>
					<xr:FillChecking>DontCheck</xr:FillChecking>
					<xr:MultiLine>false</xr:MultiLine>
					<xr:FillFromFillingValue>false</xr:FillFromFillingValue>
					<xr:CreateOnInput>Auto</xr:CreateOnInput>
					<xr:MaxValue xsi:nil="true"/>
					<xr:ToolTip/>
					<xr:ExtendedEdit>false</xr:ExtendedEdit>
					<xr:Format/>
					<xr:ChoiceForm/>
					<xr:QuickChoice>Auto</xr:QuickChoice>
					<xr:ChoiceHistoryOnInput>Auto</xr:ChoiceHistoryOnInput>
					<xr:EditFormat/>
					<xr:PasswordMode>false</xr:PasswordMode>
					<xr:MarkNegatives>false</xr:MarkNegatives>
					<xr:MinValue xsi:nil="true"/>
					<xr:Synonym/>
					<xr:Comment/>
					<xr:FullTextSearch>Use</xr:FullTextSearch>
					<xr:ChoiceParameterLinks/>
					<xr:FillValue xsi:nil="true"/>
					<xr:Mask/>
					<xr:ChoiceParameters/>
				</xr:StandardAttribute>
				<xr:StandardAttribute name="Predefined">
					<xr:LinkByType/>
					<xr:FillChecking>DontCheck</xr:FillChecking>
					<xr:MultiLine>false</xr:MultiLine>
					<xr:FillFromFillingValue>false</xr:FillFromFillingValue>
					<xr:CreateOnInput>Auto</xr:CreateOnInput>
					<xr:MaxValue xsi:nil="true"/>
					<xr:ToolTip/>
					<xr:ExtendedEdit>false</xr:ExtendedEdit>
					<xr:Format/>
					<xr:ChoiceForm/>
					<xr:QuickChoice>Auto</xr:QuickChoice>
					<xr:ChoiceHistoryOnInput>Auto</xr:ChoiceHistoryOnInput>
					<xr:EditFormat/>
					<xr:PasswordMode>false</xr:PasswordMode>
					<xr:MarkNegatives>false</xr:MarkNegatives>
					<xr:MinValue xsi:nil="true"/>
					<xr:Synonym/>
					<xr:Comment/>
					<xr:FullTextSearch>Use</xr:FullTextSearch>
					<xr:ChoiceParameterLinks/>
					<xr:FillValue xsi:nil="true"/>
					<xr:Mask/>
					<xr:ChoiceParameters/>
				</xr:StandardAttribute>
				<xr:StandardAttribute name="Ref">
					<xr:LinkByType/>
					<xr:FillChecking>DontCheck</xr:FillChecking>
					<xr:MultiLine>false</xr:MultiLine>
					<xr:FillFromFillingValue>false</xr:FillFromFillingValue>
					<xr:CreateOnInput>Auto</xr:CreateOnInput>
					<xr:MaxValue xsi:nil="true"/>
					<xr:ToolTip/>
					<xr:ExtendedEdit>false</xr:ExtendedEdit>
					<xr:Format/>
					<xr:ChoiceForm/>
					<xr:QuickChoice>Auto</xr:QuickChoice>
					<xr:ChoiceHistoryOnInput>Auto</xr:ChoiceHistoryOnInput>
					<xr:EditFormat/>
					<xr:PasswordMode>false</xr:PasswordMode>
					<xr:MarkNegatives>false</xr:MarkNegatives>
					<xr:MinValue xsi:nil="true"/>
					<xr:Synonym/>
					<xr:Comment/>
					<xr:FullTextSearch>Use</xr:FullTextSearch>
					<xr:ChoiceParameterLinks/>
					<xr:FillValue xsi:nil="true"/>
					<xr:Mask/>
					<xr:ChoiceParameters/>
				</xr:StandardAttribute>
				<xr:StandardAttribute name="DeletionMark">
					<xr:LinkByType/>
					<xr:FillChecking>DontCheck</xr:FillChecking>
					<xr:MultiLine>false</xr:MultiLine>
					<xr:FillFromFillingValue>false</xr:FillFromFillingValue>
					<xr:CreateOnInput>Auto</xr:CreateOnInput>
					<xr:MaxValue xsi:nil="true"/>
					<xr:ToolTip/>
					<xr:ExtendedEdit>false</xr:ExtendedEdit>
					<xr:Format/>
					<xr:ChoiceForm/>
					<xr:QuickChoice>Auto</xr:QuickChoice>
					<xr:ChoiceHistoryOnInput>Auto</xr:ChoiceHistoryOnInput>
					<xr:EditFormat/>
					<xr:PasswordMode>false</xr:PasswordMode>
					<xr:MarkNegatives>false</xr:MarkNegatives>
					<xr:MinValue xsi:nil="true"/>
					<xr:Synonym/>
					<xr:Comment/>
					<xr:FullTextSearch>Use</xr:FullTextSearch>
					<xr:ChoiceParameterLinks/>
					<xr:FillValue xsi:nil="true"/>
					<xr:Mask/>
					<xr:ChoiceParameters/>
				</xr:StandardAttribute>
				<xr:StandardAttribute name="IsFolder">
					<xr:LinkByType/>
					<xr:FillChecking>DontCheck</xr:FillChecking>
					<xr:MultiLine>false</xr:MultiLine>
					<xr:FillFromFillingValue>false</xr:FillFromFillingValue>
					<xr:CreateOnInput>Auto</xr:CreateOnInput>
					<xr:MaxValue xsi:nil="true"/>
					<xr:ToolTip/>
					<xr:ExtendedEdit>false</xr:ExtendedEdit>
					<xr:Format/>
					<xr:ChoiceForm/>
					<xr:QuickChoice>Auto</xr:QuickChoice>
					<xr:ChoiceHistoryOnInput>Auto</xr:ChoiceHistoryOnInput>
					<xr:EditFormat/>
					<xr:PasswordMode>false</xr:PasswordMode>
					<xr:MarkNegatives>false</xr:MarkNegatives>
					<xr:MinValue xsi:nil="true"/>
					<xr:Synonym/>
					<xr:Comment/>
					<xr:FullTextSearch>Use</xr:FullTextSearch>
					<xr:ChoiceParameterLinks/>
					<xr:FillValue xsi:nil="true"/>
					<xr:Mask/>
					<xr:ChoiceParameters/>
				</xr:StandardAttribute>
				<xr:StandardAttribute name="Owner">
					<xr:LinkByType/>
					<xr:FillChecking>ShowError</xr:FillChecking>
					<xr:MultiLine>false</xr:MultiLine>
					<xr:FillFromFillingValue>true</xr:FillFromFillingValue>
					<xr:CreateOnInput>Auto</xr:CreateOnInput>
					<xr:MaxValue xsi:nil="true"/>
					<xr:ToolTip/>
					<xr:ExtendedEdit>false</xr:ExtendedEdit>
					<xr:Format/>
					<xr:ChoiceForm/>
					<xr:QuickChoice>Auto</xr:QuickChoice>
					<xr:ChoiceHistoryOnInput>Auto</xr:ChoiceHistoryOnInput>
					<xr:EditFormat/>
					<xr:PasswordMode>false</xr:PasswordMode>
					<xr:MarkNegatives>false</xr:MarkNegatives>
					<xr:MinValue xsi:nil="true"/>
					<xr:Synonym/>
					<xr:Comment/>
					<xr:FullTextSearch>Use</xr:FullTextSearch>
					<xr:ChoiceParameterLinks/>
					<xr:FillValue xsi:nil="true"/>
					<xr:Mask/>
					<xr:ChoiceParameters/>
				</xr:StandardAttribute>
				<xr:StandardAttribute name="Parent">
					<xr:LinkByType/>
					<xr:FillChecking>DontCheck</xr:FillChecking>
					<xr:MultiLine>false</xr:MultiLine>
					<xr:FillFromFillingValue>true</xr:FillFromFillingValue>
					<xr:CreateOnInput>Auto</xr:CreateOnInput>
					<xr:MaxValue xsi:nil="true"/>
					<xr:ToolTip/>
					<xr:ExtendedEdit>false</xr:ExtendedEdit>
					<xr:Format/>
					<xr:ChoiceForm/>
					<xr:QuickChoice>Auto</xr:QuickChoice>
					<xr:ChoiceHistoryOnInput>Auto</xr:ChoiceHistoryOnInput>
					<xr:EditFormat/>
					<xr:PasswordMode>false</xr:PasswordMode>
					<xr:MarkNegatives>false</xr:MarkNegatives>
					<xr:MinValue xsi:nil="true"/>
					<xr:Synonym/>
					<xr:Comment/>
					<xr:FullTextSearch>Use</xr:FullTextSearch>
					<xr:ChoiceParameterLinks/>
					<xr:FillValue xsi:nil="true"/>
					<xr:Mask/>
					<xr:ChoiceParameters/>
				</xr:StandardAttribute>
				<xr:StandardAttribute name="Description">
					<xr:LinkByType/>
					<xr:FillChecking>ShowError</xr:FillChecking>
					<xr:MultiLine>false</xr:MultiLine>
					<xr:FillFromFillingValue>false</xr:FillFromFillingValue>
					<xr:CreateOnInput>Auto</xr:CreateOnInput>
					<xr:MaxValue xsi:nil="true"/>
					<xr:ToolTip>
						<v8:item>
							<v8:lang>ru</v8:lang>
							<v8:content>Наименование</v8:content>
						</v8:item>
					</xr:ToolTip>
					<xr:ExtendedEdit>false</xr:ExtendedEdit>
					<xr:Format/>
					<xr:ChoiceForm/>
					<xr:QuickChoice>Auto</xr:QuickChoice>
					<xr:ChoiceHistoryOnInput>Auto</xr:ChoiceHistoryOnInput>
					<xr:EditFormat/>
					<xr:PasswordMode>false</xr:PasswordMode>
					<xr:MarkNegatives>false</xr:MarkNegatives>
					<xr:MinValue xsi:nil="true"/>
					<xr:Synonym/>
					<xr:Comment/>
					<xr:FullTextSearch>Use</xr:FullTextSearch>
					<xr:ChoiceParameterLinks/>
					<xr:FillValue xsi:nil="true"/>
					<xr:Mask/>
					<xr:ChoiceParameters/>
				</xr:StandardAttribute>
				<xr:StandardAttribute name="Code">
					<xr:LinkByType/>
					<xr:FillChecking>DontCheck</xr:FillChecking>
					<xr:MultiLine>false</xr:MultiLine>
					<xr:FillFromFillingValue>false</xr:FillFromFillingValue>
					<xr:CreateOnInput>Auto</xr:CreateOnInput>
					<xr:MaxValue xsi:nil="true"/>
					<xr:ToolTip>
						<v8:item>
							<v8:lang>ru</v8:lang>
							<v8:content>Код</v8:content>
						</v8:item>
					</xr:ToolTip>
					<xr:ExtendedEdit>false</xr:ExtendedEdit>
					<xr:Format/>
					<xr:ChoiceForm/>
					<xr:QuickChoice>Auto</xr:QuickChoice>
					<xr:ChoiceHistoryOnInput>Auto</xr:ChoiceHistoryOnInput>
					<xr:EditFormat/>
					<xr:PasswordMode>false</xr:PasswordMode>
					<xr:MarkNegatives>false</xr:MarkNegatives>
					<xr:MinValue xsi:nil="true"/>
					<xr:Synonym/>
					<xr:Comment/>
					<xr:FullTextSearch>Use</xr:FullTextSearch>
					<xr:ChoiceParameterLinks/>
					<xr:FillValue xsi:nil="true"/>
					<xr:Mask/>
					<xr:ChoiceParameters/>
				</xr:StandardAttribute>
			</StandardAttributes>
			<Characteristics/>
			<PredefinedDataUpdate>Auto</PredefinedDataUpdate>
			<EditType>InDialog</EditType>
			<QuickChoice>false</QuickChoice>
			<ChoiceMode>BothWays</ChoiceMode>
			<InputByString>
				<xr:Field>Catalog.ТипыИнформацииИнформационногоЦентра.StandardAttribute.Description</xr:Field>
				<xr:Field>Catalog.ТипыИнформацииИнформационногоЦентра.StandardAttribute.Code</xr:Field>
			</InputByString>
			<SearchStringModeOnInputByString>Begin</SearchStringModeOnInputByString>
			<FullTextSearchOnInputByString>DontUse</FullTextSearchOnInputByString>
			<ChoiceDataGetModeOnInputByString>Directly</ChoiceDataGetModeOnInputByString>
			<DefaultObjectForm/>
			<DefaultFolderForm/>
			<DefaultListForm/>
			<DefaultChoiceForm/>
			<DefaultFolderChoiceForm/>
			<AuxiliaryObjectForm/>
			<AuxiliaryFolderForm/>
			<AuxiliaryListForm/>
			<AuxiliaryChoiceForm/>
			<AuxiliaryFolderChoiceForm/>
			<IncludeHelpInContents>false</IncludeHelpInContents>
			<BasedOn/>
			<DataLockFields/>
			<DataLockControlMode>Managed</DataLockControlMode>
			<FullTextSearch>DontUse</FullTextSearch>
			<ObjectPresentation>
				<v8:item>
					<v8:lang>ru</v8:lang>
					<v8:content>Типы информации</v8:content>
				</v8:item>
			</ObjectPresentation>
			<ExtendedObjectPresentation/>
			<ListPresentation>
				<v8:item>
					<v8:lang>ru</v8:lang>
					<v8:content>Список типов информации</v8:content>
				</v8:item>
			</ListPresentation>
			<ExtendedListPresentation/>
			<Explanation/>
			<CreateOnInput>Use</CreateOnInput>
			<ChoiceHistoryOnInput>Auto</ChoiceHistoryOnInput>
		</Properties>
		<ChildObjects/>
	</Catalog>
</MetaDataObject>


text:
all: release
debug:
	xcodebuild -derivedDataPath $(PWD) -configuration Debug -scheme RsyncOSX
release:
	xcodebuild -derivedDataPath $(PWD) -configuration Release -scheme RsyncOSX
clean:
	rm -Rf Build
	rm -Rf ModuleCache.noindex
	rm -Rf info.plist
	rm -Rf Logs
	rm -rf SourcePackages


text:
class ChangeDealTittle < ActiveRecord::Migration
  def self.up
    change_column :products,:name,:string,:limit =>512
  end

  def self.down
    change_column :products,:name,:string
  end
end


text:
import { createStore, applyMiddleware } from 'redux'
import rootReducer from './reducers'
import promiseMiddleware from 'redux-promise';

const initialState = {};

export default function configureStore() { /*initialState) { */
    return createStore(
       rootReducer,
       initialState,
       applyMiddleware(
           promiseMiddleware
       )
   )
}


text:
package org.apache.commons.imaging.formats.png;

import java.io.UnsupportedEncodingException;

import org.apache.commons.imaging.common.BinaryFunctions;

/**
 * Type of a PNG chunk.
 *
 * @see Portable Network Graphics Specification - Chunk specifications
 */
public enum ChunkType {

    /** Image header */
    IHDR,

    /** Palette */
    PLTE,

    /** Image data */
    IDAT,

    /** Image trailer */
    IEND,

    /** Transparency */
    tRNS,

    /** Primary chromaticities and white point */
    cHRM,

    /** Image gamma */
    gAMA,

    /** Embedded ICC profile */
    iCCP,

    /** Significant bits*/
    sBIT,

    /** Standard RGB colour space */
    sRGB,

    /** Textual data */
    tEXt,

    /** Compressed textual data */
    zTXt,

    /** International textual data */
    iTXt,

    /** Background colour */
    bKGD,

    /** Image histogram */
    hIST,

    /** Physical pixel dimensions */
    pHYs,

    /** Suggested palette */
    sPLT,

    /** Image last-modification time */
    tIME;

    final byte[] array;
    final int value;

    private ChunkType() {
        char[] chars = name().toCharArray();
        try {
            array = name().getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            // will not happen since UTF-8 is one of the StandardCharsets of the Java platform
            throw new RuntimeException(e);
        }
        value = BinaryFunctions.charsToQuad(chars[0], chars[1], chars[2], chars[3]);
    }
}


text:
package com.thoughtworks.btu;

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class TeacherTest {
    @Test
    public void should_return_true_if_teacher_say_three_special_number_success() {
        Teacher teacher = new Teacher();
        teacher.say(3, 5, 7);
        assertThat(teacher.getFizzNumber()).isEqualTo(3);
        assertThat(teacher.getBuzzNumber()).isEqualTo(5);
        assertThat(teacher.getWhizzNumber()).isEqualTo(7);
    }
}


text:
#ifndef _ICONFIGURABLECOMMANDFACTORY_H_
#define _ICONFIGURABLECOMMANDFACTORY_H_

#include "ICommandFactory.h"
#include "ICommandCreator.h"

class IConfigurableCommandFactory: public ICommandFactory {
public:
    typedef Poco::SharedPtr<IConfigurableCommandFactory> Handle;

    virtual void addCreator(const std::string& aCmdName, ICommandCreator::SingleHandle aCreator) = 0;
    virtual ICommandCreator::SingleHandle removeCreator(const std::string& aCmdName) = 0;

    virtual ~IConfigurableCommandFactory(){}
protected:
    IConfigurableCommandFactory(){}
};

#endif


text:
using System;
using System.Globalization;
using System.Threading;
using NUnit.Framework;

namespace Ampla.LogReader
{
    [TestFixture]
    public class ThreadCultureUnitTests : TestFixture
    {
        [Test]
        public void SetUICulture()
        {
            CultureInfo inside;
            CultureInfo before = Thread.CurrentThread.CurrentUICulture;

            using (ThreadCulture.SetUICulture("fr-FR"))
            {
                inside = Thread.CurrentThread.CurrentUICulture;
            }

            CultureInfo after = Thread.CurrentThread.CurrentUICulture;

            Assert.That(inside.Name, Is.EqualTo("fr-FR"), "Not set");
            Assert.That(before.Name, Is.EqualTo(after.Name), "Not reset back");
        }

        [Test]
        public void SetUICultureLayered()
        {
            CultureInfo inside;
            CultureInfo inner;
            CultureInfo outside;
            CultureInfo before = Thread.CurrentThread.CurrentUICulture;

            using (ThreadCulture.SetUICulture("fr-FR"))
            {
                inside = Thread.CurrentThread.CurrentUICulture;
                using (ThreadCulture.SetUICulture("de-DE"))
                {
                    inner = Thread.CurrentThread.CurrentUICulture;
                }
                outside = Thread.CurrentThread.CurrentUICulture;
            }

            CultureInfo after = Thread.CurrentThread.CurrentUICulture;

            Assert.That(inside.Name, Is.EqualTo("fr-FR"), "Not set");
            Assert.That(inner.Name, Is.EqualTo("de-DE"), "Inner not set");
            Assert.That(inside.Name, Is.EqualTo(outside.Name), "Not reset back");
            Assert.That(before.Name, Is.EqualTo(after.Name), "Not reset back");
        }
    }
}


text:
<?php

namespace Networking\InitCmsBundle\Entity;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NoResultException;
use Networking\InitCmsBundle\Model\HelpTextManagerInterface;

/**
 * Class HelpTextManager.
 *
 * @author Yorkie Chadwick <y.chadwick@networking.ch>
 */
class HelpTextManager extends EntityRepository implements HelpTextManagerInterface
{
    public function __construct(EntityManagerInterface $om, $class)
    {
        $classMetaData = $om->getClassMetadata($class);

        parent::__construct($om, $classMetaData);
    }

    /**
     * @param $translationKey
     * @param $locale
     *
     * @return object
     */
    public function getHelpTextByKeyLocale($translationKey, $locale)
    {
        $qb = $this->createQueryBuilder('h');
        $qb->where('h.locale LIKE :locale')
            ->andWhere('h.translationKey LIKE :translationKey')
            ->orderBy('h.id', 'asc')
            ->setParameter(':locale', substr($locale, 0, 2).'%')
            ->setParameter(':translationKey', $translationKey.'%');

        try {
            $helpText = $qb->getQuery()->getSingleResult();
        } catch (NoResultException $e) {
            $qb = $this->createQueryBuilder('h');
            $qb->where('h.locale LIKE :locale')
                ->andWhere('h.translationKey = :translationKey')
                ->orderBy('h.id', 'asc')
                ->setParameter(':locale', substr($locale, 0, 2).'%')
                ->setParameter(':translationKey', 'not_found');
            $helpText = $qb->getQuery()->getSingleResult();
        }

        return $helpText;
    }

    /**
     * @param $translationKey
     * @param $locale
     *
     * @return array
     */
    public function searchHelpTextByKeyLocale($translationKey, $locale)
    {
        $qb = $this->createQueryBuilder('h');
        $qb->where('h.locale LIKE :locale')
            ->andWhere('h.translationKey LIKE :translationKey')
            ->orderBy('h.id', 'asc')
            ->setParameter(':locale', substr($locale, 0, 2).'%')
            ->setParameter(':translationKey', $translationKey.'%');

        return $qb->getQuery()->getResult();
    }
}