text:
/* Smartphones (portrait and landscape) ----------- */

@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {

    #header {
        width: 90%!important;
    }

    #header a {
        padding-top: 0!important;
    }

    #header .navbar-inner .container {
        margin-left: 0!important;
        width: 100%!important;
    }

    #header ul.nav {
        padding-top: 15px!important;
    }

    #home-page {
        width: 98%!important;
    }

    .navbar .btn-navbar {
        margin-top: 0!important;
        padding: 7px 15px!important;
    }
    .logoFix {
        display: inline!important;
        float: left;
    }

    #page-content .heading .social-icons {
        display: none!important;
    }

    .nav-collapse {
        -webkit-transform: translate3d(0, 0, 0);
    }
    .nav-collapse .nav .logo-item {
        display: none!important;
    }
    .page-header h1 small {
        display: block;
        line-height: 20px;
    }
    input[type="checkbox"],
    input[type="radio"] {
        border: 1px solid #ccc;
    }
    .form-horizontal .control-group > label {
        float: none;
        width: auto;
        padding-top: 0;
        text-align: left;
    }
    .form-horizontal .controls {
        margin-left: 0;
    }
    .form-horizontal .control-list {
        padding-top: 0;
    }
    .form-horizontal .form-actions {
        padding-right: 10px;
        padding-left: 10px;
    }
    .modal {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    .modal-header .close {
        padding: 10px;
        margin: -10px;
    }
    .carousel-caption {
        position: static;
    }

    #home-page {
        width: 98%!important;
    }

    #page-content .buttons-container a {
        width: 40%!important;
    }

    #page-content .top {
        width: 100%!important;
        height: 100%!important;
        box-shadow: none!important;
    }
    #page-content .top-container .news-area {
        width: 100%!important;
        float: none!important;
        clear: both;
    }
    #page-content .middle {
        width: 100%!important;
    }
    #page-content .bottom {
        width: 100%!important;
    }
    #page-content .top .intro {
        width: 100%!important;
    }
    #page-content .top .intro {
        width: 100%!important;
        margin: 0 0 10px 0 !important;
    }
    #page-content {
        padding-top: 0!important;
    }
    #page-content .top .intro .desc {
        width: 100%!important;
    }
    #page-content .top .intro .heading {
        font-size: 1.5em!important;
    }
    #page-content .top .intro .buttons {
        width: 100%!important;
    }
    #page-content .top .intro .buttons a {
        font-size: 0.9em!important;
    }
    #page-content .top:before, #page-content .top:after{
        box-shadow: none!important;
        content: none!important;
    }
    #page-content .top-container .news-area {
        height: auto!important;
        margin-left: 0!important;
    }
    #page-content .news-area .heading .social-icons {
        display: none!important;
    }
    #page-content .middle {
        min-height: 1100px;
    }
    #page-content .top .intro .buttons .main-button{
        margin-right: 0!important;
    }

    #page-content .middle .list li {
        float: none!important;
        padding-left: 25%!important;
    }

    /* About */
    .community-page {
        width: 100%!important;
    }
    .content-box .inner-content {
        width: 73%!important;
    }
    .community-page .left-side {
        font-size: 10px!important;
    }

    /* Downloads */
    #downloads-page .download-button-area {
        float: none!important;
        width: 100%!important;
        display: inline!important;
    }
    #downloads-page .download-description {
        width: 100%!important;
    }

}

/* Disable iOS/WinMobile font size changes */
@media screen and (min-width:481px) and (max-width: 700px){
    html {
        -ms-text-size-adjust:     none;
        -webkit-text-size-adjust: none;
    }

    #header {
        width: 90%!important;
    }

    #page-content .buttons-container a {
      width: 22% !important;
    }

    #header a {
        padding-top: 0!important;
    }

    #header .navbar-inner .container {
        margin-left: 0!important;
        width: 100%!important;
    }

    #header ul.nav {
        padding-top: 15px!important;
    }

    .navbar .btn-navbar {
        margin-top: 0!important;
        padding: 7px 15px!important;
    }
    .logoFix {
        display: inline!important;
        float: left;
    }

    .nav-collapse {
        -webkit-transform: translate3d(0, 0, 0);
    }
    .nav-collapse .nav .logo-item {
        display: none!important;
    }
    .page-header h1 small {
        display: block;
        line-height: 20px;
    }
    input[type="checkbox"],
    input[type="radio"] {
        border: 1px solid #ccc;
    }
    .form-horizontal .control-group > label {
        float: none;
        width: auto;
        padding-top: 0;
        text-align: left;
    }
    .form-horizontal .controls {
        margin-left: 0;
    }
    .form-horizontal .control-list {
        padding-top: 0;
    }
    .form-horizontal .form-actions {
        padding-right: 10px;
        padding-left: 10px;
    }
    .modal {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    .modal-header .close {
        padding: 10px;
        margin: -10px;
    }
    .carousel-caption {
        position: static;
    }

    #home-page {
        width: 98%!important;
    }
    #page-content .top {
        width: 100%!important;
        height: 100%!important;
        box-shadow: none!important;
    }
    #page-content .top-container .news-area {
        width: 100%!important;
        float: none!important;
        clear: both;
    }
    #page-content .middle {
        width: 100%!important;
    }
    #page-content .bottom {
        width: 100%!important;
    }
    #page-content .top .intro {
        width: 100%!important;
    }
    #page-content .top .intro {
        width: 100%!important;
        margin: 0 0 10px 0 !important;
    }
    #page-content {
        padding-top: 0!important;
    }
    #page-content .top .intro .desc {
        width: 100%!important;
    }
    #page-content .top .intro .heading {
        font-size: 1.5em!important;
    }
    #page-content .top .intro .buttons {
        width: 100%!important;
    }
    #page-content .top .intro .buttons a {
        font-size: 0.9em!important;
    }
    #page-content .top:before, #page-content .top:after{
        box-shadow: none!important;
        content: none!important;
    }
    #page-content .top-container .news-area {
        height: auto!important;
        margin-left: 0!important;
    }
    #page-content .news-area .heading .social-icons {
        display: none!important;
    }
    #page-content .middle {
        min-height: 750px;
    }
    #page-content .top .intro .buttons .main-button{
        margin-right: 0!important;
    }

    /* About */
    .community-page {
        width: 100%!important;
    }
    .content-box .inner-content {
        width: 75%!important;
    }
    .community-page .left-side {
        font-size: 12px!important;
    }
    /* Downloads */
    #downloads-page .download-button-area {
        float: none!important;
        display: inline!important;
    }
    #downloads-page .download-description {
        width: 100%!important;
    }

}

/* iPads (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 701px)
and (max-device-width : 979px) {
    #header {
        width: 90%!important;
    }

    #header a {
        padding-top: 0!important;
    }

    #header .navbar-inner .container {
        margin-left: 0!important;
        width: 100%!important;
    }

    #header ul.nav {
        padding-top: 15px!important;
    }

    .navbar .btn-navbar {
        margin-top: 0!important;
        padding: 7px 15px!important;
    }
    .logoFix {
        display: inline!important;
        float: left;
    }

    .nav-collapse {
        -webkit-transform: translate3d(0, 0, 0);
    }
    .nav-collapse .nav .logo-item {
        display: none!important;
    }
    .page-header h1 small {
        display: block;
        line-height: 20px;
    }
    input[type="checkbox"],
    input[type="radio"] {
        border: 1px solid #ccc;
    }
    .form-horizontal .control-group > label {
        float: none;
        width: auto;
        padding-top: 0;
        text-align: left;
    }
    .form-horizontal .controls {
        margin-left: 0;
    }
    .form-horizontal .control-list {
        padding-top: 0;
    }
    .form-horizontal .form-actions {
        padding-right: 10px;
        padding-left: 10px;
    }
    .modal {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    .modal-header .close {
        padding: 10px;
        margin: -10px;
    }
    .carousel-caption {
        position: static;
    }

    #home-page {
        width: 98%!important;
    }
    #page-content .top {
        width: 100%!important;
        height: 100%!important;
        box-shadow: none!important;
    }
    #page-content .top-container .news-area {
        width: 100%!important;
        float: none!important;
        clear: both;
    }
    #page-content .middle {
        width: 100%!important;
    }
    #page-content .bottom {
        width: 100%!important;
    }
    #page-content .top .intro {
        width: 100%!important;
    }
    #page-content .top .intro {
        width: 100%!important;
        margin: 0 0 10px 0 !important;
    }
    #page-content {
        padding-top: 0!important;
    }
    #page-content .top .intro .desc {
        width: 100%!important;
    }
    #page-content .top .intro .heading {
        font-size: 1.5em!important;
    }
    #page-content .top .intro .buttons {
        width: 100%!important;
    }
    #page-content .top .intro .buttons a {
        font-size: 0.9em!important;
    }
    #page-content .top:before, #page-content .top:after{
        box-shadow: none!important;
        content: none!important;
    }
    #page-content .top-container .news-area {
        height: auto!important;
        margin-left: 0!important;
    }
    #page-content .news-area .heading .social-icons {
        display: none!important;
    }
    #page-content .middle {
        min-height: 500px;
    }
    #page-content .top .intro .buttons .main-button{
        margin-right: 0!important;
    }
    #page-content .middle .list li {
        width: 30%!important;
        padding-left: 15%!important;
    }
    /* About */
    .community-page {
        width: 100%!important;
    }

}

