text:
import * as debug from 'debug';
import { NextFunction, Request, Response, Router } from 'express';
import ParkingDb from '../database/ParkingDb';

const log = debug('app');

export class WidgetRouter {
    public router: Router;

    constructor() {
        this.router = Router();
        this.init();
    }

    /**
     * GET current state of parking
     */
    public getWidget(req: Request, res: Response, next: NextFunction) {
        const parkingDb = new ParkingDb();
        parkingDb.getLastParkingIdAsync()
            .then(parkingDb.getParkingForIdAsync)
            .then((parking: { models }) => {
                const free = parking.models[0].attributes.free;
                let result;
                if (free > 200) {
                    result = `#00ff00 ${free}`;
                } else if (free > 100) {
                    result = `#0000ff ${free}`;
                } else {
                    result = `#ff0000 ${free}`;
                }
                res.send(result);
            }).catch((err) => {
                res.send(err);
            });
    }

    public init() {
        this.router.get('/', this.getWidget);
    }

}

const widgetRoute = new WidgetRouter();
widgetRoute.init();

export default widgetRoute.router;


text:
namespace Cosmetics.Cart
{
    using System.Collections.Generic;
    using System.Linq;

    using Cosmetics.Contracts;
    using Common;

    public class ShoppingCart : IShoppingCart
    {
        private ICollection<IProduct> productList;

        public ShoppingCart()
        {
            this.ProductList = new List<IProduct>();
        }

        public ICollection<IProduct> ProductList
        {
            get
            {
                return new List<IProduct>(this.productList);
            }

            private set
            {
                Validator.CheckIfNull(value,
                    string.Format(GlobalErrorMessages.ObjectCannotBeNull, "The Product list"));

                productList = value;
            }
        }

        public void AddProduct(IProduct product)
        {
            // TODO: duplicate code?
           // Validator.CheckIfNull(product, string.Format(GlobalErrorMessages.ObjectCannotBeNull, "product"));

            this.ProductList.Add(product);
        }

        public void RemoveProduct(IProduct product)
        {
            Validator.CheckIfNull(product, string.Format(GlobalErrorMessages.ObjectCannotBeNull, "product"));
            this.ProductList.Remove(product);
        }

        public bool ContainsProduct(IProduct product)
        {
            Validator.CheckIfNull(product, string.Format(GlobalErrorMessages.ObjectCannotBeNull, "product"));

            if (this.ProductList.Contains(product))
            {
                return true;
            }

            return false;
        }