@media (max-width: 979px) {
    body {
        padding-top: 0;
    }

    #header a {
        padding-top: 0!important;
    }

    .logoFix {
        display: inline!important;
        float: left;
    }

    #page-content {
      padding-top: 0;
    }

    .navbar-fixed-top,
    .navbar-fixed-bottom {
        position: static;
    }
    .navbar-fixed-top {
      margin-bottom: 12px;
    }
    .navbar-fixed-bottom {
        margin-top: 20px;
    }
    .navbar-fixed-top .navbar-inner,
    .navbar-fixed-bottom .navbar-inner {
        padding: 5px;
    }
    .navbar .brand {
        padding-right: 10px;
        padding-left: 10px;
        margin: 0 0 0 -5px;
    }
    .nav-collapse {
        clear: both;
    }
    .nav-collapse .nav {
        float: none;
        margin: 0 0 10px;
    }
    .nav-collapse .nav > li {
        float: none;
    }
    .nav-collapse .nav > li > a {
        margin-bottom: 2px;
    }
    .nav-collapse .nav > .divider-vertical {
        display: none;
    }
    .nav-collapse .nav .nav-header {
        color: #555555;
        text-shadow: none;
    }
    .nav-collapse .nav > li > a,
    .nav-collapse .dropdown-menu a {
        padding: 9px 15px;
        font-weight: bold;
        color: #555555;
        -webkit-border-radius: 3px;
        -moz-border-radius: 3px;
        border-radius: 3px;
    }
    .nav-collapse .btn {
        padding: 4px 10px 4px;
        font-weight: normal;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        border-radius: 4px;
    }
    .nav-collapse .dropdown-menu li + li a {
        margin-bottom: 2px;
    }
    .nav-collapse .nav > li > a:hover,
    .nav-collapse .dropdown-menu a:hover {
        background-color: #f2f2f2;
    }
    .navbar-inverse .nav-collapse .nav > li > a:hover,
    .navbar-inverse .nav-collapse .dropdown-menu a:hover {
        background-color: #111111;
    }
    .nav-collapse.in .btn-group {
        padding: 0;
        margin-top: 5px;
    }
    .nav-collapse .dropdown-menu {
        position: static;
        top: auto;
        left: auto;
        display: block;
        float: none;
        max-width: none;
        padding: 0;
        margin: 0 15px;
        background-color: transparent;
        border: none;
        -webkit-border-radius: 0;
        -moz-border-radius: 0;
        border-radius: 0;
        -webkit-box-shadow: none;
        -moz-box-shadow: none;
        box-shadow: none;
    }
    .nav-collapse .dropdown-menu:before,
    .nav-collapse .dropdown-menu:after {
        display: none;
    }
    .nav-collapse .dropdown-menu .divider {
        display: none;
    }
    .nav-collapse .navbar-form,
    .nav-collapse .navbar-search {
        float: none;
        padding: 10px 15px;
        margin: 10px 0;
        border-top: 1px solid #f2f2f2;
        border-bottom: 1px solid #f2f2f2;
        -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
        -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1);
    }
    .navbar .nav-collapse .nav.pull-right {
        float: none;
        margin-left: 0;
    }
    .nav-collapse,
    .nav-collapse.collapse {
        height: 0;
        overflow: hidden;
    }
    .navbar .btn-navbar {
        display: block;
    }
    .navbar-static .navbar-inner {
        padding-right: 10px;
        padding-left: 10px;
    }
    .navbar-inner {
        min-height: 50px!important;
    }

    #header ul.nav {
        padding-top: 15px!important;
    }
}

@media (min-width: 980px) {
    .nav-collapse.collapse {
        height: auto !important;
        overflow: visible !important;
    }
}


text:
<?php

/**
 * @namespace
 */

namespace Bluz\Tests\Fixtures\Models;

use Bluz\Auth\AbstractIdentity;
use Bluz\Proxy\Auth;

/**
 * Row
 *
 * @package  Bluz\Tests\Fixtures\Models
 *
 * @author   Anton Shevchuk
 * @created  28.03.14 18:25
 */
class UserAdmin extends AbstractIdentity
{
    /**
     * Can entity login
     *
     * @return void
     */
    public function tryLogin()
    {
        Auth::setIdentity($this);
    }

    /**
     * Get user privileges
     *
     * @return array
     */
    public function getPrivileges(): array
    {
        return [];
    }

    /**
     * Check user role
     *
     * @param integer $roleId
     *
     * @return boolean
     */
    public function hasRole($roleId)
    {
        return true;
    }

    /**
     * Has role a privilege
     *
     * @param string $module
     * @param string $privilege
     *
     * @return boolean
     */
    public function hasPrivilege($module, $privilege): bool
    {
        return true;
    }
}

redpajama_set_name: RedPajamaGithub


text:
var Schema = require('mongoose').Schema;
module.exports = {
  name: 'Quiz',
  schema: {
    name: String,
    questions: [{
      type: Schema.Types.ObjectId,
      ref: 'Question',
      'default': []
    }]
  }
};


text:
@interface AppointmentRemindTipsTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;
@property (weak, nonatomic) IBOutlet UILabel *hospitalLabel;

@end


text:
<?php

interface EC_Cache_MultiInterface
{
    /**
     * Adds multi get support to the interface, needed for memcached
     * via EC_Cache_Backend_LoadmemcachedMulti
     *
     * @param array $ids              Array of keys to load at once
     * @param bool  $doNotUnserialize Whethere or not to skip serializing
     *
     * @return array
     */
    public function loadMulti(array $ids, $doNotUnserialize = false);

    /**
     * Adds multi set support to the interface, needed for memcached
     * via EC_Cache_Backend_LoadmemcachedMulti
     *
     * @param array $data             The key/values to set at one time
     * @param mixed $specificLifetime Optional lifetime for this store
     *
     * @return bool
     */
    public function saveMulti(array $data, $specificLifetime = false);
}


text:
rm -rf FayeCpp.framework
rm -f *.a
rm -rf openssl

git clone git://github.com/krzyzanowskim/OpenSSL.git openssl
cd openssl
./build.sh
cd ..

lipo -extract i386 openssl/lib-ios/libcrypto.a -o libcrypto-i386.a
lipo -extract x86_64 openssl/lib-ios/libcrypto.a -o libcrypto-x86_64.a
lipo -extract armv7 openssl/lib-ios/libcrypto.a -o libcrypto-armv7.a
lipo -extract armv7s openssl/lib-ios/libcrypto.a -o libcrypto-armv7s.a
lipo -extract arm64 openssl/lib-ios/libcrypto.a -o libcrypto-arm64.a

lipo -extract i386 openssl/lib-ios/libssl.a -o libssl-i386.a
lipo -extract x86_64 openssl/lib-ios/libssl.a -o libssl-x86_64.a
lipo -extract armv7 openssl/lib-ios/libssl.a -o libssl-armv7.a
lipo -extract armv7s openssl/lib-ios/libssl.a -o libssl-armv7s.a
lipo -extract arm64 openssl/lib-ios/libssl.a -o libssl-arm64.a

xcodebuild -configuration Release -project fayecpp.xcodeproj -target fayecpp -arch i386 -sdk iphonesimulator OBJROOT=obj SYMROOT=sym clean build
cd obj
find . -type f -iregex '.*\.o$' | xargs -I @ ar -q -v ../all-i386.a @
cd ..
rm -rf obj
rm -rf sym

xcodebuild -configuration Release -project fayecpp.xcodeproj -target fayecpp -arch x86_64 -sdk iphonesimulator OBJROOT=obj SYMROOT=sym clean build
cd obj
find . -type f -iregex '.*\.o$' | xargs -I @ ar -q -v ../all-x86_64.a @
cd ..
rm -rf obj
rm -rf sym

xcodebuild -configuration Release -project fayecpp.xcodeproj -target fayecpp -arch armv7 -sdk iphoneos OBJROOT=obj SYMROOT=sym clean build
cd obj
find . -type f -iregex '.*\.o$' | xargs -I @ ar -q -v ../all-armv7.a @
cd ..
rm -rf obj
rm -rf sym

xcodebuild -configuration Release -project fayecpp.xcodeproj -target fayecpp -arch armv7s -sdk iphoneos OBJROOT=obj SYMROOT=sym clean build
cd obj
find . -type f -iregex '.*\.o$' | xargs -I @ ar -q -v ../all-armv7s.a @
cd ..
rm -rf obj
rm -rf sym

xcodebuild -configuration Release -project fayecpp.xcodeproj -target fayecpp -arch arm64 -sdk iphoneos OBJROOT=obj SYMROOT=sym IPHONEOS_DEPLOYMENT_TARGET=7.0.0 clean build
cd obj
find . -type f -iregex '.*\.o$' | xargs -I @ ar -q -v ../all-arm64.a @
cd ..
rm -rf obj
rm -rf sym

libtool -static all-i386.a libssl-i386.a libcrypto-i386.a -o all-ssl-i386.a
libtool -static all-x86_64.a libssl-x86_64.a libcrypto-x86_64.a -o all-ssl-x86_64.a
libtool -static all-armv7.a libssl-armv7.a libcrypto-armv7.a -o all-ssl-armv7.a
libtool -static all-armv7s.a libssl-armv7s.a libcrypto-armv7s.a -o all-ssl-armv7s.a
libtool -static all-arm64.a libssl-arm64.a libcrypto-arm64.a -o all-ssl-arm64.a

lipo -create all-ssl-i386.a all-ssl-x86_64.a all-ssl-armv7.a all-ssl-armv7s.a all-ssl-arm64.a -output all.a

rm -rf FayeCpp.framework
mkdir -p FayeCpp.framework/Versions/A/Headers

cp ../../fayecpp.h FayeCpp.framework/Versions/A/Headers/
cp ../../contrib/objc/FayeCppClient.h FayeCpp.framework/Versions/A/Headers/

mkdir -p FayeCpp.framework/Versions/A/Resources
cp all.a FayeCpp
cp FayeCpp FayeCpp.framework/Versions/A

ln -s A FayeCpp.framework/Versions/Current
ln -s Versions/Current/Headers FayeCpp.framework/Headers
ln -s Versions/Current/Resources FayeCpp.framework/Resources
ln -s Versions/Current/FayeCpp FayeCpp.framework/FayeCpp

rm -f FayeCpp
rm -f *.a


text:
#include <cuda.h>

#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_cuda_internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"

#include "avfilter.h"
#include "internal.h"

#define HIST_SIZE (3*256)
#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) )
#define BLOCKX 32
#define BLOCKY 16

static const enum AVPixelFormat supported_formats[] = {
    AV_PIX_FMT_NV12,
    AV_PIX_FMT_YUV420P,
    AV_PIX_FMT_YUV444P,
    AV_PIX_FMT_P010,
    AV_PIX_FMT_P016,
    AV_PIX_FMT_YUV444P16,
};

struct thumb_frame {
    AVFrame *buf;               ///< cached frame
    int histogram[HIST_SIZE];   ///< RGB color distribution histogram of the frame
};

typedef struct ThumbnailCudaContext {
    const AVClass *class;
    int n;                      ///< current frame
    int n_frames;               ///< number of frames for analysis
    struct thumb_frame *frames; ///< the n_frames frames
    AVRational tb;              ///< copy of the input timebase to ease access

    AVBufferRef *hw_frames_ctx;

    CUmodule    cu_module;

    CUfunction  cu_func_uchar;
    CUfunction  cu_func_uchar2;
    CUfunction  cu_func_ushort;
    CUfunction  cu_func_ushort2;
    CUtexref    cu_tex_uchar;
    CUtexref    cu_tex_uchar2;
    CUtexref    cu_tex_ushort;
    CUtexref    cu_tex_ushort2;

    CUdeviceptr data;
} ThumbnailCudaContext;

#define OFFSET(x) offsetof(ThumbnailCudaContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM

static const AVOption thumbnail_cuda_options[] = {
    { "n", "set the frames batch size", OFFSET(n_frames), AV_OPT_TYPE_INT, {.i64=100}, 2, INT_MAX, FLAGS },
    { NULL }
};

AVFILTER_DEFINE_CLASS(thumbnail_cuda);

static av_cold int init(AVFilterContext *ctx)
{
    ThumbnailCudaContext *s = ctx->priv;

    s->frames = av_calloc(s->n_frames, sizeof(*s->frames));
    if (!s->frames) {
        av_log(ctx, AV_LOG_ERROR,
               "Allocation failure, try to lower the number of frames\n");
        return AVERROR(ENOMEM);
    }
    av_log(ctx, AV_LOG_VERBOSE, "batch size: %d frames\n", s->n_frames);
    return 0;
}

/**
 * @brief        Compute Sum-square deviation to estimate "closeness".
 * @param hist   color distribution histogram
 * @param median average color distribution histogram
 * @return       sum of squared errors
 */
static double frame_sum_square_err(const int *hist, const double *median)
{
    int i;
    double err, sum_sq_err = 0;

    for (i = 0; i < HIST_SIZE; i++) {
        err = median[i] - (double)hist[i];
        sum_sq_err += err*err;
    }
    return sum_sq_err;
}

static AVFrame *get_best_frame(AVFilterContext *ctx)
{
    AVFrame *picref;
    ThumbnailCudaContext *s = ctx->priv;
    int i, j, best_frame_idx = 0;
    int nb_frames = s->n;
    double avg_hist[HIST_SIZE] = {0}, sq_err, min_sq_err = -1;

    // average histogram of the N frames
    for (j = 0; j < FF_ARRAY_ELEMS(avg_hist); j++) {
        for (i = 0; i < nb_frames; i++)
            avg_hist[j] += (double)s->frames[i].histogram[j];
        avg_hist[j] /= nb_frames;
    }

    // find the frame closer to the average using the sum of squared errors
    for (i = 0; i < nb_frames; i++) {
        sq_err = frame_sum_square_err(s->frames[i].histogram, avg_hist);
        if (i == 0 || sq_err < min_sq_err)
            best_frame_idx = i, min_sq_err = sq_err;
    }

    // free and reset everything (except the best frame buffer)
    for (i = 0; i < nb_frames; i++) {
        memset(s->frames[i].histogram, 0, sizeof(s->frames[i].histogram));
        if (i != best_frame_idx)
            av_frame_free(&s->frames[i].buf);
    }
    s->n = 0;

    // raise the chosen one
    picref = s->frames[best_frame_idx].buf;
    av_log(ctx, AV_LOG_INFO, "frame id #%d (pts_time=%f) selected "
           "from a set of %d images\n", best_frame_idx,
           picref->pts * av_q2d(s->tb), nb_frames);
    s->frames[best_frame_idx].buf = NULL;

    return picref;
}

static int thumbnail_kernel(ThumbnailCudaContext *s, CUfunction func, CUtexref tex, int channels,
    int *histogram, uint8_t *src_dptr, int src_width, int src_height, int src_pitch, int pixel_size)
{
    CUdeviceptr src_devptr = (CUdeviceptr)src_dptr;
    void *args[] = { &histogram, &src_width, &src_height };
    CUDA_ARRAY_DESCRIPTOR desc;

    desc.Width = src_width;
    desc.Height = src_height;
    desc.NumChannels = channels;
    if (pixel_size == 1) {
        desc.Format = CU_AD_FORMAT_UNSIGNED_INT8;
    }
    else {
        desc.Format = CU_AD_FORMAT_UNSIGNED_INT16;
    }

    cuTexRefSetAddress2D_v3(tex, &desc, src_devptr, src_pitch);
    cuLaunchKernel(func, DIV_UP(src_width, BLOCKX), DIV_UP(src_height, BLOCKY), 1, BLOCKX, BLOCKY, 1, 0, 0, args, NULL);

    return 0;
}