        public decimal TotalPrice()
        {
            // TODO: is this proper?
            decimal result = this.ProductList.Sum(p => p.Price);

            return result;
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
require 'test_helper'

class Cfp::PeopleHelperTest < ActionView::TestCase
end


text:
'use strict';

const getRequest = require(`nodejs-repo-tools`).getRequest;
const test = require(`ava`);

module.exports = (DATA_BACKEND) => {
  let originalDataBackend, id, testConfig, appConfig;

  test.before(() => {
    testConfig = require(`./_test-config`);
    appConfig = require(`../config`);
    originalDataBackend = appConfig.get(`DATA_BACKEND`);
    appConfig.set(`DATA_BACKEND`, DATA_BACKEND);
  });

  // setup a book
  test.serial.cb(`should create a book`, (t) => {
    getRequest(testConfig)
      .post(`/api/books`)
      .send({ title: `my book` })
      .expect(200)
      .expect((response) => {
        id = response.body.id;
        t.truthy(response.body.id);
        t.is(response.body.title, `my book`);
      })
      .end(t.end);
  });

  test.serial.cb(`should show a list of books`, (t) => {
    // Give Datastore time to become consistent
    setTimeout(() => {
      const expected = /
/;
      getRequest(testConfig)
        .get(`/books`)
        .expect(200)
        .expect((response) => {
          t.regex(response.text, expected);
        })
        .end(t.end);
    }, 2000);
  });

  test.serial.cb(`should handle error`, (t) => {
    getRequest(testConfig)
      .get(`/books`)
      .query({ pageToken: `badrequest` })
      .expect(500)
      .end(t.end);
  });

  // delete the book
  test.serial.cb(`should delete a book`, (t) => {
    if (id) {
      getRequest(testConfig)
        .delete(`/api/books/${id}`)
        .expect(200)
        .end(t.end);
    } else {
      t.end();
    }
  });

  test.serial.cb(`should post to add book form`, (t) => {
    const expected = /Redirecting to \/books\//;
    getRequest(testConfig)
      .post(`/books/add`)
      .send(`title=my%20book`)
      .expect(302)
      .expect((response) => {
        const location = response.headers.location;
        const idPart = location.replace(`/books/`, ``);
        if (DATA_BACKEND !== `mongodb`) {
          id = parseInt(idPart, 10);
        } else {
          id = idPart;
        }
        t.regex(response.text, expected);
      })
      .end(t.end);
  });

  test.serial.cb(`should show add book form`, (t) => {
    const expected = /Add book/;
    getRequest(testConfig)
      .get(`/books/add`)
      .expect(200)
      .expect((response) => {
        t.regex(response.text, expected);
      })
      .end(t.end);
  });

  // delete the book
  test.serial.cb((t) => {
    if (id) {
      getRequest(testConfig)
        .delete(`/api/books/${id}`)
        .expect(200)
        .end(t.end);
    } else {
      t.end();
    }
  });

  // setup a book
  test.serial.cb((t) => {
    getRequest(testConfig)
      .post(`/api/books`)
      .send({ title: `my book` })
      .expect(200)
      .expect((response) => {
        id = response.body.id;
        t.truthy(response.body.id);
        t.is(response.body.title, `my book`);
      })
      .end(t.end);
  });

  test.serial.cb(`should update a book`, (t) => {
    const expected = new RegExp(`Redirecting to /books/${id}`);
    getRequest(testConfig)
      .post(`/books/${id}/edit`)
      .send(`title=my%20other%20book`)
      .expect(302)
      .expect((response) => {
        t.regex(response.text, expected);
      })
      .end(t.end);
  });

  test.serial.cb(`should show edit book form`, (t) => {
    const expected =
      /<input type="text" name="title" id="title" value="my other book" class="form-control">/;
    getRequest(testConfig)
      .get(`/books/${id}/edit`)
      .expect(200)
      .expect((response) => {
        t.regex(response.text, expected);
      })
      .end(t.end);
  });

  test.serial.cb(`should show a book`, (t) => {
    const expected = /
my other book <\/small><\/h4>/;
    getRequest(testConfig)
      .get(`/books/${id}`)
      .expect(200)
      .expect((response) => {
        t.regex(response.text, expected);
      })
      .end(t.end);
  });

  test.serial.cb(`should delete a book`, (t) => {
    const expected = /Redirecting to \/books/;
    getRequest(testConfig)
      .get(`/books/${id}/delete`)
      .expect(302)
      .expect((response) => {
        id = undefined;
        t.regex(response.text, expected);
      })
      .end(t.end);
  });

  // clean up
  test.always.after.cb((t) => {
    appConfig.set(`DATA_BACKEND`, originalDataBackend);

    if (id) {
      getRequest(testConfig)
        .delete(`/api/books/${id}`)
        .expect(200)
        .end(t.end);
    } else {
      t.end();
    }
  });
};


text:
redis-cli FLUSHALL
if [ $? == "0" ];then
    go test -v -run=TestMysqlWithCache
else
    echo "no redis-server running on localhost"
fi


text:
var MarkersGroup = require('../models/group-model'),
    Marker = require('../models/marker-model.js'),
    formidable = require('formidable'),
    fs = require('fs'),
    gm = require('gm'),
    date;

var MarkersController = function(){

    if(!fs.existsSync('public/img/uploaded')){
        fs.mkdirSync('public/img/uploaded', 777);
    }
//    for(var i = 0; i < 20000; i++){
//        var newMarker = new Marker({
//            name : i,
//            description : i,
//            id : undefined,
//            groupId: 'none',
//            location: {
//                latitude : Math.random() * 100 - 50,
//                longitude : Math.random() * 100 - 50
//            },
//            user:'anonymous'
//
//        });
//        newMarker.id = newMarker._id;
//        newMarker.save(function(err, marker){
//            console.log(marker.id);
//        });
//
//    }

    console.log('new controller created');
};

//MarkersController.prototype.getFile = function(request, responce){
//
//    var form = new formidable.IncomingForm();
//
//    form.parse(request, function(err, fields, files) {
//        console.dir(files['file0']);
//        fs.readFile(files['file0'].path, function(err, data){
//            if(err){
//                console.dir(err);
//                responce.send('error');
//                return;
//            }
//            fs.writeFile('public/img/uploaded/' + files['file0'].name, data, function(err){
//                if(err){
//                    console.dir(err);
//                    responce.send('fail');
//                }
//                responce.send({src : '/img/uploaded/' + files['file0'].name});
//            })
//        });
//
//    });
//
//
//
//};

MarkersController.prototype.saveGroup = function(request, response){
    var date = new Date();
    console.log(request.param('id'));

    if(request.param('id') != 0){
        console.log('update group id:' + request.param('id') +  ' request ' + date.toDateString() + ' ' + date.toTimeString());
        MarkersGroup.findOneAndUpdate({id : request.param('id')}, { $set: {name : request.param('name'), iconUrl : request.param('iconUrl')}}, function(err, group){
            if(err){
                console.error(err);
                response.status(500);
                response.send('Did not updated');
                return false;
            }
            if(group){
                response.send(group);
            }
        });
    }
    else{
        console.log('save group request ' + date.toDateString() + ' ' + date.toTimeString());
        var newGroup = new MarkersGroup({
            name : request.param('name'),
            id : 0,
            user:'anonymous',
            iconUrl: request.param('iconUrl')
        });
        newGroup.id = newGroup._id;
        newGroup.save(function(err, group){
            if(err){
                console.error(err);
                response.status(500);
                response.send('Did not saved');
                return false;
            }
            if(group){
                response.send(group);
            }

        });
    }

};

MarkersController.prototype.removeGroup = function(request, response){
    var date = new Date(),
        groupIdToRemove = request.param('id');
    console.log('request remove group '  + date.toDateString() + ' ' + date.toTimeString());
    MarkersGroup.remove({id : groupIdToRemove}, function(err){
        if(!err){
            Marker.find({groupId : groupIdToRemove}, function(err, markers){
                if(err){
                    response.send('no markers in deleted group');
                }
                if(markers){
                    console.dir(markers);
                    for(var i = 0; i < markers.length; i++){
                        if(fs.existsSync('public' + markers[i].imageUrl)){
                            fs.unlinkSync('public' + markers[i].imageUrl);
                        }
                    }
                    Marker.remove({groupId : request.param('id')}, function(err){
                        if(!err) {
                            response.send({answer: 'ok'});
                        }
                        else{
                            response.send({answer: 'failremovemarkers'});
                        }
                    });

                }
            });

        }
        else{
            response.send({answer: 'failremovegroup'});
        }
    });
};

MarkersController.prototype.updateGroup = function(request, response){
    var date = new Date();
    console.log('request for group update id:' + request.param('id') + ' ' + date.toDateString() + ' ' + date.toTimeString());
    console.dir(request.params);
    MarkersGroup.findOneAndUpdate({id: request.param('id')}, { markers: request.param('markers') }, function(err, group){
        if(err){
            console.error(err);
            response.status(500);
            response.send('Did not saved');
        }
        if(group){
            response.send(group);
        }
    });

};

MarkersController.prototype.uploadGroups = function(request, response){
    var date = new Date();
    console.log('request for groups '  + date.toDateString() + ' ' + date.toTimeString());
    MarkersGroup.find({}, function(err, groups){
        if(err){
            console.error(err);
            response.status(500);
            response.send('Collection not found');
            return false;
        }
        if(groups.length){
            response.send(groups);
        }
        else{
            response.send([]);
        }
    });
};

MarkersController.prototype.uploadSpecifiedGroup = function (request, response){
    var date = new Date();
    console.log('request specified group '  + date.toDateString() + ' ' + date.toTimeString());

    var markerGroup = {};
    date = (new Date()).toTimeString();
    console.log(date);

    MarkersGroup.find({'id' : request.param('groupId')}, function(err, group){

        if(err){
            console.error(err);
            response.status(500);
            response.send('Collection not found');
            return false;
        }
        if(group){
            markerGroup = group;
            Marker.find({'groupId' : markerGroup.id}, function(err, markers){
                if(err){
                    console.error(err);
                    response.status(500);
                    response.send('Collection not found');
                    return false;
                }
                if(markers){
                    markerGroup.markers = markers;
                    response.send(markerGroup);
                }
            });
//            response.send(group);
        }

    });
};

MarkersController.prototype.uploadMarkers = function(request, response){
    var date = new Date();

    console.log('request for ungrouped markers '  + date.toDateString() + ' ' + date.toTimeString());

    Marker.find({}, function(err, markers){
        if(err){
            console.error(err);
            response.status(404);
            response.send('Collection not found');
            return false;
        }
        if(markers){
            response.send(markers);
        }
    });

};

MarkersController.prototype.updateMarker = function(request, response){

    console.log(request.param('id'));

};

MarkersController.prototype.saveMarker = function(request, response){

    var newMarker,
        date = new Date(),
        self = this,
        markerIsNew,
        updateOptions,

        form = new formidable.IncomingForm();

    form.parse(request, function(err, fields, files) {
//        console.dir(files['image']);
        markerIsNew = fields['id'] && fields['id'] != 'none' ? false : true;
        if(files['image'] && !markerIsNew){
                Marker.findOne({id : fields['id']}, function(err, marker){
                    if(err){
                        console.dir(err);
                    }
                    if(marker){
                        fs.exists('public' + marker.imageUrl, function(exists){
                            exists ? fs.unlink('public' + marker.imageUrl) : false;
                        });
                    }
                });
                gm(files['image'].path).resize(250).write('public/img/uploaded/' + files['image'].name, function(err){
                    if(err){console.dir(err);}

                    console.log('gm write');
                });
        }

    if(!markerIsNew){ // ================ update existing marker ===================

        console.log('request update marker ' + fields['id'] + ' ' + date.toDateString() + ' ' + date.toTimeString());
        if(files['image']){
            var fName = files['image'].name;
            updateOptions = {
                description : fields['description'],
                groupId : fields['groupId'],
                imageUrl : '/img/uploaded/' + fields['id'] + MarkersController.prototype.getImageExtension(files['image'].name)
            };
            fs.rename('public/img/uploaded/' + fName, 'public' + updateOptions.imageUrl, function(err, success){
                if(err){console.error(err);}
                fs.unlink('public/img/uploaded/' + fName, function(err){
                    if(err){console.error(err)}
                });
            });
        }
        else{
            updateOptions = {
                description : fields['description'],
                groupId : fields['groupId']
            }

        }

        Marker.findOneAndUpdate({id : fields['id']}, {
                $set: updateOptions
            },
            function(err, marker){
                if(err){
                    console.error(err);
                    response.status(500);
                    response.send('Did not updated');
                    return false;
                }
                if(marker){
    //                console.dir(marker);
                    response.send(marker);
                }
            });
    }

    else{ // ================ save new marker ==============================

        console.log('request save new marker '  + date.toDateString() + ' ' + date.toTimeString());
//        console.log(files['image'].path);

        newMarker = new Marker({
            name : fields['name'],
            description : fields.description,
            id : undefined,
            groupId: fields.groupId,
            location: {
                latitude : fields.latitude,
                longitude : fields.longitude
            },
            user:'anonymous'

        });
        newMarker.id = newMarker._id;

        if(files['image']){
            gm(files['image'].path).resize(250).write('public/img/uploaded/' + newMarker.id + MarkersController.prototype.getImageExtension(files['image'].name), function(err){
                console.dir(err);
            });

//            fs.rename('public/img/uploaded/' + files['image'].name, 'public/img/uploaded/' + newMarker.id + MarkersController.prototype.getImageExtension(files['image'].name), function(err, success){
//                console.dir(err);
//                console.dir(success);
//            });
            newMarker.imageUrl =  '/img/uploaded/' + newMarker.id + MarkersController.prototype.getImageExtension(files['image'].name);
        }
        else{
            newMarker.imageUrl = undefined;
        }

        newMarker.save(function(err, marker){
            if(err){
                console.error(err);
                response.status(500);
                response.send('Did not saved');
                return false;
            }
            if(marker){
//            marker.id = marker._id;
                console.dir(marker);
                response.send(marker);
            }

        });
    }
    });
//    if(request.param('id')){ // ================ update existing marker ===================
//
//        console.log('request update marker ' + request.param('id') + ' ' + date.toDateString() + ' ' + date.toTimeString());
//        console.log(request.param('description'));
//
//        Marker.findOneAndUpdate({id : request.param('id')}, { $set: {description : request.param('description'), groupId : request.param('groupId')}}, function(err, marker){
//            if(err){
//                console.error(err);
//                response.status(500);
//                response.send('Did not updated');
//                return false;
//            }
//            if(marker){
//                console.dir(marker);
//                response.send(marker);
//            }
//        });
//    }
//
//    else{ // ================ save new marker ==============================
//
//        console.log('request save marker '  + date.toDateString() + ' ' + date.toTimeString());
//        newMarker = new Marker({
//            name : request.param('name'),
//            description : request.param('description'),
//            id : undefined,
//            groupId: request.param('groupId'),
//            location: request.param('location'),
//            user:'anonymous'
//        });
//        newMarker.id = newMarker._id;
//        newMarker.save(function(err, marker){
//            if(err){
//                console.error(err);
//                response.status(500);
//                response.send('Did not saved');
//                return false;
//            }
//            if(marker){
////            marker.id = marker._id;
//                response.send(marker);
//            }
//
//        });
//    }

};

MarkersController.prototype.removeMarker = function(request, response){
    var date = new Date();
    console.log('Request remove marker ' + request.param('id') + ' ' + date.toDateString() + ' ' + date.toTimeString());
    Marker.find({id : request.param('id')}, function(err, doc){

        if(doc){
            console.dir(doc);
            if(fs.existsSync('public' + doc[0].imageUrl)){
                console.log('exists');
                fs.unlinkSync('public' + doc[0].imageUrl);
            }

            Marker.remove({id : request.param('id')}, function(err, doc){
                console.log(err + '     ' + doc);
            });
        }
    });
    response.send('ok');
};

MarkersController.prototype.getImageExtension = function(fileName){

    return fileName.match(/\.\w+$/)[0];

};

module.exports = MarkersController;


text:
package org.jugbd.mnet.domain.enums;

/**
 * @author Bazlur Rahman Rokon
 * @date 10/3/15.
 */
public enum RegistrationType {
    //OUTDOOR("Outpatient"), INDOOR("Inpatient"),

    EMERGENCY("Emergency Indoor"), GENERAL("General Indoor");

    private String label;

    RegistrationType(String label) {
        this.label = label;
    }

    public String getLabel() {
        return label;
    }
}


text:
@use 'light.html'

//@ I'm a comment, you will not see me in the compiled PHP file :)

@block content

@title

Index

        @foreach response as resp

@resp->title

@resp->content

        @endforeach

@endblock


text:
// Copyright 2000 John Maddock (john@johnmaddock.co.uk)
// Copyright 2000 Jeremy Siek (jsiek@lsc.nd.edu)
// Copyright 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
//
//  Use, modification and distribution are subject to the Boost Software License,
//  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt).
//
//  See http://www.boost.org/libs/type_traits for most recent version including documentation.

#ifndef NDNBOOST_TT_IS_CONVERTIBLE_HPP_INCLUDED
#define NDNBOOST_TT_IS_CONVERTIBLE_HPP_INCLUDED

#include <ndnboost/type_traits/intrinsics.hpp>
#ifndef NDNBOOST_IS_CONVERTIBLE
#include <ndnboost/type_traits/detail/yes_no_type.hpp>
#include <ndnboost/type_traits/config.hpp>
#include <ndnboost/type_traits/is_array.hpp>
#include <ndnboost/type_traits/ice.hpp>
#include <ndnboost/type_traits/is_arithmetic.hpp>
#include <ndnboost/type_traits/is_void.hpp>
#ifndef NDNBOOST_NO_IS_ABSTRACT
#include <ndnboost/type_traits/is_abstract.hpp>
#endif
#include <ndnboost/type_traits/add_lvalue_reference.hpp>
#include <ndnboost/type_traits/add_rvalue_reference.hpp>
#include <ndnboost/type_traits/is_function.hpp>

#if defined(__MWERKS__)
#include <ndnboost/type_traits/remove_reference.hpp>
#endif

#endif // NDNBOOST_IS_CONVERTIBLE

// should be always the last #include directive
#include <ndnboost/type_traits/detail/bool_trait_def.hpp>

namespace ndnboost {

#ifndef NDNBOOST_IS_CONVERTIBLE

// is one type convertible to another?
//
// there are multiple versions of the is_convertible
// template, almost every compiler seems to require its
// own version.
//
// Thanks to Andrei Alexandrescu for the original version of the
// conversion detection technique!
//

namespace detail {

// MS specific version:

#if defined(NDNBOOST_MSVC) && (NDNBOOST_MSVC <= 1300)

// This workaround is necessary to handle when From is void
// which is normally taken care of by the partial specialization
// of the is_convertible typename.
using ::ndnboost::type_traits::yes_type;
using ::ndnboost::type_traits::no_type;

template< typename From >
struct does_conversion_exist
{
    template< typename To > struct result_
    {
        static no_type NDNBOOST_TT_DECL _m_check(...);
        static yes_type NDNBOOST_TT_DECL _m_check(To);
        static typename add_lvalue_reference<From>::type  _m_from;
        enum { value = sizeof( _m_check(_m_from) ) == sizeof(yes_type) };
    };
};

template<>
struct does_conversion_exist<void>
{
    template< typename To > struct result_
    {
        enum { value = ::ndnboost::is_void<To>::value };
    };
};

template <typename From, typename To>
struct is_convertible_basic_impl
    : public does_conversion_exist<From>::template result_<To>
{
};

#elif defined(__BORLANDC__) && (__BORLANDC__ < 0x560)
//
// special version for Borland compilers
// this version breaks when used for some
// UDT conversions:
//
template <typename From, typename To>
struct is_convertible_impl
{
#pragma option push -w-8074
    // This workaround for Borland breaks the EDG C++ frontend,
    // so we only use it for Borland.
    template <typename T> struct checker
    {
        static ::ndnboost::type_traits::no_type NDNBOOST_TT_DECL _m_check(...);
        static ::ndnboost::type_traits::yes_type NDNBOOST_TT_DECL _m_check(T);
    };

    static typename add_lvalue_reference<From>::type  _m_from;
    static bool const value = sizeof( checker<To>::_m_check(_m_from) )
        == sizeof(::ndnboost::type_traits::yes_type);
#pragma option pop
};

#elif defined(__GNUC__) || defined(__BORLANDC__) && (__BORLANDC__ < 0x600)
// special version for gcc compiler + recent Borland versions
// note that this does not pass UDT's through (...)

struct any_conversion
{
    template <typename T> any_conversion(const volatile T&);
    template <typename T> any_conversion(const T&);
    template <typename T> any_conversion(volatile T&);
    template <typename T> any_conversion(T&);
};

template <typename T> struct checker
{
    static ndnboost::type_traits::no_type _m_check(any_conversion ...);
    static ndnboost::type_traits::yes_type _m_check(T, int);
};

template <typename From, typename To>
struct is_convertible_basic_impl
{
    typedef typename add_lvalue_reference<From>::type lvalue_type;
    typedef typename add_rvalue_reference<From>::type rvalue_type;
    static lvalue_type _m_from;
#if !defined(NDNBOOST_NO_CXX11_RVALUE_REFERENCES) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 6)))
    static bool const value =
        sizeof( ndnboost::detail::checker<To>::_m_check(static_cast<rvalue_type>(_m_from), 0) )
        == sizeof(::ndnboost::type_traits::yes_type);
#else
    static bool const value =
        sizeof( ndnboost::detail::checker<To>::_m_check(_m_from, 0) )
        == sizeof(::ndnboost::type_traits::yes_type);
#endif
};

#elif (defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 245) && !defined(__ICL)) \
      || defined(__IBMCPP__) || defined(__HP_aCC)
//
// This is *almost* an ideal world implementation as it doesn't rely
// on undefined behaviour by passing UDT's through (...).
// Unfortunately it doesn't quite pass all the tests for most compilers (sigh...)
// Enable this for your compiler if is_convertible_test.cpp will compile it...
//
// Note we do not enable this for VC7.1, because even though it passes all the
// type_traits tests it is known to cause problems when instantiation occurs
// deep within the instantiation tree :-(
//
struct any_conversion
{
    template <typename T> any_conversion(const volatile T&);
    template <typename T> any_conversion(const T&);
    template <typename T> any_conversion(volatile T&);
    // we need this constructor to catch references to functions
    // (which can not be cv-qualified):
    template <typename T> any_conversion(T&);
};

template <typename From, typename To>
struct is_convertible_basic_impl
{
    static ::ndnboost::type_traits::no_type NDNBOOST_TT_DECL _m_check(any_conversion ...);
    static ::ndnboost::type_traits::yes_type NDNBOOST_TT_DECL _m_check(To, int);
    typedef typename add_lvalue_reference<From>::type lvalue_type;
    typedef typename add_rvalue_reference<From>::type rvalue_type;
    static lvalue_type _m_from;

#ifndef NDNBOOST_NO_CXX11_RVALUE_REFERENCES
    NDNBOOST_STATIC_CONSTANT(bool, value =
        sizeof( _m_check(static_cast<rvalue_type>(_m_from), 0) ) == sizeof(::ndnboost::type_traits::yes_type)
        );
#else
    NDNBOOST_STATIC_CONSTANT(bool, value =
        sizeof( _m_check(_m_from, 0) ) == sizeof(::ndnboost::type_traits::yes_type)
        );
#endif
};

#elif defined(__DMC__)

struct any_conversion
{
    template <typename T> any_conversion(const volatile T&);
    template <typename T> any_conversion(const T&);
    template <typename T> any_conversion(volatile T&);
    // we need this constructor to catch references to functions
    // (which can not be cv-qualified):
    template <typename T> any_conversion(T&);
};

template <typename From, typename To>
struct is_convertible_basic_impl
{
    // Using '...' doesn't always work on Digital Mars. This version seems to.
    template <class T>
    static ::ndnboost::type_traits::no_type NDNBOOST_TT_DECL _m_check(any_conversion,  float, T);
    static ::ndnboost::type_traits::yes_type NDNBOOST_TT_DECL _m_check(To, int, int);
    typedef typename add_lvalue_reference<From>::type lvalue_type;
    typedef typename add_rvalue_reference<From>::type rvalue_type;
    static lvalue_type _m_from;

    // Static constants sometime cause the conversion of _m_from to To to be
    // called. This doesn't happen with an enum.
#ifndef NDNBOOST_NO_CXX11_RVALUE_REFERENCES
    enum { value =
        sizeof( _m_check(static_cast<rvalue_type>(_m_from), 0, 0) ) == sizeof(::ndnboost::type_traits::yes_type)
        };
#else
    enum { value =
        sizeof( _m_check(_m_from, 0, 0) ) == sizeof(::ndnboost::type_traits::yes_type)
        };
#endif
};

#elif defined(__MWERKS__)
//
// CW works with the technique implemented above for EDG, except when From
// is a function type (or a reference to such a type), in which case
// any_conversion won't be accepted as a valid conversion. We detect this
// exceptional situation and channel it through an alternative algorithm.
//

template <typename From, typename To,bool FromIsFunctionRef>
struct is_convertible_basic_impl_aux;

struct any_conversion
{
    template <typename T> any_conversion(const volatile T&);
    template <typename T> any_conversion(const T&);
    template <typename T> any_conversion(volatile T&);
    template <typename T> any_conversion(T&);
};

template <typename From, typename To>
struct is_convertible_basic_impl_aux<From,To,false /*FromIsFunctionRef*/>
{
    static ::ndnboost::type_traits::no_type NDNBOOST_TT_DECL _m_check(any_conversion ...);
    static ::ndnboost::type_traits::yes_type NDNBOOST_TT_DECL _m_check(To, int);
    typedef typename add_lvalue_reference<From>::type lvalue_type;
    typedef typename add_rvalue_reference<From>::type rvalue_type;
    static lvalue_type _m_from;

#ifndef NDNBOOST_NO_CXX11_RVALUE_REFERENCES
    NDNBOOST_STATIC_CONSTANT(bool, value =
        sizeof( _m_check(static_cast<rvalue_type>(_m_from), 0) ) == sizeof(::ndnboost::type_traits::yes_type)
        );
#else
    NDNBOOST_STATIC_CONSTANT(bool, value =
        sizeof( _m_check(_m_from, 0) ) == sizeof(::ndnboost::type_traits::yes_type)
        );
#endif
};

template <typename From, typename To>
struct is_convertible_basic_impl_aux<From,To,true /*FromIsFunctionRef*/>
{
    static ::ndnboost::type_traits::no_type NDNBOOST_TT_DECL _m_check(...);
    static ::ndnboost::type_traits::yes_type NDNBOOST_TT_DECL _m_check(To);
    typedef typename add_lvalue_reference<From>::type lvalue_type;
    typedef typename add_rvalue_reference<From>::type rvalue_type;
    static lvalue_type _m_from;
#ifndef NDNBOOST_NO_CXX11_RVALUE_REFERENCES
    NDNBOOST_STATIC_CONSTANT(bool, value =
        sizeof( _m_check(static_cast<rvalue_type>(_m_from)) ) == sizeof(::ndnboost::type_traits::yes_type)
        );
#else
    NDNBOOST_STATIC_CONSTANT(bool, value =
        sizeof( _m_check(_m_from) ) == sizeof(::ndnboost::type_traits::yes_type)
        );
#endif
};

template <typename From, typename To>
struct is_convertible_basic_impl:
  is_convertible_basic_impl_aux<
    From,To,
    ::ndnboost::is_function<typename ::ndnboost::remove_reference<From>::type>::value
  >
{};

#else
//
// This version seems to work pretty well for a wide spectrum of compilers,
// however it does rely on undefined behaviour by passing UDT's through (...).
//
template <typename From, typename To>
struct is_convertible_basic_impl
{
    static ::ndnboost::type_traits::no_type NDNBOOST_TT_DECL _m_check(...);
    static ::ndnboost::type_traits::yes_type NDNBOOST_TT_DECL _m_check(To);
    typedef typename add_lvalue_reference<From>::type lvalue_type;
    typedef typename add_rvalue_reference<From>::type rvalue_type;
    static lvalue_type _m_from;
#ifdef NDNBOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4244)
#if NDNBOOST_WORKAROUND(NDNBOOST_MSVC_FULL_VER, >= 140050000)
#pragma warning(disable:6334)
#endif
#endif
#ifndef NDNBOOST_NO_CXX11_RVALUE_REFERENCES
    NDNBOOST_STATIC_CONSTANT(bool, value =
        sizeof( _m_check(static_cast<rvalue_type>(_m_from)) ) == sizeof(::ndnboost::type_traits::yes_type)
        );
#else
    NDNBOOST_STATIC_CONSTANT(bool, value =
        sizeof( _m_check(_m_from) ) == sizeof(::ndnboost::type_traits::yes_type)
        );
#endif
#ifdef NDNBOOST_MSVC
#pragma warning(pop)
#endif
};

#endif // is_convertible_impl

#if defined(__DMC__)
// As before, a static constant sometimes causes errors on Digital Mars.
template <typename From, typename To>
struct is_convertible_impl
{
    enum { value =
        (::ndnboost::type_traits::ice_and<
            ::ndnboost::type_traits::ice_or<
               ::ndnboost::detail::is_convertible_basic_impl<From,To>::value,
               ::ndnboost::is_void<To>::value
            >::value,
            ::ndnboost::type_traits::ice_not<
               ::ndnboost::is_array<To>::value
            >::value,
            ::ndnboost::type_traits::ice_not<
               ::ndnboost::is_function<To>::value
            >::value
        >::value) };
};
#elif !defined(__BORLANDC__) || __BORLANDC__ > 0x551
template <typename From, typename To>
struct is_convertible_impl
{
    NDNBOOST_STATIC_CONSTANT(bool, value =
        (::ndnboost::type_traits::ice_and<
            ::ndnboost::type_traits::ice_or<
               ::ndnboost::detail::is_convertible_basic_impl<From,To>::value,
               ::ndnboost::is_void<To>::value
            >::value,
            ::ndnboost::type_traits::ice_not<
               ::ndnboost::is_array<To>::value
            >::value,
            ::ndnboost::type_traits::ice_not<
               ::ndnboost::is_function<To>::value
            >::value
        >::value)
        );
};
#endif

template <bool trivial1, bool trivial2, bool abstract_target>
struct is_convertible_impl_select
{
   template <class From, class To>
   struct rebind
   {
      typedef is_convertible_impl<From, To> type;
   };
};

template <>
struct is_convertible_impl_select<true, true, false>
{
   template <class From, class To>
   struct rebind
   {
      typedef true_type type;
   };
};

template <>
struct is_convertible_impl_select<false, false, true>
{
   template <class From, class To>
   struct rebind
   {
      typedef false_type type;
   };
};

template <>
struct is_convertible_impl_select<true, false, true>
{
   template <class From, class To>
   struct rebind
   {
      typedef false_type type;
   };
};

template <typename From, typename To>
struct is_convertible_impl_dispatch_base
{
#if !NDNBOOST_WORKAROUND(__HP_aCC, < 60700)
   typedef is_convertible_impl_select<
      ::ndnboost::is_arithmetic<From>::value,
      ::ndnboost::is_arithmetic<To>::value,
#ifndef NDNBOOST_NO_IS_ABSTRACT
      ::ndnboost::is_abstract<To>::value
#else
      false
#endif
   > selector;
#else
   typedef is_convertible_impl_select<false, false, false> selector;
#endif
   typedef typename selector::template rebind<From, To> isc_binder;
   typedef typename isc_binder::type type;
};

template <typename From, typename To>
struct is_convertible_impl_dispatch
   : public is_convertible_impl_dispatch_base<From, To>::type
{};

//
// Now add the full and partial specialisations
// for void types, these are common to all the
// implementation above:
//
#ifndef NDNBOOST_NO_CV_VOID_SPECIALIZATIONS
#   define TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2_PART1(trait,spec1,spec2,value) \
    NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(trait,spec1,spec2,value) \
    NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(trait,spec1,spec2 const,value) \
    NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(trait,spec1,spec2 volatile,value) \
    NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(trait,spec1,spec2 const volatile,value) \
    /**/

#   define TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2(trait,spec1,spec2,value) \
    TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2_PART1(trait,spec1,spec2,value) \
    TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2_PART1(trait,spec1 const,spec2,value) \
    TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2_PART1(trait,spec1 volatile,spec2,value) \
    TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2_PART1(trait,spec1 const volatile,spec2,value) \
    /**/

    TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2(is_convertible,void,void,true)

#   undef TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2
#   undef TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2_PART1

#else
    NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(is_convertible,void,void,true)
#endif // NDNBOOST_NO_CV_VOID_SPECIALIZATIONS

#ifndef NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void,To,false)
NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void,false)
#ifndef NDNBOOST_NO_CV_VOID_SPECIALIZATIONS
NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void const,To,false)
NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void volatile,To,false)
NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void const volatile,To,false)
NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void const,false)
NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void volatile,false)
NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void const volatile,false)
#endif
#endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION

} // namespace detail