static int thumbnail(AVFilterContext *ctx, int *histogram, AVFrame *in)
{
    AVHWFramesContext *in_frames_ctx = (AVHWFramesContext*)in->hw_frames_ctx->data;
    ThumbnailCudaContext *s = ctx->priv;

    switch (in_frames_ctx->sw_format) {
    case AV_PIX_FMT_NV12:
        thumbnail_kernel(s, s->cu_func_uchar, s->cu_tex_uchar, 1,
            histogram, in->data[0], in->width, in->height, in->linesize[0], 1);
        thumbnail_kernel(s, s->cu_func_uchar2, s->cu_tex_uchar2, 2,
            histogram + 256, in->data[1], in->width / 2, in->height / 2, in->linesize[1], 1);
        break;
    case AV_PIX_FMT_YUV420P:
        thumbnail_kernel(s, s->cu_func_uchar, s->cu_tex_uchar, 1,
            histogram, in->data[0], in->width, in->height, in->linesize[0], 1);
        thumbnail_kernel(s, s->cu_func_uchar, s->cu_tex_uchar, 1,
            histogram + 256, in->data[1], in->width / 2, in->height / 2, in->linesize[1], 1);
        thumbnail_kernel(s, s->cu_func_uchar, s->cu_tex_uchar, 1,
            histogram + 512, in->data[2], in->width / 2, in->height / 2, in->linesize[2], 1);
        break;
    case AV_PIX_FMT_YUV444P:
        thumbnail_kernel(s, s->cu_func_uchar, s->cu_tex_uchar, 1,
            histogram, in->data[0], in->width, in->height, in->linesize[0], 1);
        thumbnail_kernel(s, s->cu_func_uchar, s->cu_tex_uchar, 1,
            histogram + 256, in->data[1], in->width, in->height, in->linesize[1], 1);
        thumbnail_kernel(s, s->cu_func_uchar, s->cu_tex_uchar, 1,
            histogram + 512, in->data[2], in->width, in->height, in->linesize[2], 1);
        break;
    case AV_PIX_FMT_P010LE:
    case AV_PIX_FMT_P016LE:
        thumbnail_kernel(s, s->cu_func_ushort, s->cu_tex_ushort, 1,
            histogram, in->data[0], in->width, in->height, in->linesize[0], 2);
        thumbnail_kernel(s, s->cu_func_ushort2, s->cu_tex_ushort2, 2,
            histogram + 256, in->data[1], in->width / 2, in->height / 2, in->linesize[1], 2);
        break;
    case AV_PIX_FMT_YUV444P16:
        thumbnail_kernel(s, s->cu_func_ushort2, s->cu_tex_uchar, 1,
            histogram, in->data[0], in->width, in->height, in->linesize[0], 2);
        thumbnail_kernel(s, s->cu_func_ushort2, s->cu_tex_uchar, 1,
            histogram + 256, in->data[1], in->width, in->height, in->linesize[1], 2);
        thumbnail_kernel(s, s->cu_func_ushort2, s->cu_tex_uchar, 1,
            histogram + 512, in->data[2], in->width, in->height, in->linesize[2], 2);
        break;
    default:
        return AVERROR_BUG;
    }

    return 0;
}

static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
{
    AVFilterContext *ctx  = inlink->dst;
    ThumbnailCudaContext *s   = ctx->priv;
    AVFilterLink *outlink = ctx->outputs[0];
    int *hist = s->frames[s->n].histogram;
    AVHWFramesContext *hw_frames_ctx = (AVHWFramesContext*)s->hw_frames_ctx->data;
    AVCUDADeviceContext *device_hwctx = hw_frames_ctx->device_ctx->hwctx;
    CUresult err;
    CUcontext dummy;
    CUDA_MEMCPY2D cpy = { 0 };
    int ret = 0;

    // keep a reference of each frame
    s->frames[s->n].buf = frame;

    err = cuCtxPushCurrent(device_hwctx->cuda_ctx);
    if (err != CUDA_SUCCESS)
        return AVERROR_UNKNOWN;

    cuMemsetD8(s->data, 0, HIST_SIZE * sizeof(int));

    thumbnail(ctx, (int*)s->data, frame);

    cpy.srcMemoryType = CU_MEMORYTYPE_DEVICE;
    cpy.dstMemoryType = CU_MEMORYTYPE_HOST;
    cpy.srcDevice = s->data;
    cpy.dstHost = hist;
    cpy.srcPitch = HIST_SIZE * sizeof(int);
    cpy.dstPitch = HIST_SIZE * sizeof(int);
    cpy.WidthInBytes = HIST_SIZE * sizeof(int);
    cpy.Height = 1;

    err = cuMemcpy2D(&cpy);
    if (err != CUDA_SUCCESS) {
        av_log(ctx, AV_LOG_ERROR, "Error transferring the data from the CUDA frame\n");
        return AVERROR_UNKNOWN;
    }

    if (hw_frames_ctx->sw_format == AV_PIX_FMT_NV12 || hw_frames_ctx->sw_format == AV_PIX_FMT_YUV420P ||
        hw_frames_ctx->sw_format == AV_PIX_FMT_P010LE || hw_frames_ctx->sw_format == AV_PIX_FMT_P016LE)
    {
        int i;
        for (i = 256; i < HIST_SIZE; i++)
            hist[i] = 4 * hist[i];
    }

    cuCtxPopCurrent(&dummy);
    if (ret < 0)
        return ret;

    // no selection until the buffer of N frames is filled up
    s->n++;
    if (s->n < s->n_frames)
        return 0;

    return ff_filter_frame(outlink, get_best_frame(ctx));
}

static av_cold void uninit(AVFilterContext *ctx)
{
    int i;
    ThumbnailCudaContext *s = ctx->priv;

    if (s->data) {
        cuMemFree(s->data);
        s->data = 0;
    }

    if (s->cu_module) {
        cuModuleUnload(s->cu_module);
        s->cu_module = NULL;
    }

    for (i = 0; i < s->n_frames && s->frames[i].buf; i++)
        av_frame_free(&s->frames[i].buf);
    av_freep(&s->frames);
}

static int request_frame(AVFilterLink *link)
{
    AVFilterContext *ctx = link->src;
    ThumbnailCudaContext *s = ctx->priv;
    int ret = ff_request_frame(ctx->inputs[0]);

    if (ret == AVERROR_EOF && s->n) {
        ret = ff_filter_frame(link, get_best_frame(ctx));
        if (ret < 0)
            return ret;
        ret = AVERROR_EOF;
    }
    if (ret < 0)
        return ret;
    return 0;
}

static int format_is_supported(enum AVPixelFormat fmt)
{
    int i;

    for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
        if (supported_formats[i] == fmt)
            return 1;
    return 0;
}

static int config_props(AVFilterLink *inlink)
{
    AVFilterContext *ctx = inlink->dst;
    ThumbnailCudaContext *s = ctx->priv;
    AVHWFramesContext     *hw_frames_ctx = (AVHWFramesContext*)inlink->hw_frames_ctx->data;
    AVCUDADeviceContext *device_hwctx = hw_frames_ctx->device_ctx->hwctx;
    CUcontext dummy, cuda_ctx = device_hwctx->cuda_ctx;
    CUresult err;

    extern char vf_thumbnail_cuda_ptx[];

    err = cuCtxPushCurrent(cuda_ctx);
    if (err != CUDA_SUCCESS) {
        av_log(ctx, AV_LOG_ERROR, "Error pushing cuda context\n");
        return AVERROR_UNKNOWN;
    }

    err = cuModuleLoadData(&s->cu_module, vf_thumbnail_cuda_ptx);
    if (err != CUDA_SUCCESS) {
        av_log(ctx, AV_LOG_ERROR, "Error loading module data\n");
        return AVERROR_UNKNOWN;
    }

    cuModuleGetFunction(&s->cu_func_uchar, s->cu_module, "Thumbnail_uchar");
    cuModuleGetFunction(&s->cu_func_uchar2, s->cu_module, "Thumbnail_uchar2");
    cuModuleGetFunction(&s->cu_func_ushort, s->cu_module, "Thumbnail_ushort");
    cuModuleGetFunction(&s->cu_func_ushort2, s->cu_module, "Thumbnail_ushort2");

    cuModuleGetTexRef(&s->cu_tex_uchar, s->cu_module, "uchar_tex");
    cuModuleGetTexRef(&s->cu_tex_uchar2, s->cu_module, "uchar2_tex");
    cuModuleGetTexRef(&s->cu_tex_ushort, s->cu_module, "ushort_tex");
    cuModuleGetTexRef(&s->cu_tex_ushort2, s->cu_module, "ushort2_tex");

    cuTexRefSetFlags(s->cu_tex_uchar, CU_TRSF_READ_AS_INTEGER);
    cuTexRefSetFlags(s->cu_tex_uchar2, CU_TRSF_READ_AS_INTEGER);
    cuTexRefSetFlags(s->cu_tex_ushort, CU_TRSF_READ_AS_INTEGER);
    cuTexRefSetFlags(s->cu_tex_ushort2, CU_TRSF_READ_AS_INTEGER);

    cuTexRefSetFilterMode(s->cu_tex_uchar, CU_TR_FILTER_MODE_LINEAR);
    cuTexRefSetFilterMode(s->cu_tex_uchar2, CU_TR_FILTER_MODE_LINEAR);
    cuTexRefSetFilterMode(s->cu_tex_ushort, CU_TR_FILTER_MODE_LINEAR);
    cuTexRefSetFilterMode(s->cu_tex_ushort2, CU_TR_FILTER_MODE_LINEAR);

    err = cuMemAlloc(&s->data, HIST_SIZE * sizeof(int));
    if (err != CUDA_SUCCESS) {
        av_log(ctx, AV_LOG_ERROR, "Error allocating cuda memory\n");
        return AVERROR_UNKNOWN;
    }

    cuCtxPopCurrent(&dummy);

    s->hw_frames_ctx = ctx->inputs[0]->hw_frames_ctx;

    ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(s->hw_frames_ctx);
    if (!ctx->outputs[0]->hw_frames_ctx)
        return AVERROR(ENOMEM);

    s->tb = inlink->time_base;

    if (!format_is_supported(hw_frames_ctx->sw_format)) {
        av_log(ctx, AV_LOG_ERROR, "Unsupported input format: %s\n", av_get_pix_fmt_name(hw_frames_ctx->sw_format));
        return AVERROR(ENOSYS);
    }

    return 0;
}

static int query_formats(AVFilterContext *ctx)
{
    static const enum AVPixelFormat pix_fmts[] = {
        AV_PIX_FMT_CUDA,
        AV_PIX_FMT_NONE
    };
    AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
    if (!fmts_list)
        return AVERROR(ENOMEM);
    return ff_set_common_formats(ctx, fmts_list);
}

static const AVFilterPad thumbnail_cuda_inputs[] = {
    {
        .name         = "default",
        .type         = AVMEDIA_TYPE_VIDEO,
        .config_props = config_props,
        .filter_frame = filter_frame,
    },
    { NULL }
};

static const AVFilterPad thumbnail_cuda_outputs[] = {
    {
        .name          = "default",
        .type          = AVMEDIA_TYPE_VIDEO,
        .request_frame = request_frame,
    },
    { NULL }
};

AVFilter ff_vf_thumbnail_cuda = {
    .name          = "thumbnail_cuda",
    .description   = NULL_IF_CONFIG_SMALL("Select the most representative frame in a given sequence of consecutive frames."),
    .priv_size     = sizeof(ThumbnailCudaContext),
    .init          = init,
    .uninit        = uninit,
    .query_formats = query_formats,
    .inputs        = thumbnail_cuda_inputs,
    .outputs       = thumbnail_cuda_outputs,
    .priv_class    = &thumbnail_cuda_class,
    .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
};


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>Challenge186</artifactId>
        <groupId>com.christianwilkie.rdailyprogrammer.challenge186</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.christianwilkie.rdailyprogrammer.challenge186</groupId>
    <artifactId>Problem1</artifactId>
    <version>1.0-SNAPSHOT</version>

</project>


text:
module Development.Shake.Internal.CompactUI(
    compactUI
    ) where

import Development.Shake.Internal.CmdOption
import Development.Shake.Internal.Options
import Development.Shake.Internal.Progress

import System.Time.Extra
import General.Extra
import Control.Exception
import General.Thread
import General.EscCodes
import Data.IORef.Extra
import Control.Monad.Extra

data S = S
    {sOutput :: [String] -- ^ Messages that haven't yet been printed, in reverse.
    ,sProgress :: String -- ^ Last progress message.
    ,sTraces :: [Maybe (String, String, Seconds)] -- ^ the traced items, in the order we display them
    ,sUnwind :: Int -- ^ Number of lines we used last time around
    }

emptyS = S [] "Starting..." [] 0

addOutput pri msg s = s{sOutput = msg : sOutput s}
addProgress x s = s{sProgress = x}

addTrace key msg start time s
    | start = s{sTraces = insert (key,msg,time) $ sTraces s}
    | otherwise = s{sTraces = remove (\(a,b,_) -> a == key && b == msg) $ sTraces s}
    where
        insert v (Nothing:xs) = Just v:xs
        insert v (x:xs) = x : insert v xs
        insert v [] = [Just v]

        remove f (Just x:xs) | f x = Nothing:xs
        remove f (x:xs) = x : remove f xs
        remove f [] = []

display :: Seconds -> S -> (S, String)
display time s = (s{sOutput=[], sUnwind=length post}, escCursorUp (sUnwind s) ++ unlines (map pad $ pre ++ post))
    where
        pre = sOutput s
        post = "" : (escForeground Green ++ "Status: " ++ sProgress s ++ escNormal) : map f (sTraces s)

        pad x = x ++ escClearLine
        f Nothing = " *"
        f (Just (k,m,t)) = " * " ++ k ++ " (" ++ g (time - t) m ++ ")"

        g i m | showDurationSecs i == "0s" = m
              | i < 10 = s
              | otherwise = escForeground (if i > 20 then Red else Yellow) ++ s ++ escNormal
            where s = m ++ " " ++ showDurationSecs i

-- | Run a compact UI, with the ShakeOptions modifier, combined with
compactUI :: ShakeOptions -> IO (ShakeOptions, IO ())
compactUI opts = do
    unlessM checkEscCodes $
        putStrLn "Your terminal does not appear to support escape codes, --compact mode may not work"
    ref <- newIORef emptyS
    let tweak = atomicModifyIORef_ ref
    time <- offsetTime
    opts <- pure $ opts
        {shakeTrace = \a b c -> do t <- time; tweak (addTrace a b c t)
        ,shakeOutput = \a b -> tweak (addOutput a b)
        ,shakeProgress = \x -> void $ progressDisplay 1 (tweak . addProgress) x `withThreadsBoth` shakeProgress opts x
        ,shakeCommandOptions = [EchoStdout False, EchoStderr False] ++ shakeCommandOptions opts
        ,shakeVerbosity = Error
        }
    let tick = do t <- time; mask_ $ putStr =<< atomicModifyIORef ref (display t)
    pure (opts, forever (tick >> sleep 0.4) `finally` tick)


text:
'''
Created on 24 mars 2014

@author: guillaume
'''

import os,sys
from unittest import TestCase
from tests.utils.utils import utils
s = sys.path.append(utils().buildPath(os.getcwd())+"/vagrant/optraj.istic.univ-rennes1.fr/src/")
from system.Shuttle import Shuttle
from system.Car import Car
from system.Worker import Worker
from system.Phase import Phase
from system.Position import Position
from system.Site import Site
from interfacebdd.SiteDAO import SiteDAO
from interfacebdd.CraftDAO import CraftDAO
from interfacebdd.QualificationDAO import QualificationDAO
from interfacebdd.ShuttleDAO import ShuttleDAO
from interfacebdd.Connexion import Connexion
from interfacebdd.CarDAO import CarDAO
from interfacebdd.WorkerDAO import WorkerDAO
from interfacebdd.PhaseDAO import PhaseDAO
from datetime import date