NDNBOOST_TT_AUX_BOOL_TRAIT_DEF2(is_convertible,From,To,(::ndnboost::detail::is_convertible_impl_dispatch<From,To>::value))

#else

NDNBOOST_TT_AUX_BOOL_TRAIT_DEF2(is_convertible,From,To,NDNBOOST_IS_CONVERTIBLE(From,To))

#endif

} // namespace ndnboost

#include <ndnboost/type_traits/detail/bool_trait_undef.hpp>

#endif // NDNBOOST_TT_IS_CONVERTIBLE_HPP_INCLUDED


text:
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model common\models\LawsCase */
/* @var $form yii\widgets\ActiveForm */
?>

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'content')->widget('pjkui\kindeditor\KindEditor',['clientOptions'=>['allowFileManager'=>'true','allowUpload'=>'true']]) ?>

    <?= $form->field($model, 'from')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'sort')->textInput(['maxlength' => true]) ?>

    <?//= $form->field($model, 'create_time')->textInput() ?>

<?//= $form->field($model, 'read_count')->textInput() ?>

        <?= Html::submitButton($model->isNewRecord ? '创建' : '更新', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

    <?php ActiveForm::end(); ?>


text:
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <parameters>
        <!--     tabonito   -->
        <parameter key="app.crawler.client.tabonito.class">AppBundle\CrawlerClients\TabonitoClient</parameter>

    </parameters>

    <services>

        <!--   tabonito (code config) -->
        <service id="app.crawler.client.tabonito" class="%app.crawler.client.tabonito.class%">
            <tag name="nz.crawler" />
            <argument>tabonito.pt</argument>
            <argument type="service" id="nz.crawler.matcher.media" />

            <call method="setTargetClass">
                <argument>\Nz\CrawlerBundle\Entity\Crawled</argument>
            </call>

            <call method="setCategoryManager">
                <argument type="service" id="sonata.classification.manager.category" />
            </call>
        </service>

    </services>

</container>


text:
Currently looking for new opportunities!

        <legend>About me</legend>

            I was born in Dallas, Texas but I grew up in Bright, Indiana. I graduated from Indiana University
            and kept moving south until I settled down in St. Petersburg, Florida.  I have been living here since 2001
            and I enjoy living the Florida life of sand volleyball, fishing, camping,
            and outdoor adventuring.

        <legend>Career Goals</legend>

            I love programming! It's always good to have a job where you love what you are doing.
            It is always a great feeling to be able to write applications that people love to use,
            and enriches them in some professional or personal way. I want to continue to mature as a developer
            and some day, create that "next big app".

            My Resume

        <legend>Favorite Quote</legend>

                Artificial intelligence is no match for natural stupidity.

        <legend>Favorite Poem</legend>

                Walk to the edge.

                listen hard.

                practice wellness.

                Play with abandon.

                l a u g h.

                choose with no regret.

                continue to Learn.

                appreciate your friends.

                    do what

                    you love.

                live as if this is all there is.

            Mary Radmacher


text:
__author__ = 'sabin'

## reads the number and tell the number of lines in the file.

import gzip, sys
filename = sys.argv[1]

def reading_txtFile(filename):
    txtFile = open(filename, 'r')
    line_number = sum(1 for line in txtFile)
    print " Determining numbers of lines in the file ..."
    print " number of lines in ", filename, " is : \n", line_number
    txtFile.close()

def reading_gzfile(filename):
    gzFile = gzip.open(filename, 'rb')
    line_number = sum(1 for line in gzFile)
    print " "
    print " rDetermining numbers of lines in the file ..."
    print " number of lines in ", filename, " is : \n", line_number
    gzFile.close()

if filename.endswith('.txt'):
 reading_txtFile(filename)
else:
 reading_gzfile(filename)


text:
function rcube_mail_ui()
{
  var env = {};
  var popups = {};
  var popupconfig = {
    forwardmenu:        { editable:1 },
    searchmenu:         { editable:1, callback:searchmenu },
    listoptions:        { editable:1 },
    dragmessagemenu:    { sticky:1 },
    groupmenu:          { above:1 },
    mailboxmenu:        { above:1 },
    spellmenu:          { callback: spellmenu },
    // toggle: #1486823, #1486930
    'attachment-form':  { editable:1, above:1, toggle:!bw.ie&&!bw.linux },
    'upload-form':      { editable:1, toggle:!bw.ie&&!bw.linux }
  };

  var me = this;
  var mailviewsplit;
  var compose_headers = {};

  // export public methods
  this.set = setenv;
  this.init = init;
  this.init_tabs = init_tabs;
  this.show_about = show_about;
  this.show_popup = show_popup;
  this.set_searchmod = set_searchmod;
  this.show_uploadform = show_uploadform;
  this.show_header_row = show_header_row;
  this.hide_header_row = hide_header_row;

  // set minimal mode on small screens (don't wait for document.ready)
  if (window.$ && document.body) {
    var minmode = rcmail.get_cookie('minimalmode');
    if (parseInt(minmode) || (minmode === null && $(window).height() < 850)) {
      $(document.body).addClass('minimal');
    }

    if (bw.tablet) {
      $('#viewport').attr('content', "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0");
    }
  }

  /**
   *
   */
  function setenv(key, val)
  {
    env[key] = val;
  }

  /**
   * Initialize UI
   * Called on document.ready
   */
  function init()
  {
    rcmail.addEventListener('message', message_displayed);

    /*** prepare minmode functions ***/
    $('#taskbar a').each(function(i,elem){
      $(elem).append('' + $('.button-inner', this).html() + '')
    });

    $('#taskbar .minmodetoggle').click(function(e){
      var ismin = $(document.body).toggleClass('minimal').hasClass('minimal');
      rcmail.set_cookie('minimalmode', ismin?1:0);
      $(window).resize();
    });

    /***  mail task  ***/
    if (rcmail.env.task == 'mail') {
      rcmail.addEventListener('menu-open', show_listoptions);
      rcmail.addEventListener('menu-save', save_listoptions);
      rcmail.addEventListener('responseafterlist', function(e){ switch_view_mode(rcmail.env.threading ? 'thread' : 'list') });

      var dragmenu = $('#dragmessagemenu');
      if (dragmenu.length) {
        rcmail.gui_object('message_dragmenu', 'dragmessagemenu');
        popups.dragmessagemenu = dragmenu;
      }

      if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') {
        rcmail.addEventListener('aftershow-headers', function() { layout_messageview(); });
        rcmail.addEventListener('afterhide-headers', function() { layout_messageview(); });
        $('#previewheaderstoggle').click(function(e){ toggle_preview_headers(this); return false });
      }
      else if (rcmail.env.action == 'compose') {
        rcmail.addEventListener('aftertoggle-editor', function(){ window.setTimeout(function(){ layout_composeview() }, 200); });
        rcmail.addEventListener('aftersend-attachment', show_uploadform);
        rcmail.addEventListener('add-recipient', function(p){ show_header_row(p.field, true); });
        layout_composeview();

        // Show input elements with non-empty value
        var field, fields = ['cc', 'bcc', 'replyto', 'followupto'];
        for (var f=0; f < fields.length; f++) {
          if ((field = $('#_'+fields[f])) && field.length && field.val() != '')
            show_header_row(fields[f], true);
        }

        $('#composeoptionstoggle').click(function(){
          $('#composeoptionstoggle').toggleClass('remove');
          $('#composeoptions').toggle();
          layout_composeview();
          return false;
        }).css('cursor', 'pointer');

        // toggle compose options if opened in new window and they were visible before
        var opener_rc = rcmail.opener();
        if (opener_rc && opener_rc.env.action == 'compose' && $('#composeoptionstoggle', opener.document).hasClass('remove'))
          $('#composeoptionstoggle').click();

        new rcube_splitter({ id:'composesplitterv', p1:'#composeview-left', p2:'#composeview-right',
          orientation:'v', relative:true, start:248, min:170, size:12, render:layout_composeview }).init();
      }
      else if (rcmail.env.action == 'list' || !rcmail.env.action) {
        var previewframe = $('#mailpreviewframe').is(':visible');
        $('#mailpreviewtoggle').addClass(previewframe ? 'enabled' : 'closed').click(function(e){ toggle_preview_pane(e); return false });
        $('#maillistmode').addClass(rcmail.env.threading ? '' : 'selected').click(function(e){ switch_view_mode('list'); return false });
        $('#mailthreadmode').addClass(rcmail.env.threading ? 'selected' : '').click(function(e){ switch_view_mode('thread'); return false });

        mailviewsplit = new rcube_splitter({ id:'mailviewsplitter', p1:'#mailview-top', p2:'#mailview-bottom',
          orientation:'h', relative:true, start:310, min:150, size:12, offset:4 });
        if (previewframe)
          mailviewsplit.init();

        new rcube_scroller('#folderlist-content', '#folderlist-header', '#folderlist-footer');

        rcmail.addEventListener('setquota', update_quota);
      }

      if ($('#mailview-left').length) {
        new rcube_splitter({ id:'mailviewsplitterv', p1:'#mailview-left', p2:'#mailview-right',
          orientation:'v', relative:true, start:226, min:150, size:12, callback:render_mailboxlist, render:resize_leftcol }).init();
      }
    }
    /***  settings task  ***/
    else if (rcmail.env.task == 'settings') {
      rcmail.addEventListener('init', function(){
        var tab = '#settingstabpreferences';
        if (rcmail.env.action)
          tab = '#settingstab' + (rcmail.env.action.indexOf('identity')>0 ? 'identities' : rcmail.env.action.replace(/\./g, ''));

        $(tab).addClass('selected')
          .children().first().removeAttr('onclick').click(function() { return false; });
      });

      if (rcmail.env.action == 'folders') {
        new rcube_splitter({ id:'folderviewsplitter', p1:'#folderslist', p2:'#folder-details',
          orientation:'v', relative:true, start:266, min:180, size:12 }).init();

        new rcube_scroller('#folderslist-content', '#folderslist-header', '#folderslist-footer');

        rcmail.addEventListener('setquota', update_quota);
      }
      else if (rcmail.env.action == 'identities') {
        new rcube_splitter({ id:'identviewsplitter', p1:'#identitieslist', p2:'#identity-details',
          orientation:'v', relative:true, start:266, min:180, size:12 }).init();
      }
      else if (rcmail.env.action == 'preferences' || !rcmail.env.action) {
        new rcube_splitter({ id:'prefviewsplitter', p1:'#sectionslist', p2:'#preferences-box',
          orientation:'v', relative:true, start:266, min:180, size:12 }).init();
      }
    }
    /***  addressbook task  ***/
    else if (rcmail.env.task == 'addressbook') {
      rcmail.addEventListener('afterupload-photo', show_uploadform);

      if (rcmail.env.action == '') {
        new rcube_splitter({ id:'addressviewsplitterd', p1:'#addressview-left', p2:'#addressview-right',
          orientation:'v', relative:true, start:226, min:150, size:12, render:resize_leftcol }).init();
        new rcube_splitter({ id:'addressviewsplitter', p1:'#addresslist', p2:'#contacts-box',
          orientation:'v', relative:true, start:286, min:270, size:12 }).init();

        new rcube_scroller('#directorylist-content', '#directorylist-header', '#directorylist-footer');
      }
    }

    // set min-width to show all toolbar buttons
    var screen = $('.minwidth');
    if (screen.length) {
      screen.css('min-width', $('.toolbar').width() + $('#quicksearchbar').parent().width() + 20);
    }

    // turn a group of fieldsets into tabs
    $('.tabbed').each(function(idx, elem){ init_tabs(elem); })

    // decorate select elements
    $('select.decorated').each(function(){
      if (bw.opera) {
        $(this).removeClass('decorated');
        return;
      }

      var select = $(this),
        height = Math.max(select.height(), 26) - 2,
        width = select.width() - 22,
        title = $('option', this).first().text();

      if ($('option:selected', this).val() != '')
        title = $('option:selected', this).text();

      var overlay = $('' + title + '')
        .css('position', 'absolute')
        .offset(select.position())
        .insertAfter(select);

      overlay.children().width(width).height(height).css('line-height', (height - 1) + 'px');

      select.change(function() {
          var val = $('option:selected', this).text();
          $(this).next().children().html(val);
        });

      var parent = select.parent();
      if (parent.css('position') != 'absolute')
        parent.css('position', 'relative');

      // re-set original select width to fix click action and options width in some browsers
      select.width(overlay.width());
    });

    $(document.body)
      .bind('mouseup', body_mouseup)
      .bind('keyup', function(e){
        if (e.keyCode == 27) {
          for (var id in popups) {
            if (popups[id].is(':visible'))
              show_popup(id, false);
          }
        }
      });

    $('iframe').load(function(e){
      // this = iframe
      try {
        var doc = this.contentDocument ? this.contentDocument : this.contentWindow ? this.contentWindow.document : null;
        $(doc).mouseup(body_mouseup);
      }
      catch (e) {
        // catch possible "Permission denied" error in IE
      };
    })
    .contents().mouseup(body_mouseup);

    // don't use $(window).resize() due to some unwanted side-effects
    window.onresize = resize;
    resize();
  }

  /**
   * Handler for mouse-up events on the document body.
   * This will close all open popup menus
   */
  function body_mouseup(e)
  {
    var config, obj, target = e.target;
    if (target.className == 'inner')
        target = e.target.parentNode;
    for (var id in popups) {
      obj = popups[id];
      config = popupconfig[id];
      if (obj.is(':visible')
        && target.id != id+'link'
        && !config.toggle
        && (!config.editable || !target_overlaps(target, obj.get(0)))
        && (!config.sticky || !rcube_mouse_is_over(e, obj.get(0)))
      ) {
        var myid = id+'';
        window.setTimeout(function(){ show_popupmenu(myid, false) }, 10);
      }
    }
  }

  /**
   * Update UI on window resize
   */
  function resize()
  {
    if (rcmail.env.task == 'mail') {
      if (rcmail.env.action == 'show' || rcmail.env.action == 'preview')
        layout_messageview();
      else if (rcmail.env.action == 'compose')
        layout_composeview();
    }

    // make iframe footer buttons float if scrolling is active
    $('body.iframe .footerleft').each(function(){
      var footer = $(this),
        body = $(document.body),
        floating = footer.hasClass('floating'),
        overflow = body.outerHeight(true) > $(window).height();

      if (overflow != floating) {
        var action = overflow ? 'addClass' : 'removeClass';
        footer[action]('floating');
        body[action]('floatingbuttons');
      }
    });
  }

  /**
   * Triggered when a new user message is displayed
   */
  function message_displayed(p)
  {
    // show a popup dialog on errors
    if (p.type == 'error' && rcmail.env.task != 'login') {
      if (me.message_timer) {
        window.clearTimeout(me.message_timer);
      }
      if (!me.messagedialog) {
        me.messagedialog = $('
').addClass('popupdialog').hide();
      }

      var msg = p.message,
        pos = $(p.object).offset();
      pos.top -= (rcmail.env.task == 'login' ? 20 : 160);

      if (me.messagedialog.is(':visible'))
        msg = me.messagedialog.html() + '
' + p.message + '
';

      me.messagedialog.html(msg)
        .dialog({
          resizable: false,
          closeOnEscape: true,
          dialogClass: 'popupmessage ' + p.type,
          title: env.errortitle,
          close: function() {
            me.messagedialog.dialog('destroy').hide();
          },
          position: ['center', pos.top],
          hide: { effect:'drop', direction:'down' },
          width: 420,
          minHeight: 90
        }).show();

      me.message_timer = window.setTimeout(function(){ me.messagedialog.dialog('close'); }, Math.max(2000, p.timeout / 2));
    }
  }

  /**
   * Adjust UI objects of the mail view screen
   */
  function layout_messageview()
  {
    $('#messagecontent').css('top', ($('#messageheader').outerHeight() + 1) + 'px');
    $('#message-objects div a').addClass('button');

    if (!$('#attachment-list li').length) {
      $('div.rightcol').hide();
      $('div.leftcol').css('margin-right', '0');
    }
  }

  function render_mailboxlist(splitter)
  {
    // TODO: implement smart shortening of long folder names
  }

  function resize_leftcol(splitter)
  {
    // STUB
  }

  function layout_composeview()
  {
    var body = $('#composebody'),
      form = $('#compose-content'),
      bottom = $('#composeview-bottom'),
      w, h, bh, ovflw, btns = 0,
      minheight = 300,

    bh = (form.height() - bottom.position().top);
    ovflw = minheight - bh;
    btns = ovflw > -100 ? 0 : 40;
    bottom.css('height', Math.max(minheight, bh) + 'px');
    form.css('overflow', ovflw > 0 ? 'auto' : 'hidden');

    w = body.parent().width() - 5;
    h = body.parent().height() - 16;
    body.width(w).height(h);

    $('#composebody_tbl').width((w+8)+'px').height('').css('margin-top', '1px');
    $('#composebody_ifr').width((w+8)+'px').height((h-40)+'px');
    $('#googie_edit_layer').height(h+'px');
//    $('#composebodycontainer')[(btns ? 'addClass' : 'removeClass')]('buttons');
//    $('#composeformbuttons')[(btns ? 'show' : 'hide')]();

    var abooks = $('#directorylist');
    $('#compose-contacts .scroller').css('top', abooks.position().top + abooks.outerHeight());
  }

  function update_quota(p)
  {
    var step = 24, step_count = 20,
      y = p.total ? Math.ceil(p.percent / 100 * step_count) * step : 0;

    // never show full-circle if quota is close to 100% but below.
    if (p.total && y == step * step_count && p.percent < 100)
      y -= step;

    $('#quotadisplay').css('background-position', '0 -'+y+'px');
  }

  /**
   * Trigger for popup menus
   */
  function show_popup(popup, show, config)
  {
    // auto-register menu object
    if (config || !popupconfig[popup])
      popupconfig[popup] = $.extend(popupconfig[popup] || {}, config);

    var visible = show_popupmenu(popup, show),
      config = popupconfig[popup];
    if (typeof config.callback == 'function')
      config.callback(visible);
  }

  /**
   * Show/hide a specific popup menu
   */
  function show_popupmenu(popup, show)
  {
    var obj = popups[popup],
      config = popupconfig[popup],
      ref = $('#'+popup+'link'),
      above = config.above;

    if (!obj) {
      obj = popups[popup] = $('#'+popup);
      obj.appendTo(document.body);  // move them to top for proper absolute positioning
    }

    if (!obj || !obj.length)
      return false;

    if (typeof show == 'undefined')
      show = obj.is(':visible') ? false : true;
    else if (config.toggle && show && obj.is(':visible'))
      show = false;

    if (show && ref) {
      var parent = ref.parent(),
        win = $(window),
        pos;

      if (parent.hasClass('dropbutton'))
        ref = parent;

      pos = ref.offset();
      ref.offsetHeight = ref.outerHeight();
      if (!above && pos.top + ref.offsetHeight + obj.height() > win.height())
        above = true;
      if (pos.left + obj.width() > win.width())
        pos.left = win.width() - obj.width() - 12;

      obj.css({ left:pos.left, top:(pos.top + (above ? -obj.height() : ref.offsetHeight)) });
    }

    obj[show?'show':'hide']();

    // hide drop-down elements on buggy browsers
    if (bw.ie6 && config.overlap) {
      $('select').css('visibility', show?'hidden':'inherit');
      $('select', obj).css('visibility', 'inherit');
    }

    return show;
  }

  /**
   *
   */
  function target_overlaps(target, elem)
  {
    while (target.parentNode) {
      if (target.parentNode == elem)
        return true;
      target = target.parentNode;
    }
    return false;
  }

  /**
   * Show/hide the preview pane
   */
  function toggle_preview_pane(e)
  {
    var button = $(e.target),
      frame = $('#mailpreviewframe'),
      visible = !frame.is(':visible'),
      splitter = mailviewsplit.pos || parseInt(rcmail.get_cookie('mailviewsplitter') || 320),
      topstyles, bottomstyles, uid;

    frame.toggle();
    button.removeClass().addClass(visible ? 'enabled' : 'closed');

    if (visible) {
      $('#mailview-top').removeClass('fullheight').css({ bottom:'auto' });
      $('#mailview-bottom').css({ height:'auto' });

      rcmail.env.contentframe = 'messagecontframe';
      if (uid = rcmail.message_list.get_single_selection())
        rcmail.show_message(uid, false, true);

      // let the splitter set the correct size and position
      if (mailviewsplit.handle) {
        mailviewsplit.handle.show();
        mailviewsplit.resize();
      }
      else
        mailviewsplit.init();
    }
    else {
      rcmail.env.contentframe = null;
      rcmail.show_contentframe(false);

      $('#mailview-top').addClass('fullheight').css({ height:'auto', bottom:'28px' });
      $('#mailview-bottom').css({ top:'auto', height:'26px' });

      if (mailviewsplit.handle)
        mailviewsplit.handle.hide();
    }

    if (visible && uid && rcmail.message_list)
      rcmail.message_list.scrollto(uid);

    rcmail.command('save-pref', { name:'preview_pane', value:(visible?1:0) });
  }

  /**
   * Switch between short and full headers display in message preview
   */
  function toggle_preview_headers(button)
  {
    $('#preview-shortheaders').toggle();
    var full = $('#preview-allheaders').toggle(),
      button = $('a#previewheaderstoggle');

    // add toggle button to full headers table
    if (full.is(':visible'))
      button.attr('href', '#hide').removeClass('add').addClass('remove')
    else
      button.attr('href', '#details').removeClass('remove').addClass('add')
  }

  /**
   *
   */
  function switch_view_mode(mode)
  {
    if (rcmail.env.threading != (mode == 'thread'))
      rcmail.set_list_options(null, undefined, undefined, mode == 'thread' ? 1 : 0);

    $('#maillistmode, #mailthreadmode').removeClass('selected');
    $('#mail'+mode+'mode').addClass('selected');
  }

  /**** popup callbacks ****/

  function searchmenu(show)
  {
    if (show && rcmail.env.search_mods) {
      var n, all,
        obj = popups['searchmenu'],
        list = $('input:checkbox[name="s_mods[]"]', obj),
        mbox = rcmail.env.mailbox,
        mods = rcmail.env.search_mods;

      if (rcmail.env.task == 'mail') {
        mods = mods[mbox] ? mods[mbox] : mods['*'];
        all = 'text';
      }
      else {
        all = '*';
      }

      if (mods[all])
        list.map(function() {
          this.checked = true;
          this.disabled = this.value != all;
        });
      else {
        list.prop('disabled', false).prop('checked', false);
        for (n in mods)
          $('#s_mod_' + n).prop('checked', true);
      }
    }
  }

  function spellmenu(show)
  {
    var link, li,
      lang = rcmail.spellcheck_lang(),
      menu = popups.spellmenu,
      ul = $('ul', menu);

    if (!ul.length) {
      ul = $('
');

      for (i in rcmail.env.spell_langs) {
        li = $('
');
        link = $('').text(rcmail.env.spell_langs[i])
          .addClass('active').data('lang', i)
          .click(function() {
            rcmail.spellcheck_lang_set($(this).data('lang'));
          });

        link.appendTo(li);
        li.appendTo(ul);
      }

      ul.appendTo(menu);
    }

    // select current language
    $('li', ul).each(function() {
      var el = $('a', this);
      if (el.data('lang') == lang)
        el.addClass('selected');
      else if (el.hasClass('selected'))
        el.removeClass('selected');
    });
  }

  /**
   *
   */
  function show_listoptions()
  {
    var $dialog = $('#listoptions');

    // close the dialog
    if ($dialog.is(':visible')) {
      $dialog.dialog('close');
      return;
    }

    // set form values
    $('input[name="sort_col"][value="'+rcmail.env.sort_col+'"]').prop('checked', true);
    $('input[name="sort_ord"][value="DESC"]').prop('checked', rcmail.env.sort_order == 'DESC');
    $('input[name="sort_ord"][value="ASC"]').prop('checked', rcmail.env.sort_order != 'DESC');

    // set checkboxes
    $('input[name="list_col[]"]').each(function() {
      $(this).prop('checked', $.inArray(this.value, rcmail.env.coltypes) != -1);
    });

    $dialog.dialog({
      modal: true,
      resizable: false,
      closeOnEscape: true,
      title: null,
      close: function() {
        $dialog.dialog('destroy').hide();
      },
      width: 650
    }).show();
  }

  /**
   *
   */
  function save_listoptions()
  {
    $('#listoptions').dialog('close');

    var sort = $('input[name="sort_col"]:checked').val(),
      ord = $('input[name="sort_ord"]:checked').val(),
      cols = $('input[name="list_col[]"]:checked')
        .map(function(){ return this.value; }).get();

    rcmail.set_list_options(cols, sort, ord, rcmail.env.threading);
  }

  /**
   *
   */
  function set_searchmod(elem)
  {
    var all, m, task = rcmail.env.task,
      mods = rcmail.env.search_mods,
      mbox = rcmail.env.mailbox;

    if (!mods)
      mods = {};

    if (task == 'mail') {
      if (!mods[mbox])
        mods[mbox] = rcube_clone_object(mods['*']);
      m = mods[mbox];
      all = 'text';
    }
    else { //addressbook
      m = mods;
      all = '*';
    }

    if (!elem.checked)
      delete(m[elem.value]);
    else
      m[elem.value] = 1;

    // mark all fields
    if (elem.value != all)
      return;

    $('input:checkbox[name="s_mods[]"]').map(function() {
      if (this == elem)
        return;

      this.checked = true;
      if (elem.checked) {
        this.disabled = true;
        delete m[this.value];
      }
      else {
        this.disabled = false;
        m[this.value] = 1;
      }
    });
  }

  function show_uploadform()
  {
    var $dialog = $('#upload-dialog');

    // close the dialog
    if ($dialog.is(':visible')) {
      $dialog.dialog('close');
      return;
    }

    // add icons to clone file input field
    if (rcmail.env.action == 'compose' && !$dialog.data('extended')) {
      $('')
        .addClass('iconlink add')
        .attr('href', '#add')
        .html('Add')
        .appendTo($('input[type="file"]', $dialog).parent())
        .click(add_uploadfile);
      $dialog.data('extended', true);
    }

    $dialog.dialog({
      modal: true,
      resizable: false,
      closeOnEscape: true,
      title: $dialog.attr('title'),
      close: function() {
        try { $('#upload-dialog form').get(0).reset(); }
        catch(e){ }  // ignore errors

        $dialog.dialog('destroy').hide();
        $('div.addline', $dialog).remove();
      },
      width: 480
    }).show();

    if (!document.all)
      $('input[type=file]', $dialog).first().click();
  }

  function add_uploadfile(e)
  {
    var div = $(this).parent();
    var clone = div.clone().addClass('addline').insertAfter(div);
    clone.children('.iconlink').click(add_uploadfile);
    clone.children('input').val('');

    if (!document.all)
      $('input[type=file]', clone).click();
  }

  /**
   *
   */
  function show_header_row(which, updated)
  {
    var row = $('#compose-' + which);
    if (row.is(':visible'))
      return;  // nothing to be done here

    if (compose_headers[which] && !updated)
      $('#_' + which).val(compose_headers[which]);

    row.show();
    $('#' + which + '-link').hide();
    layout_composeview();
    return false;
  }

  /**
   *
   */
  function hide_header_row(which)
  {
    // copy and clear field value
    var field = $('#_' + which);
    compose_headers[which] = field.val();
    field.val('');

    $('#compose-' + which).hide();
    $('#' + which + '-link').show();
    layout_composeview();
    return false;
  }

  /**
   * Fieldsets-to-tabs converter
   */
  function init_tabs(elem, current)
  {
    var content = $(elem),
      id = content.get(0).id,
      fs = content.children('fieldset');

    if (!fs.length)
      return;

    if (!id) {
      id = 'rcmtabcontainer';
      content.attr('id', id);
    }

    // first hide not selected tabs
    current = current || 0;
    fs.each(function(idx) { if (idx != current) $(this).hide(); });

    // create tabs container
    var tabs = $('
').addClass('tabsbar').prependTo(content);

    // convert fildsets into tabs
    fs.each(function(idx) {
      var tab, a, elm = $(this), legend = elm.children('legend');

      // create a tab
      a   = $('').text(legend.text()).attr('href', '#');
      tab = $('').attr({'id': 'tab'+idx, 'class': 'tablink'})
        .click(function() { show_tab(id, idx); return false })

      // remove legend
      legend.remove();
      // style fieldset
      elm.addClass('tab');
      // style selected tab
      if (idx == current)
        tab.addClass('selected');

      // add the tab to container
      tab.append(a).appendTo(tabs);
    });
  }

  function show_tab(id, index)
  {
    var fs = $('#'+id).children('fieldset');

    fs.each(function(idx) {
      // Show/hide fieldset (tab content)
      $(this)[index==idx ? 'show' : 'hide']();
      // Select/unselect tab
      $('#tab'+idx).toggleClass('selected', idx==index);
    });

    resize();
  }

  /**
   * Show about page as jquery UI dialog
   */
  function show_about(elem)
  {
    var frame = $('').attr('id', 'aboutframe')
      .attr('src', rcmail.url('settings/about'))
      .attr('frameborder', '0')
      .appendTo(document.body);

    var h = Math.floor($(window).height() * 0.75);
    var buttons = {};
    var supportln = $('#supportlink');
    if (supportln.length && (env.supporturl = supportln.attr('href')))
      buttons[supportln.html()] = function(e){ env.supporturl.indexOf('mailto:') < 0 ? window.open(env.supporturl) : location.href = env.supporturl };

    frame.dialog({
      modal: true,
      resizable: false,
      closeOnEscape: true,
      title: elem ? elem.title || elem.innerHTML : null,
      close: function() {
        frame.dialog('destroy').remove();
      },
      buttons: buttons,
      width: 640,
      height: h
    }).width(640);
  }
}

/**
 * Roundcube Scroller class
 */
function rcube_scroller(list, top, bottom)
{
  var ref = this;

  this.list = $(list);
  this.top = $(top);
  this.bottom = $(bottom);
  this.step_size = 6;
  this.step_time = 20;
  this.delay = 500;

  this.top
    .mouseenter(function() { if (rcmail.drag_active) ref.ts = window.setTimeout(function() { ref.scroll('down'); }, ref.delay); })
    .mouseout(function() { if (ref.ts) window.clearTimeout(ref.ts); });

  this.bottom
    .mouseenter(function() { if (rcmail.drag_active) ref.ts = window.setTimeout(function() { ref.scroll('up'); }, ref.delay); })
    .mouseout(function() { if (ref.ts) window.clearTimeout(ref.ts); });

  this.scroll = function(dir)
  {
    var ref = this, size = this.step_size;

    if (!rcmail.drag_active)
      return;

    if (dir == 'down')
      size *= -1;

    this.list.get(0).scrollTop += size;
    this.ts = window.setTimeout(function() { ref.scroll(dir); }, this.step_time);
  };
};

/**
 * Roundcube UI splitter class
 *
 * @constructor
 */
function rcube_splitter(p)
{
  this.p = p;
  this.id = p.id;
  this.horizontal = (p.orientation == 'horizontal' || p.orientation == 'h');
  this.halfsize = (p.size !== undefined ? p.size : 10) / 2;
  this.pos = p.start || 0;
  this.min = p.min || 20;
  this.offset = p.offset || 0;
  this.relative = p.relative ? true : false;
  this.drag_active = false;
  this.render = p.render;
  this.callback = p.callback;

  var me = this;
  rcube_splitter._instances[this.id] = me;

  this.init = function()
  {
    this.p1 = $(this.p.p1);
    this.p2 = $(this.p.p2);

    // check if referenced elements exist, otherwise abort
    if (!this.p1.length || !this.p2.length)
      return;

    // create and position the handle for this splitter
    this.p1pos = this.relative ? this.p1.position() : this.p1.offset();
    this.p2pos = this.relative ? this.p2.position() : this.p2.offset();
    this.handle = $('
')
      .attr('id', this.id)
      .attr('unselectable', 'on')
      .addClass('splitter ' + (this.horizontal ? 'splitter-h' : 'splitter-v'))
      .appendTo(this.p1.parent())
      .bind('mousedown', onDragStart);

    if (this.horizontal) {
      var top = this.p1pos.top + this.p1.outerHeight();
      this.handle.css({ left:'0px', top:top+'px' });
    }
    else {
      var left = this.p1pos.left + this.p1.outerWidth();
      this.handle.css({ left:left+'px', top:'0px' });
    }

    // listen to window resize on IE
    if (bw.ie)
      $(window).resize(onResize);

    // read saved position from cookie
    var cookie = rcmail.get_cookie(this.id);
    if (cookie && !isNaN(cookie)) {
      this.pos = parseFloat(cookie);
      this.resize();
    }
    else if (this.pos) {
      this.resize();
      this.set_cookie();
    }
  };

  /**
   * Set size and position of all DOM objects
   * according to the saved splitter position
   */
  this.resize = function()
  {
    if (this.horizontal) {
      this.p1.css('height', Math.floor(this.pos - this.p1pos.top - this.halfsize) + 'px');
      this.p2.css('top', Math.ceil(this.pos + this.halfsize + 2) + 'px');
      this.handle.css('top', Math.round(this.pos - this.halfsize + this.offset)+'px');
      if (bw.ie) {
        var new_height = parseInt(this.p2.parent().outerHeight(), 10) - parseInt(this.p2.css('top'), 10) - (bw.ie8 ? 2 : 0);
        this.p2.css('height', (new_height > 0 ? new_height : 0) + 'px');
      }
    }
    else {
      this.p1.css('width', Math.floor(this.pos - this.p1pos.left - this.halfsize) + 'px');
      this.p2.css('left', Math.ceil(this.pos + this.halfsize) + 'px');
      this.handle.css('left', Math.round(this.pos - this.halfsize + this.offset + 3)+'px');
      if (bw.ie) {
        var new_width = parseInt(this.p2.parent().outerWidth(), 10) - parseInt(this.p2.css('left'), 10) ;
        this.p2.css('width', (new_width > 0 ? new_width : 0) + 'px');
      }
    }

    this.p2.resize();
    this.p1.resize();

    // also resize iframe covers
    if (this.drag_active) {
      $('iframe').each(function(i, elem) {
        var pos = $(this).offset();
        $('#iframe-splitter-fix-'+i).css({ top: pos.top+'px', left: pos.left+'px', width:elem.offsetWidth+'px', height: elem.offsetHeight+'px' });
      });
    }

    if (typeof this.render == 'function')
      this.render(this);
  };

  /**
   * Handler for mousedown events
   */
  function onDragStart(e)
  {
    // disable text selection while dragging the splitter
    if (bw.konq || bw.chrome || bw.safari)
      document.body.style.webkitUserSelect = 'none';

    me.p1pos = me.relative ? me.p1.position() : me.p1.offset();
    me.p2pos = me.relative ? me.p2.position() : me.p2.offset();
    me.drag_active = true;

    // start listening to mousemove events
    $(document).bind('mousemove.'+this.id, onDrag).bind('mouseup.'+this.id, onDragStop);

    // enable dragging above iframes
    $('iframe').each(function(i, elem) {
      $('
')
        .attr('id', 'iframe-splitter-fix-'+i)
        .addClass('iframe-splitter-fix')
        .css({ background: '#fff',
          width: elem.offsetWidth+'px', height: elem.offsetHeight+'px',
          position: 'absolute', opacity: '0.001', zIndex: 1000
        })
        .css($(this).offset())
        .appendTo('body');
      });
  };

  /**
   * Handler for mousemove events
   */
  function onDrag(e)
  {
    if (!me.drag_active)
      return false;

    var pos = rcube_event.get_mouse_pos(e);

    if (me.relative) {
      var parent = me.p1.parent().offset();
      pos.x -= parent.left;
      pos.y -= parent.top;
    }

    if (me.horizontal) {
      if (((pos.y - me.halfsize) > me.p1pos.top) && ((pos.y + me.halfsize) < (me.p2pos.top + me.p2.outerHeight()))) {
        me.pos = Math.max(me.min, pos.y - me.offset);
        me.resize();
      }
    }
    else {
      if (((pos.x - me.halfsize) > me.p1pos.left) && ((pos.x + me.halfsize) < (me.p2pos.left + me.p2.outerWidth()))) {
        me.pos = Math.max(me.min, pos.x - me.offset);
        me.resize();
      }
    }

    me.p1pos = me.relative ? me.p1.position() : me.p1.offset();
    me.p2pos = me.relative ? me.p2.position() : me.p2.offset();
    return false;
  };

  /**
   * Handler for mouseup events
   */
  function onDragStop(e)
  {
    // resume the ability to highlight text
    if (bw.konq || bw.chrome || bw.safari)
      document.body.style.webkitUserSelect = 'auto';

    // cancel the listening for drag events
    $(document).unbind('.'+me.id);
    me.drag_active = false;

    // remove temp divs
    $('div.iframe-splitter-fix').remove();

    me.set_cookie();

    if (typeof me.callback == 'function')
      me.callback(me);

    return bw.safari ? true : rcube_event.cancel(e);
  };

  /**
   * Handler for window resize events
   */
  function onResize(e)
  {
    if (me.horizontal) {
      var new_height = parseInt(me.p2.parent().outerHeight(), 10) - parseInt(me.p2[0].style.top, 10) - (bw.ie8 ? 2 : 0);
      me.p2.css('height', (new_height > 0 ? new_height : 0) +'px');
    }
    else {
      var new_width = parseInt(me.p2.parent().outerWidth(), 10) - parseInt(me.p2[0].style.left, 10);
      me.p2.css('width', (new_width > 0 ? new_width : 0) + 'px');
    }
  };

  /**
   * Saves splitter position in cookie
   */
  this.set_cookie = function()
  {
    var exp = new Date();
    exp.setYear(exp.getFullYear() + 1);
    rcmail.set_cookie(this.id, this.pos, exp);
  };

} // end class rcube_splitter

// static getter for splitter instances
rcube_splitter._instances = {};

rcube_splitter.get_instance = function(id)
{
  return rcube_splitter._instances[id];
};


text:
import React from 'react';
import PropTypes from 'prop-types';
import TableCell from '@material-ui/core/TableCell';
import TimeCell from './TimeCell';

export default function FactCheckPublishedAtCell({ projectMedia }) {
  const timestamp = projectMedia.list_columns_values.fact_check_published_on;
  if (timestamp === 0) {
    return <TableCell>-</TableCell>;
  }
  return <TimeCell unixTimestampInS={timestamp} />;
}

FactCheckPublishedAtCell.propTypes = {
  projectMedia: PropTypes.shape({
    list_columns_values: PropTypes.shape({
      fact_check_published_on: PropTypes.number.isRequired,
    }).isRequired,
  }).isRequired,
};


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

package org.chromium.base;

import static android.content.Context.UI_MODE_SERVICE;

import android.app.UiModeManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Build;
import android.text.TextUtils;

import androidx.annotation.OptIn;
import androidx.annotation.VisibleForTesting;
import androidx.core.os.BuildCompat;

import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.compat.ApiHelperForP;
import org.chromium.build.BuildConfig;

/**
 * BuildInfo is a utility class providing easy access to {@link PackageInfo} information. This is
 * primarily of use for accessing package information from native code.
 */
public class BuildInfo {
    private static final String TAG = "BuildInfo";
    private static final int MAX_FINGERPRINT_LENGTH = 128;

    private static PackageInfo sBrowserPackageInfo;
    private static ApplicationInfo sBrowserApplicationInfo;
    private static boolean sInitialized;

    /** Not a member variable to avoid creating the instance early (it is set early in start up). */
    private static String sFirebaseAppId = "";

    /** The application name (e.g. "Chrome"). For WebView, this is name of the embedding app. */
    public final String hostPackageLabel;
    /** By default: same as versionCode. For WebView: versionCode of the embedding app. */
    public final long hostVersionCode;
    /** The packageName of Chrome/WebView. Use application context for host app packageName. */
    public final String packageName;
    /** The versionCode of the apk. */
    public final long versionCode;
    /** The versionName of Chrome/WebView. Use application context for host app versionName. */
    public final String versionName;
    /** Result of PackageManager.getInstallerPackageName(). Never null, but may be "". */
    public final String installerPackageName;
    /** The versionCode of Play Services (for crash reporting). */
    public final String gmsVersionCode;
    /** Formatted ABI string (for crash reporting). */
    public final String abiString;
    /** Truncated version of Build.FINGERPRINT (for crash reporting). */
    public final String androidBuildFingerprint;
    /** Whether or not the device has apps installed for using custom themes. */
    public final String customThemes;
    /** Product version as stored in Android resources. */
    public final String resourcesVersion;
    /** Whether we're running on Android TV or not */
    public final boolean isTV;
    /** Whether we're running on an Android Automotive OS device or not. */
    public final boolean isAutomotive;

    private static class Holder { private static BuildInfo sInstance = new BuildInfo(); }

    @CalledByNative
    private static String[] getAll() {
        return BuildInfo.getInstance().getAllProperties();
    }

    /** Returns a serialized string array of all properties of this class. */
    @VisibleForTesting
    String[] getAllProperties() {
        String hostPackageName = ContextUtils.getApplicationContext().getPackageName();
        return new String[] {
                Build.BRAND,
                Build.DEVICE,
                Build.ID,
                Build.MANUFACTURER,
                Build.MODEL,
                String.valueOf(Build.VERSION.SDK_INT),
                Build.TYPE,
                Build.BOARD,
                hostPackageName,
                String.valueOf(hostVersionCode),
                hostPackageLabel,
                packageName,
                String.valueOf(versionCode),
                versionName,
                androidBuildFingerprint,
                gmsVersionCode,
                installerPackageName,
                abiString,
                sFirebaseAppId,
                customThemes,
                resourcesVersion,
                String.valueOf(
                        ContextUtils.getApplicationContext().getApplicationInfo().targetSdkVersion),
                isDebugAndroid() ? "1" : "0",
                isTV ? "1" : "0",
                Build.VERSION.INCREMENTAL,
                Build.HARDWARE,
                isAtLeastT() ? "1" : "0",
                isAutomotive ? "1" : "0",
        };
    }

    private static String nullToEmpty(CharSequence seq) {
        return seq == null ? "" : seq.toString();
    }

    /**
     * Return the "long" version code of the given PackageInfo.
     * Does the right thing for before/after Android P when this got wider.
     */
    public static long packageVersionCode(PackageInfo pi) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
            return ApiHelperForP.getLongVersionCode(pi);
        } else {
            return pi.versionCode;
        }
    }

    /**
     * @param packageInfo Package for Chrome/WebView (as opposed to host app).
     */
    public static void setBrowserPackageInfo(PackageInfo packageInfo) {
        assert !sInitialized;
        sBrowserPackageInfo = packageInfo;
    }

    /**
     * @return ApplicationInfo for Chrome/WebView (as opposed to host app).
     */
    public ApplicationInfo getBrowserApplicationInfo() {
        return sBrowserApplicationInfo;
    }

    public static BuildInfo getInstance() {
        return Holder.sInstance;
    }

    @VisibleForTesting
    BuildInfo() {
        sInitialized = true;

        Context appContext = ContextUtils.getApplicationContext();
        String hostPackageName = appContext.getPackageName();
        PackageManager pm = appContext.getPackageManager();
        PackageInfo pi = PackageUtils.getPackageInfo(hostPackageName, 0);
        hostVersionCode = packageVersionCode(pi);
        if (sBrowserPackageInfo != null) {
            packageName = sBrowserPackageInfo.packageName;
            versionCode = packageVersionCode(sBrowserPackageInfo);
            versionName = nullToEmpty(sBrowserPackageInfo.versionName);
            sBrowserApplicationInfo = sBrowserPackageInfo.applicationInfo;
            sBrowserPackageInfo = null;
        } else {
            packageName = hostPackageName;
            versionCode = hostVersionCode;
            versionName = nullToEmpty(pi.versionName);
            sBrowserApplicationInfo = appContext.getApplicationInfo();
        }

        hostPackageLabel = nullToEmpty(pm.getApplicationLabel(pi.applicationInfo));
        installerPackageName = nullToEmpty(pm.getInstallerPackageName(packageName));

        PackageInfo gmsPackageInfo = PackageUtils.getPackageInfo("com.google.android.gms", 0);
        gmsVersionCode = gmsPackageInfo != null ? String.valueOf(packageVersionCode(gmsPackageInfo))
                                                : "gms versionCode not available.";

        // Substratum is a theme engine that enables users to use custom themes provided
        // by theme apps. Sometimes these can cause crashs if not installed correctly.
        // These crashes can be difficult to debug, so knowing if the theme manager is
        // present on the device is useful (http://crbug.com/820591).
        customThemes = String.valueOf(PackageUtils.isPackageInstalled("projekt.substratum"));

        String currentResourcesVersion = "Not Enabled";
        // Controlled by target specific build flags.
        if (BuildConfig.R_STRING_PRODUCT_VERSION != 0) {
            try {
                // This value can be compared with the actual product version to determine if
                // corrupted resources were the cause of a crash. This can happen if the app
                // loads resources from the outdated package  during an update
                // (http://crbug.com/820591).
                currentResourcesVersion = ContextUtils.getApplicationContext().getString(
                        BuildConfig.R_STRING_PRODUCT_VERSION);
            } catch (Exception e) {
                currentResourcesVersion = "Not found";
            }
        }
        resourcesVersion = currentResourcesVersion;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            abiString = TextUtils.join(", ", Build.SUPPORTED_ABIS);
        } else {
            abiString = String.format("ABI1: %s, ABI2: %s", Build.CPU_ABI, Build.CPU_ABI2);
        }

        // The value is truncated, as this is used for crash and UMA reporting.
        androidBuildFingerprint = Build.FINGERPRINT.substring(
                0, Math.min(Build.FINGERPRINT.length(), MAX_FINGERPRINT_LENGTH));

        // See https://developer.android.com/training/tv/start/hardware.html#runtime-check.
        UiModeManager uiModeManager = (UiModeManager) appContext.getSystemService(UI_MODE_SERVICE);
        isTV = uiModeManager != null
                && uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;

        boolean isAutomotive;
        try {
            isAutomotive = pm.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE);
        } catch (SecurityException e) {
            Log.e(TAG, "Unable to query for Automotive system feature", e);

            // `hasSystemFeature` can possibly throw an exception on modified instances of
            // Android. In this case, assume the device is not a car since automotive vehicles
            // should not have such a modification.
            isAutomotive = false;
        }
        this.isAutomotive = isAutomotive;
    }

    /**
     * Check if this is a debuggable build of Android. Use this to enable developer-only features.
     * This is a rough approximation of the hidden API {@code Build.IS_DEBUGGABLE}.
     */
    public static boolean isDebugAndroid() {
        return "eng".equals(Build.TYPE) || "userdebug".equals(Build.TYPE);
    }

    /**
     * Wrap BuildCompat.isAtLeastT. This enables it to be shadowed in Robolectric tests.
     */
    @OptIn(markerClass = androidx.core.os.BuildCompat.PrereleaseSdkCheck.class)
    public static boolean isAtLeastT() {
        return BuildCompat.isAtLeastT();
    }

    /**
     * Checks if the application targets pre-release SDK T.
     * This must be manually maintained as the SDK goes through finalization!
     * Avoid depending on this if possible; this is only intended for WebView.
     */
    @OptIn(markerClass = androidx.core.os.BuildCompat.PrereleaseSdkCheck.class)
    public static boolean targetsAtLeastT() {
        int target = ContextUtils.getApplicationContext().getApplicationInfo().targetSdkVersion;

        // Logic for pre-API-finalization:
        // return BuildCompat.isAtLeastT() && target == Build.VERSION_CODES.CUR_DEVELOPMENT;

        // Logic for after API finalization but before public SDK release has to
        // just hardcode the appropriate SDK integer. This will include Android
        // builds with the finalized SDK, and also pre-API-finalization builds
        // (because CUR_DEVELOPMENT == 10000).
        // return target >= 33;

        // Once the public SDK is upstreamed we can use the defined constant,
        // deprecate this, then eventually inline this at all callsites and
        // remove it.
        return target >= Build.VERSION_CODES.TIRAMISU;
    }

    public static void setFirebaseAppId(String id) {
        assert sFirebaseAppId.equals("");
        sFirebaseAppId = id;
    }

    public static String getFirebaseAppId() {
        return sFirebaseAppId;
    }

}


text:
#ifndef _ItkConvertArrayTo8BitImageAttributeMatrix_H_
#define _ItkConvertArrayTo8BitImageAttributeMatrix_H_

#include <QtCore/QString>
#include <set>

#include "SIMPLib/SIMPLib.h"
#include "SIMPLib/Common/SIMPLibSetGetMacros.h"
#include "SIMPLib/DataArrays/IDataArray.h"
#include "SIMPLib/Common/AbstractFilter.h"

#include "SIMPLib/DataContainers/DataContainer.h"

#include "ImageProcessing/ImageProcessingConstants.h"
/**
 * @class ConvertArrayTo8BitImageAttributeMatrix ConvertArrayTo8BitImageAttributeMatrix.h /FilterCategoryFilters/ConvertArrayTo8BitImageAttributeMatrix.h
 * @brief
 * @author
 * @date
 * @version 1.0
 */
class ItkConvertArrayTo8BitImageAttributeMatrix : public AbstractFilter
{
    Q_OBJECT /* Need this for Qt's signals and slots mechanism to work */
  public:
    SIMPL_SHARED_POINTERS(ItkConvertArrayTo8BitImageAttributeMatrix)
    SIMPL_STATIC_NEW_MACRO(ItkConvertArrayTo8BitImageAttributeMatrix)
    SIMPL_TYPE_MACRO_SUPER(ItkConvertArrayTo8BitImageAttributeMatrix, AbstractFilter)

    virtual ~ItkConvertArrayTo8BitImageAttributeMatrix();

    SIMPL_FILTER_PARAMETER(DataArrayPath, AttributeMatrixName)
    Q_PROPERTY(DataArrayPath AttributeMatrixName READ getAttributeMatrixName WRITE setAttributeMatrixName)

    SIMPL_FILTER_PARAMETER(QString, NewArrayArrayName)
    Q_PROPERTY(QString NewArrayArrayName READ getNewArrayArrayName WRITE setNewArrayArrayName)

    /**
    * @brief This returns the group that the filter belonds to. You can select
    * a different group if you want. The string returned here will be displayed
    * in the GUI for the filter
    */
    virtual const QString getCompiledLibraryName();
    virtual AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters);
    virtual const QString getGroupName();
    virtual const QString getSubGroupName();

    /**
    * @brief This returns a string that is displayed in the GUI. It should be readable
    * and understandable by humans.
    */
    virtual const QString getHumanLabel();

    /**
    * @brief This method will instantiate all the end user settable options/parameters
    * for this filter
    */
    virtual void setupFilterParameters();

    /**
    * @brief This method will write the options to a file
    * @param writer The writer that is used to write the options to a file
    */
    virtual int writeFilterParameters(AbstractFilterParametersWriter* writer, int index);

    /**
    * @brief This method will read the options from a file
    * @param reader The reader that is used to read the options from a file
    */
    virtual void readFilterParameters(AbstractFilterParametersReader* reader, int index);

    /**
    * @brief Reimplemented from @see AbstractFilter class
    */
    virtual void execute();

    /**
    * @brief This function runs some sanity checks on the DataContainer and inputs
    * in an attempt to ensure the filter can process the inputs.
    */
    virtual void preflight();

  signals:
    void updateFilterParameters(AbstractFilter* filter);
    void parametersChanged();
    void preflightAboutToExecute();
    void preflightExecuted();

  protected:
    ItkConvertArrayTo8BitImageAttributeMatrix();

    /**
    * @brief Checks for the appropriate parameter values and availability of
    * arrays in the data container
    * @param preflight
    * @param voxels The number of voxels
    * @param features The number of features
    * @param ensembles The number of ensembles
    */
    void dataCheck();

  private:
    DEFINE_DATAARRAY_VARIABLE(uint8_t, NewArray)

    ItkConvertArrayTo8BitImageAttributeMatrix(const ItkConvertArrayTo8BitImageAttributeMatrix&); // Copy Constructor Not Implemented
    void operator=(const ItkConvertArrayTo8BitImageAttributeMatrix&); // Operator '=' Not Implemented
};

#endif /* ConvertArrayTo8BitImageAttributeMatrix_H_ */


text:
package com.datastax.driver.core;

class MockClocks {
    static class BackInTimeClock implements Clock {
        final long arbitraryTimeStamp = 1412610226270L;
        int calls;

        @Override
        public long currentTimeMicros() {
            return arbitraryTimeStamp - calls++;
        }
    }

    static class FixedTimeClock implements Clock {
        final long fixedTime;

        public FixedTimeClock(long fixedTime) {
            this.fixedTime = fixedTime;
        }

        @Override
        public long currentTimeMicros() {
            return fixedTime;
        }
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <groupId>qdg</groupId>
  <artifactId>qdg-core-gwt</artifactId>
  <versioning>
    <versions>
      <version>0.0.2-SNAPSHOT</version>
      <version>0.0.3-SNAPSHOT</version>
    </versions>
    <lastUpdated>20150917143618</lastUpdated>
  </versioning>
</metadata>


text:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="IdProvider" IDEtalkID="9BFFF01803E3396F3B097D8F0ABB712D" />
  <component name="ProjectLevelVcsManager" settingsEditedManually="false">
    <OptionsSetting value="true" id="Add" />
    <OptionsSetting value="true" id="Remove" />
    <OptionsSetting value="true" id="Checkout" />
    <OptionsSetting value="true" id="Update" />
    <OptionsSetting value="true" id="Status" />
    <OptionsSetting value="true" id="Edit" />
    <ConfirmationsSetting value="0" id="Add" />
    <ConfirmationsSetting value="0" id="Remove" />
  </component>
  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true">
    <output url="file://$PROJECT_DIR$/out" />
  </component>
  <component name="PyConsoleOptionsProvider">
    <option name="myPythonConsoleState">
      <console-settings />
    </option>
  </component>
  <component name="masterDetails">
    <states>
      <state key="GlobalLibrariesConfigurable.UI">
        <settings>
          <last-edited>Python 2.7.6 (/usr/bin/python) interpreter library</last-edited>
          <splitter-proportions>
            <option name="proportions">
              <list>
                <option value="0.2" />
              </list>
            </option>
          </splitter-proportions>
        </settings>
      </state>
      <state key="JdkListConfigurable.UI">
        <settings>
          <last-edited>1.7</last-edited>
          <splitter-proportions>
            <option name="proportions">
              <list>
                <option value="0.2" />
              </list>
            </option>
          </splitter-proportions>
        </settings>
      </state>
      <state key="ProjectJDKs.UI">
        <settings>
          <last-edited>1.7</last-edited>
          <splitter-proportions>
            <option name="proportions">
              <list>
                <option value="0.2" />
              </list>
            </option>
          </splitter-proportions>
        </settings>
      </state>
      <state key="ProjectLibrariesConfigurable.UI">
        <settings>
          <splitter-proportions>
            <option name="proportions">
              <list>
                <option value="0.2" />
              </list>
            </option>
          </splitter-proportions>
        </settings>
      </state>
    </states>
  </component>
</project>


text:
NAMESPACE_BEGIN(CryptoPP)

/// .
class VMAC_Base : public IteratedHashBase<word64, MessageAuthenticationCode>
{
public:
	std::string AlgorithmName() const {return std::string("VMAC(") + GetCipher().AlgorithmName() + ")-" + IntToString(DigestSize()*8);}
	unsigned int IVSize() const {return GetCipher().BlockSize();}
	unsigned int MinIVLength() const {return 1;}
	void Resynchronize(const byte *nonce, int length=-1);
	void GetNextIV(RandomNumberGenerator &rng, byte *IV);
	unsigned int DigestSize() const {return m_is128 ? 16 : 8;};
	void UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs &params);
	void TruncatedFinal(byte *mac, size_t size);
	unsigned int BlockSize() const {return m_L1KeyLength;}
	ByteOrder GetByteOrder() const {return LITTLE_ENDIAN_ORDER;}

protected:
	virtual BlockCipher & AccessCipher() =0;
	virtual int DefaultDigestSize() const =0;
	const BlockCipher & GetCipher() const {return const_cast<VMAC_Base *>(this)->AccessCipher();}
	void HashEndianCorrectedBlock(const word64 *data);
	size_t HashMultipleBlocks(const word64 *input, size_t length);
	void Init() {}
	word64* StateBuf() {return NULL;}
	word64* DataBuf() {return (word64 *)m_data();}

	void VHASH_Update_SSE2(const word64 *data, size_t blocksRemainingInWord64, int tagPart);
#if !(defined(_MSC_VER) && _MSC_VER < 1300)		// can't use function template here with VC6
	template <bool T_128BitTag>
#endif
	void VHASH_Update_Template(const word64 *data, size_t blockRemainingInWord128);
	void VHASH_Update(const word64 *data, size_t blocksRemainingInWord128);

	CRYPTOPP_BLOCK_1(polyState, word64, 4*(m_is128+1))
	CRYPTOPP_BLOCK_2(nhKey, word64, m_L1KeyLength/sizeof(word64) + 2*m_is128)
	CRYPTOPP_BLOCK_3(data, byte, m_L1KeyLength)
	CRYPTOPP_BLOCK_4(l3Key, word64, 2*(m_is128+1))
	CRYPTOPP_BLOCK_5(nonce, byte, IVSize())
	CRYPTOPP_BLOCK_6(pad, byte, IVSize())
	CRYPTOPP_BLOCKS_END(6)

	bool m_is128, m_padCached, m_isFirstBlock;
	int m_L1KeyLength;
};

/// VMAC
template <class T_BlockCipher, int T_DigestBitSize = 128>
class VMAC : public SimpleKeyingInterfaceImpl<VMAC_Base, SameKeyLengthAs<T_BlockCipher, SimpleKeyingInterface::UNIQUE_IV, T_BlockCipher::BLOCKSIZE> >
{
public:
	static std::string StaticAlgorithmName() {return std::string("VMAC(") + T_BlockCipher::StaticAlgorithmName() + ")-" + IntToString(T_DigestBitSize);}

private:
	BlockCipher & AccessCipher() {return m_cipher;}
	int DefaultDigestSize() const {return T_DigestBitSize/8;}
	typename T_BlockCipher::Encryption m_cipher;
};

NAMESPACE_END

#endif