class test_shuttleDAO(TestCase):
    """Test the stand-alone module functions."""

    def test_insert(self):
        d = Connexion().connect()
        try:
            posIns = Position(num=-1, long=001, lat=002, address="test")
            craft = CraftDAO().getById(d, False, [], 1)
            qualif = QualificationDAO().getById(d, False, [], 1)
            driv = Worker(num=-1, name="toto", firstName="titi", birthdate=date(2013, 1, 1),licence="B1",position =posIns,  craft=craft, qualification=qualif)
            num = WorkerDAO().insert(d, driv)
            driv = WorkerDAO().getById(d, False, [], num)

            car = Car(num=-1, model="test1", nbPlace=4)
            num = CarDAO().insert(d, car)
            car = CarDAO().getById(d, False, [], num)

            pos = Position(num=-1, long=001, lat=002, address="test")
            siteIns = Site(num=-1, numSite="FR52005", name="champie", siteMaster="test", siteManager="test2", position=pos, dateInit=date(2013, 1, 1), dateEnd=date(2013, 2, 1), color="#6390df", phases=set())
            resSite = SiteDAO().insert(d, siteIns)
            ph = Phase(num=-1, numSite=resSite, numWeek=1, numYear=2014, needs = [], nbWorkers=1, totalWorkers=1)
            num = PhaseDAO().insert(d, ph)
            ph = PhaseDAO().getById(d, False, [], num)

            s = Shuttle(num=-1, driver=driv, car=car,phase=ph, pickups=set([]), passengers=set([]))
            res = ShuttleDAO().insert(d, s)
            shuRes = ShuttleDAO().getById(d, False, [], res)
            print shuRes
            s.num = res
            print s
            utils().equal(self, s, shuRes)
        except:
            Connexion().exception()
        finally:
            Connexion().disconnect(d)

    def test_get(self):
        d = Connexion().connect()
        try:
            carIns = Car(num=-1, plate="test", model="test1", nbPlace=4)
            res = CarDAO().insert(d, carIns)
            carRes = CarDAO().getById(d, False, [], res)
            carIns.num = res
            utils().equal(self, carIns, carRes)
        except:
            Connexion().exception()
        finally:
            Connexion().disconnect(d)

    def test_delete(self):
        d = Connexion().connect()
        try:
            carIns = Car(num=-1, plate="test", model="test1", nbPlace=4)
            res = CarDAO().insert(d, carIns)
            CarDAO().deleteById(d, res)
            carRes =self.assertRaises(AttributeError, CarDAO().getById, d, False, [], res)
            print(carRes)
        except:
            Connexion().exception()
        finally:
            Connexion().disconnect(d)

    def test_update(self):
        d = Connexion().connect()
        try:
            carIns = Car(num=-1, plate="test", model="test1", nbPlace=4)
            res = CarDAO().insert(d, carIns)
            carRes = CarDAO().getById(d, False, [], res)
            carRes.nbPlace = 8
            CarDAO().update(d, carRes)
            carRes2 = CarDAO().getById(d, False, [], res)
            utils().equal(self, carRes, carRes2)
        except:
            Connexion().exception()
        finally:
            Connexion().disconnect(d)


text: systems, regions, and other larger-scale stuff


text:
"""Activate coverage at python startup if appropriate.

The python site initialisation will ensure that anything we import
will be removed and not visible at the end of python startup.  However
we minimise all work by putting these init actions in this separate
module and only importing what is needed when needed.

For normal python startup when coverage should not be activated the pth
file checks a single env var and does not import or call the init fn
here.

For python startup when an ancestor process has set the env indicating
that code coverage is being collected we activate coverage based on
info passed via env vars.
"""
import atexit
import os
import signal

_active_cov = None

def init():
    # Only continue if ancestor process has set everything needed in
    # the env.
    global _active_cov

    cov_source = os.environ.get('COV_CORE_SOURCE')
    cov_config = os.environ.get('COV_CORE_CONFIG')
    cov_datafile = os.environ.get('COV_CORE_DATAFILE')
    cov_branch = True if os.environ.get('COV_CORE_BRANCH') == 'enabled' else None
    cov_context = os.environ.get('COV_CORE_CONTEXT')

    if cov_datafile:
        if _active_cov:
            cleanup()
        # Import what we need to activate coverage.
        import coverage

        # Determine all source roots.
        if cov_source in os.pathsep:
            cov_source = None
        else:
            cov_source = cov_source.split(os.pathsep)
        if cov_config == os.pathsep:
            cov_config = True

        # Activate coverage for this process.
        cov = _active_cov = coverage.Coverage(
            source=cov_source,
            branch=cov_branch,
            data_suffix=True,
            config_file=cov_config,
            auto_data=True,
            data_file=cov_datafile
        )
        cov.load()
        cov.start()
        if cov_context:
            cov.switch_context(cov_context)
        cov._warn_no_data = False
        cov._warn_unimported_source = False
        return cov

def _cleanup(cov):
    if cov is not None:
        cov.stop()
        cov.save()
        cov._auto_save = False  # prevent autosaving from cov._atexit in case the interpreter lacks atexit.unregister
        try:
            atexit.unregister(cov._atexit)
        except Exception:
            pass

def cleanup():
    global _active_cov
    global _cleanup_in_progress
    global _pending_signal

    _cleanup_in_progress = True
    _cleanup(_active_cov)
    _active_cov = None
    _cleanup_in_progress = False
    if _pending_signal:
        pending_signal = _pending_signal
        _pending_signal = None
        _signal_cleanup_handler(*pending_signal)

_previous_handlers = {}
_pending_signal = None
_cleanup_in_progress = False

def _signal_cleanup_handler(signum, frame):
    global _pending_signal
    if _cleanup_in_progress:
        _pending_signal = signum, frame
        return
    cleanup()
    _previous_handler = _previous_handlers.get(signum)
    if _previous_handler == signal.SIG_IGN:
        return
    elif _previous_handler and _previous_handler is not _signal_cleanup_handler:
        _previous_handler(signum, frame)
    elif signum == signal.SIGTERM:
        os._exit(128 + signum)
    elif signum == signal.SIGINT:
        raise KeyboardInterrupt()

def cleanup_on_signal(signum):
    previous = signal.getsignal(signum)
    if previous is not _signal_cleanup_handler:
        _previous_handlers[signum] = previous
        signal.signal(signum, _signal_cleanup_handler)

def cleanup_on_sigterm():
    cleanup_on_signal(signal.SIGTERM)


text:
"use strict";

var User = include("data/models").User;

module.exports = function(req, res, next) {
	User.findOne({ handle: req.query.handle }, function(err, user) {
		req.user = user;
		next();
	});
};


text:
class Plane :
	public Model
{
public:
	Plane();
	virtual ~Plane();

	virtual void Update(float dt) { }

	void BuildVertexBuffer();
	void BuildIndexBuffer();
};


text:
title: "Movies Trivia for Android"
excerpt: "Movies Trivia is a unique trivia game based on a random questions generator engine, that can create thousands of questions. Come test your knowledge about movies, actors & directors, characters & taglines, awards, and much more."
header:
  teaser: movies-trivia\android\Icon.png
sidebar:
  - title: Movies Trivia for Android
    image: movies-trivia\android\Icon.png
    image_alt: Movies Trivia for Android
    text: "[![Google Play](/images/google_play_en_badge_web_generic.png)](https://play.google.com/store/apps/details?id=com.saguiitay.MoviesTrivia)"
gallery:
  - url: movies-trivia\android\Screenshot1.png
    image_path: movies-trivia\android\Screenshot1.png
    alt: "Screenshot 1"
  - url: movies-trivia\android\Screenshot2.png
    image_path: movies-trivia\android\Screenshot2.png
    alt: "Screenshot 2"
  - url: movies-trivia\android\Screenshot3.png
    image_path: movies-trivia\android\Screenshot3.png
    alt: "Screenshot 3"
  - url: movies-trivia\android\Screenshot4.png
    image_path: movies-trivia\android\Screenshot4.png
    alt: "Screenshot 4"
  - url: movies-trivia\android\Screenshot5.png
    image_path: movies-trivia\android\Screenshot5.png
    alt: "Screenshot 5"
  - url: movies-trivia\android\Screenshot6.png
    image_path: movies-trivia\android\Screenshot6.png
    alt: "Screenshot 6"
  - url: movies-trivia\android\Screenshot7.png
    image_path: movies-trivia\android\Screenshot7.png
    alt: "Screenshot 7"
  - url: movies-trivia\android\Screenshot8.png
    image_path: movies-trivia\android\Screenshot8.png
    alt: "Screenshot 8"
---

Movies Trivia is a unique trivia game based on a random questions generator engine, that can create thousands of questions. Come test your knowledge about movies, actors & directors, characters & taglines, awards, and much more.

## Features:

  - Exceedingly simple and elegant
  - Thousands of questions
  - Unique random questions engine
  - Questions based on 540 movies, 1349 actors, 1201 images, 565 characters, 474 taglines, 223 directors, 504 awards and more…
  - 25 types of questions

[![Google Play](/images/google_play_en_badge_web_generic.png)](https://play.google.com/store/apps/details?id=com.saguiitay.MoviesTrivia)

## Screenshots

{% include gallery %}

## Data

You can see the data used for the game [here](/movies-data/)


text:
import click
from parsec.commands.toolshed.get_repositories import cli as get_repositories
from parsec.commands.toolshed.install_repository_revision import cli as install_repository_revision
from parsec.commands.toolshed.show_repository import cli as show_repository
from parsec.commands.toolshed.uninstall_repository_revision import cli as uninstall_repository_revision

@click.group()
def cli():
    pass

cli.add_command(get_repositories)
cli.add_command(install_repository_revision)
cli.add_command(show_repository)
cli.add_command(uninstall_repository_revision)


text:
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

var SourceEntry = (function() {
  'use strict';

  /**
   * A SourceEntry gathers all log entries with the same source.
   *
   * @constructor
   */
  function SourceEntry(logEntry, maxPreviousSourceId) {
    this.maxPreviousSourceId_ = maxPreviousSourceId;
    this.entries_ = [];
    this.description_ = '';

    // Set to true on most net errors.
    this.isError_ = false;

    // If the first entry is a BEGIN_PHASE, set to false.
    // Set to true when an END_PHASE matching the first entry is encountered.
    this.isInactive_ = true;

    if (logEntry.phase == LogEventPhase.PHASE_BEGIN)
      this.isInactive_ = false;

    this.update(logEntry);
  }

  SourceEntry.prototype = {
    update: function(logEntry) {
      // Only the last event should have the same type first event,
      if (!this.isInactive_ &&
          logEntry.phase == LogEventPhase.PHASE_END &&
          logEntry.type == this.entries_[0].type) {
        this.isInactive_ = true;
      }

      // If we have a net error code, update |this.isError_| if apporpriate.
      if (logEntry.params) {
        var netErrorCode = logEntry.params.net_error;
        // Skip both cases where netErrorCode is undefined, and cases where it
        // is 0, indicating no actual error occurred.
        if (netErrorCode) {
          // Ignore error code caused by not finding an entry in the cache.
          if (logEntry.type != LogEventType.HTTP_CACHE_OPEN_ENTRY ||
              netErrorCode != NetError.FAILED) {
            this.isError_ = true;
          }
        }
      }

      var prevStartEntry = this.getStartEntry_();
      this.entries_.push(logEntry);
      var curStartEntry = this.getStartEntry_();

      // If we just got the first entry for this source.
      if (prevStartEntry != curStartEntry)
        this.updateDescription_();
    },

    updateDescription_: function() {
      var e = this.getStartEntry_();
      this.description_ = '';
      if (!e)
        return;

      if (e.source.type == LogSourceType.NONE) {
        // NONE is what we use for global events that aren't actually grouped
        // by a "source ID", so we will just stringize the event's type.
        this.description_ = getKeyWithValue(LogEventType, e.type);
        return;
      }

      if (e.params == undefined) {
        return;
      }

      switch (e.source.type) {
        case LogSourceType.URL_REQUEST:
        case LogSourceType.SOCKET_STREAM:
        case LogSourceType.HTTP_STREAM_JOB:
          this.description_ = e.params.url;
          break;
        case LogSourceType.CONNECT_JOB:
          this.description_ = e.params.group_name;
          break;
        case LogSourceType.HOST_RESOLVER_IMPL_REQUEST:
        case LogSourceType.HOST_RESOLVER_IMPL_JOB:
        case LogSourceType.HOST_RESOLVER_IMPL_PROC_TASK:
          this.description_ = e.params.host;
          break;
        case LogSourceType.DISK_CACHE_ENTRY:
        case LogSourceType.MEMORY_CACHE_ENTRY:
          this.description_ = e.params.key;
          break;
        case LogSourceType.SPDY_SESSION:
          if (e.params.host)
            this.description_ = e.params.host + ' (' + e.params.proxy + ')';
          break;
        case LogSourceType.HTTP_PIPELINED_CONNECTION:
          if (e.params.host_and_port)
            this.description_ = e.params.host_and_port;
          break;
        case LogSourceType.SOCKET:
          // Use description of parent source, if any.
          if (e.params.source_dependency != undefined) {
            var parentId = e.params.source_dependency.id;
            this.description_ =
                SourceTracker.getInstance().getDescription(parentId);
          }
          break;
        case LogSourceType.UDP_SOCKET:
          if (e.params.address != undefined) {
            this.description_ = e.params.address;
            // If the parent of |this| is a HOST_RESOLVER_IMPL_JOB, use
            // '<DNS Server IP> [<host we're resolving>]'.
            if (this.entries_[0].type == LogEventType.SOCKET_ALIVE &&
                this.entries_[0].params.source_dependency != undefined) {
              var parentId = this.entries_[0].params.source_dependency.id;
              var parent = SourceTracker.getInstance().getSourceEntry(parentId);
              if (parent &&
                  parent.getSourceType() ==
                      LogSourceType.HOST_RESOLVER_IMPL_JOB &&
                  parent.getDescription().length > 0) {
                this.description_ += ' [' + parent.getDescription() + ']';
              }
            }
          }
          break;
        case LogSourceType.ASYNC_HOST_RESOLVER_REQUEST:
        case LogSourceType.DNS_TRANSACTION:
          this.description_ = e.params.hostname;
          break;
        case LogSourceType.DOWNLOAD:
          switch (e.type) {
            case LogEventType.DOWNLOAD_FILE_RENAMED:
              this.description_ = e.params.new_filename;
              break;
            case LogEventType.DOWNLOAD_FILE_OPENED:
              this.description_ = e.params.file_name;
              break;
            case LogEventType.DOWNLOAD_ITEM_ACTIVE:
              this.description_ = e.params.file_name;
              break;
          }
          break;
        case LogSourceType.FILESTREAM:
          this.description_ = e.params.file_name;
          break;
      }

      if (this.description_ == undefined)
        this.description_ = '';
    },

    /**
     * Returns a description for this source log stream, which will be displayed
     * in the list view. Most often this is a URL that identifies the request,
     * or a hostname for a connect job, etc...
     */
    getDescription: function() {
      return this.description_;
    },

    /**
     * Returns the starting entry for this source. Conceptually this is the
     * first entry that was logged to this source. However, we skip over the
     * TYPE_REQUEST_ALIVE entries which wrap TYPE_URL_REQUEST_START_JOB /
     * TYPE_SOCKET_STREAM_CONNECT.
     */
    getStartEntry_: function() {
      if (this.entries_.length < 1)
        return undefined;
      if (this.entries_[0].source.type == LogSourceType.FILESTREAM) {
        var e = this.findLogEntryByType_(LogEventType.FILE_STREAM_OPEN);
        if (e != undefined)
          return e;
      }
      if (this.entries_[0].source.type == LogSourceType.DOWNLOAD) {
        // If any rename occurred, use the last name
        e = this.findLastLogEntryStartByType_(
            LogEventType.DOWNLOAD_FILE_RENAMED);
        if (e != undefined)
          return e;
        // Otherwise, if the file was opened, use that name
        e = this.findLogEntryByType_(LogEventType.DOWNLOAD_FILE_OPENED);
        if (e != undefined)
          return e;
        // History items are never opened, so use the activation info
        e = this.findLogEntryByType_(LogEventType.DOWNLOAD_ITEM_ACTIVE);
        if (e != undefined)
          return e;
      }
      if (this.entries_.length >= 2) {
        if (this.entries_[0].type == LogEventType.REQUEST_ALIVE ||
            this.entries_[0].type == LogEventType.SOCKET_POOL_CONNECT_JOB ||
            this.entries_[1].type == LogEventType.UDP_CONNECT) {
          return this.entries_[1];
        }
      }
      return this.entries_[0];
    },

    /**
     * Returns the first entry with the specified type, or undefined if not
     * found.
     */
    findLogEntryByType_: function(type) {
      for (var i = 0; i < this.entries_.length; ++i) {
        if (this.entries_[i].type == type) {
          return this.entries_[i];
        }
      }
      return undefined;
    },

    /**
     * Returns the beginning of the last entry with the specified type, or
     * undefined if not found.
     */
    findLastLogEntryStartByType_: function(type) {
      for (var i = this.entries_.length - 1; i >= 0; --i) {
        if (this.entries_[i].type == type) {
          if (this.entries_[i].phase != LogEventPhase.PHASE_END)
            return this.entries_[i];
        }
      }
      return undefined;
    },

    getLogEntries: function() {
      return this.entries_;
    },

    getSourceTypeString: function() {
      return getKeyWithValue(LogSourceType, this.entries_[0].source.type);
    },

    getSourceType: function() {
      return this.entries_[0].source.type;
    },

    getSourceId: function() {
      return this.entries_[0].source.id;
    },

    /**
     * Returns the largest source ID seen before this object was received.
     * Used only for sorting SourceEntries without a source by source ID.
     */
    getMaxPreviousEntrySourceId: function() {
      return this.maxPreviousSourceId_;
    },

    isInactive: function() {
      return this.isInactive_;
    },

    isError: function() {
      return this.isError_;
    },

    /**
     * Returns time of last event if inactive.  Returns current time otherwise.
     */
    getEndTime: function() {
      if (!this.isInactive_) {
        return timeutil.getCurrentTime();
      } else {
        var endTicks = this.entries_[this.entries_.length - 1].time;
        return timeutil.convertTimeTicksToDate(endTicks).getTime();
      }
    },

    /**
     * Returns the time between the first and last events with a matching
     * source ID.  If source is still active, uses the current time for the
     * last event.
     */
    getDuration: function() {
      var startTicks = this.entries_[0].time;
      var startTime = timeutil.convertTimeTicksToDate(startTicks).getTime();
      var endTime = this.getEndTime();
      return endTime - startTime;
    },

    /**
     * Prints descriptive text about |entries_| to a new node added to the end
     * of |parent|.
     */
    printAsText: function(parent) {
      printLogEntriesAsText(this.entries_, parent);
    }
  };

  return SourceEntry;
})();


text:
# gulp-custom-filter
[![Build Status](https://secure.travis-ci.org/a-miyashita/gulp-custom-filter.png?branch=master)](http://travis-ci.org/a-miyashita/gulp-custom-filter)
[![Coverage Status](https://coveralls.io/repos/a-miyashita/gulp-custom-filter/badge.svg?branch=master&service=github)](https://coveralls.io/github/a-miyashita/gulp-custom-filter?branch=master)
[![Code Climate](https://codeclimate.com/github/a-miyashita/gulp-custom-filter/badges/gpa.svg)](https://codeclimate.com/github/a-miyashita/gulp-custom-filter)
[![David DM](https://david-dm.org/a-miyashita/gulp-custom-filter.svg)](https://david-dm.org/a-miyashita/gulp-custom-filter)

A gulp plugin to filter files by customized filters.

## Install

```bash
$ npm install --save-dev gulp-custom-filter
```

## Usage

```javascript
var filter = require('gulp-custom-filter');
var gulp = require('gulp');
var less = require('gulp-less');

function myFilter(file) {
	return file.basename.startsWith('my_');
}

gulp.task('less', function() {
	return gulp.src('./less/**/*.less')
		.pipe(filter(myFilter))
		.pipe(less())
		.pipe(gulp.dest('./css')
});
```

This is equivalent to:

```javascript
var filter = require('gulp-custom-filter');
var gulp = require('gulp');
var less = require('gulp-less');

gulp.task('less', function() {
	return gulp.src('./less/**/my_*.less')
		.pipe(less())
		.pipe(gulp.dest('./css')
});
```

You may set any predicate function to a vinyl file.

### Basic filters

#### filter.not(fn)

Nagates filter conditions

```javascript
var not = filter.not;

gulp.src('./less/**/*.less')
	.pipe(filter(not(myFilter)) // will pass files which not satisfy myFilter
```

This filter passes less files which its name does not start with 'my_'.

#### filter.and(fn1, fn2, ...)

Passes files which satisfy every filter conditions.

```javascript
var and = filter.and;

gulp.src('./less/**/*.less')
	.pipe(filter(and(myFilter1, myFilter2)) // will pass files which satisfy myFilter1 and myFilter2
```

#### filter.or(fn1, fn2, ...)

Passes files which satisfy at least one of the filter conditions.

```javascript
var or = filter.or;

gulp.src('./less/**/*.less')
	.pipe(filter(or(myFilter1, myFilter2)) // will pass files which satisfy myFilter1 or myFilter2
```

#### filter.all()

Passes every files. This is equivalent `function() { return true; }`

```javascript
var all = filter.all;

gulp.src('./less/**/*.less')
	.pipe(filter(all())) // no file will be filtered out.
```

#### filter.none()

Passes no file. This is equivalent `function() { return false; }`

```javascript
var none = filter.none;

gulp.src('./less/**/*.less')
	.pipe(filter(none())) // no file will be passed.
```

### Filename pattern filters

#### filter.glob(pattern, options)

Glob pattern filter for file name. Just a wrapper of minimatch.

```javascript
var glob = filter.glob;

gulp.src('./**/*.*')
	.pipe(filter(glob('./**/*.less'))).
```

* `pattern`: a string or an array of glob pattern.
* `options`: optional options.

#### filter.ignore(filename)

Ignore list filter.

```javascript
var ignore = filter.ignore;

gulp.src('./**/*.*')
	.pipe(filter(ignore('.gitignore')))
```

* `filename`: filename to ignore file.

## Filter development guide

`gulp-custom-filter` accepts three type of predicate functions.

### Simple boolean predicates: function(file, [encode]): boolean

A predicate must have one or two argument(s).
It returns a boolean value `true`/`false`.

```javascript
gulp.src('./**/*.*')
	.pipe(filter(function(file, encode) {
		return file.isBuffer();
	});
```

To fail the predicate, just throw an error.

```javascript
gulp.src('./**/*.*')
	.pipe(filter(function(file, encode) {
		throw new Error('error');
	});
```

### Asynchronous predicates: function(file, [encode], done: function(err, result)): void

A predicate must have three arguments.
The third argument is a callback function to settle a result.

Call `done` with the second argument of `true`/`false`.

```javascript
gulp.src('./**/*.*')
	.pipe(filter(function(file, encode, done) {
		setTimeout(function() {
			done(null, file.isBuffer()); // 1st argument must be falsy.
		}, 0);
	});
```

To fail the predicate, call `done` with the first argument of non-falsy value.

```javascript
gulp.src('./**/*.*')
	.pipe(filter(function(file, encode, done) {
		setTimeout(function() {
			done(new Error('error'));
		}, 0);
	});
```

### Promise predicates: function(file, done: function(err, result)): Promise.<boolean>

A predicate must have one or two argument(s).
It returns a fulfilling promise of boolean value `true`/`false`.

```javascript
gulp.src('./**/*.*')
	.pipe(filter(function(file, encode) {
		return Promise.resolve(file.isBuffer());
	});
```

To fail the predicate, return a rejecting promise.

```javascript
gulp.src('./**/*.*')
	.pipe(filter(function(file, encode) {
		return Promise.reject(new Error('error'));
	});
```

## Release Notes

* v0.4.3
  * Update library dependency

* v0.3.0

  * Update library dependency
  * Update supporting version of Node.js
     * Now we support Node 6 or higher

* v0.2.5

	* Update supporting version of Node.js
	* Fix assertion error message of or() filter

## License

* MIT License
	* see [LICENSE](LICENSE)


text:
<?php
/**
 * Created by PhpStorm.
 * User: gseidel
 * Date: 2020-02-11
 * Time: 14:21
 */

namespace Enhavo\Bundle\AppBundle\Toolbar\Widget;

use Enhavo\Bundle\AppBundle\Toolbar\AbstractToolbarWidgetType;
use Symfony\Component\OptionsResolver\OptionsResolver;

class NewWindowToolbarWidgetType extends AbstractToolbarWidgetType
{
    public function createViewData($name, array $options)
    {
        $data = parent::createViewData($name, $options);
        $data['label'] = $this->getLabel($options);
        $data['icon'] = $options['icon'];
        return $data;
    }

    private function getLabel($config)
    {
        return $this->translator->trans($config['label'], [], $config['translation_domain'] ? $config['translation_domain'] : null);
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        parent::configureOptions($resolver);
        $resolver->setDefaults([
            'icon' => 'open_in_new',
            'component' => 'new-window-widget',
            'translation_domain' => null,
            'label' => null
        ]);
    }

    public function getType()
    {
        return 'new_window';
    }
}


text:
struct ChessPiece {
  char pieceColor;
  unsigned char	pieceType;
  bool pieceInPlay;
  int pieceRow;		// row
  int pieceCol;		// col
  char pieceState;	// IDLE, MOVING, DYING
  MD2Instance* pieceModel;
};

#endif // __CHESS_PIECE_H__