text:
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CompositionContainerBuilderBase.cs" company="Kephas Software SRL">
//   Copyright (c) Kephas Software SRL. All rights reserved.
//   Licensed under the MIT license. See LICENSE file in the project root for full license information.
// </copyright>
// <summary>
//   Base class for composition container builders.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Kephas.Composition.Hosting
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics.CodeAnalysis;
    using System.Linq;
    using System.Reflection;
    using System.Text.RegularExpressions;

    using Kephas.Application;
    using Kephas.Collections;
    using Kephas.Composition.Configuration;
    using Kephas.Composition.Conventions;
    using Kephas.Diagnostics;
    using Kephas.Diagnostics.Contracts;
    using Kephas.Logging;
    using Kephas.Reflection;
    using Kephas.Resources;
    using Kephas.Services;
    using Kephas.Services.Reflection;

    /// <summary>
    /// Base class for composition container builders.
    /// </summary>
    /// <typeparam name="TBuilder">The type of the builder.</typeparam>
    public abstract class CompositionContainerBuilderBase<TBuilder> : ICompositionContainerBuilder
        where TBuilder : CompositionContainerBuilderBase<TBuilder>
    {
        private HashSet<Assembly> compositionAssemblies;
        private HashSet<Assembly> conventionAssemblies;

        /// <summary>
        /// Initializes a new instance of the <see cref="CompositionContainerBuilderBase{TBuilder}"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        [SuppressMessage("ReSharper", "VirtualMemberCallInConstructor", Justification = "Must register the ambient services in the composition context.")]
        protected CompositionContainerBuilderBase(ICompositionRegistrationContext context)
        {
            Requires.NotNull(context, nameof(context));
            var ambientServices = context.AmbientServices;
            Requires.NotNull(ambientServices, nameof(ambientServices));

            this.RegistrationContext = context;

            this.LogManager = ambientServices.LogManager;
            this.AssertRequiredService(this.LogManager);

            this.AppRuntime = ambientServices.AppRuntime;
            this.AssertRequiredService(this.AppRuntime);

            this.TypeLoader = ambientServices.TypeLoader;
            this.AssertRequiredService(this.TypeLoader);

            this.Logger = this.LogManager.GetLogger(this.GetType());

            context.AppServiceInfoProviders = context.AppServiceInfoProviders == null
                ? new List<IAppServiceInfoProvider> { this.Registry }
                : new List<IAppServiceInfoProvider>(context.AppServiceInfoProviders) { this.Registry };
        }

        /// <summary>
        /// Gets the log manager.
        /// </summary>
        /// <value>
        /// The log manager.
        /// </value>
        protected internal ILogManager LogManager { get; }

        /// <summary>
        /// Gets the type loader.
        /// </summary>
        /// <value>
        /// The type loader.
        /// </value>
        protected internal ITypeLoader TypeLoader { get; }

        /// <summary>
        /// Gets the application runtime.
        /// </summary>
        /// <value>
        /// The application runtime.
        /// </value>
        protected internal IAppRuntime AppRuntime { get; }

        /// <summary>
        /// Gets the logger.
        /// </summary>
        /// <value>
        /// The logger.
        /// </value>
        protected ILogger Logger { get; }

        /// <summary>
        /// Gets the conventions builder.
        /// </summary>
        /// <value>
        /// The conventions builder.
        /// </value>
        protected IConventionsBuilder ConventionsBuilder { get; private set; }

        /// <summary>
        /// Gets the composition parts.
        /// </summary>
        /// <value>
        /// The composition parts.
        /// </value>
        protected HashSet<Type> CompositionParts { get; private set; }

        /// <summary>
        /// Gets the <see cref="IAppServiceInfo"/> serviceRegistry.
        /// </summary>
        /// <value>
        /// The serviceRegistry.
        /// </value>
        protected AppServiceInfoRegistry Registry { get; } = new AppServiceInfoRegistry();

        /// <summary>
        /// Gets the registration context.
        /// </summary>
        protected ICompositionRegistrationContext RegistrationContext { get; }

        /// <summary>
        /// Adds the assemblies containing the conventions.
        /// </summary>
        /// <param name="assemblies">The convention assemblies.</param>
        /// <returns>
        /// This builder.
        /// </returns>
        /// <remarks>
        /// Can be used multiple times, the provided assemblies are added to the existing ones.
        /// </remarks>
        public virtual TBuilder WithConventionAssemblies(IEnumerable<Assembly> assemblies)
        {
            Requires.NotNull(assemblies, nameof(assemblies));

            if (this.conventionAssemblies == null)
            {
                this.conventionAssemblies = new HashSet<Assembly>(assemblies);
            }
            else
            {
                this.conventionAssemblies.AddRange(assemblies);
            }

            return (TBuilder)this;
        }

        /// <summary>
        /// Adds the assembly containing the conventions.
        /// </summary>
        /// <param name="assembly">The convention assembly.</param>
        /// <returns>
        /// This builder.
        /// </returns>
        /// <remarks>
        /// Can be used multiple times, the provided assembly is added to the existing ones.
        /// </remarks>
        public virtual TBuilder WithConventionAssembly(Assembly assembly)
        {
            Requires.NotNull(assembly, nameof(assembly));

            return this.WithConventionAssemblies(new[] { assembly });
        }

        /// <summary>
        /// Sets the composition conventions.
        /// </summary>
        /// <param name="conventions">The conventions.</param>
        /// <returns>This builder.</returns>
        public virtual TBuilder WithConventions(IConventionsBuilder conventions)
        {
            Requires.NotNull(conventions, nameof(conventions));

            this.ConventionsBuilder = conventions;

            return (TBuilder)this;
        }

        /// <summary>
        /// Adds the assemblies containing the composition parts.
        /// </summary>
        /// <param name="assemblies">The composition assemblies.</param>
        /// <returns>
        /// This builder.
        /// </returns>
        /// <remarks>
        /// Can be used multiple times, the provided assemblies are added to the existing ones.
        /// </remarks>
        public virtual TBuilder WithAssemblies(IEnumerable<Assembly> assemblies)
        {
            Requires.NotNull(assemblies, nameof(assemblies));

            if (this.compositionAssemblies == null)
            {
                this.compositionAssemblies = new HashSet<Assembly>(assemblies);
            }
            else
            {
                this.compositionAssemblies.AddRange(assemblies);
            }

            return (TBuilder)this;
        }

        /// <summary>
        /// Adds the assembly containing the composition parts.
        /// </summary>
        /// <param name="assembly">The composition assembly.</param>
        /// <returns>
        /// This builder.
        /// </returns>
        /// <remarks>
        /// Can be used multiple times, the provided assembly is added to the existing ones.
        /// </remarks>
        public virtual TBuilder WithAssembly(Assembly assembly)
        {
            Requires.NotNull(assembly, nameof(assembly));

            return this.WithAssemblies(new[] { assembly });
        }

        /// <summary>
        /// Adds the composition parts.
        /// </summary>
        /// <param name="parts">The parts.</param>
        /// <returns>
        /// This builder.
        /// </returns>
        /// <remarks>
        /// Can be used multiple times, the provided parts are added to the existing ones.
        /// </remarks>
        public virtual TBuilder WithParts(IEnumerable<Type> parts)
        {
            Requires.NotNull(parts, nameof(parts));

            if (this.CompositionParts == null)
            {
                this.CompositionParts = new HashSet<Type>(parts);
            }
            else
            {
                this.CompositionParts.AddRange(parts);
            }

            return (TBuilder)this;
        }

        /// <summary>
        /// Adds the composition parts.
        /// </summary>
        /// <param name="part">The composition part.</param>
        /// <returns>
        /// This builder.
        /// </returns>
        /// <remarks>
        /// Can be used multiple times, the provided part is added to the existing ones.
        /// </remarks>
        public virtual TBuilder WithPart(Type part)
        {
            Requires.NotNull(part, nameof(part));

            return this.WithParts(new[] { part });
        }

        /// <summary>
        /// Adds the factory export.
        /// </summary>
        /// <typeparam name="TContract">The type of the contract.</typeparam>
        /// <param name="factory">The factory.</param>
        /// <param name="isSingleton">If set to <c>true</c>, the factory returns a shared component, otherwise an instance component.</param>
        /// <param name="allowMultiple">Indicates whether multiple registrations are allowed.</param>
        /// <returns>
        /// This builder.
        /// </returns>
        /// <remarks>
        /// Can be used multiple times, the factories are added to the existing ones.
        /// </remarks>
        public virtual TBuilder WithFactory<TContract>(Func<TContract> factory, bool isSingleton = false, bool allowMultiple = false)
        {
            Requires.NotNull(factory, nameof(factory));

            this.Registry.Add(new AppServiceInfo(
                                    typeof(TContract),
                                    ctx => factory(),
                                    isSingleton ? AppServiceLifetime.Singleton : AppServiceLifetime.Transient)
                                {
                                    AllowMultiple = allowMultiple,
                                });

            return (TBuilder)this;
        }

        /// <summary>
        /// Adds the registrations.
        /// </summary>
        /// <param name="registrations">A variable-length parameters list containing registrations.</param>
        /// <returns>
        /// A TBuilder.
        /// </returns>
        public virtual TBuilder WithRegistration(params IAppServiceInfo[] registrations)
        {
            Requires.NotNull(registrations, nameof(registrations));

            registrations.ForEach(r =>
                {
                    this.Registry.Add(r);
                    if (r.ContractType != null) { this.WithPart(r.ContractType); }
                    if (r.InstanceType != null) { this.WithPart(r.InstanceType); }
                });

            return (TBuilder)this;
        }

        /// <summary>
        /// Adds the export provider.
        /// </summary>
        /// <remarks>
        /// Can be used multiple times, the factories are added to the existing ones.
        /// </remarks>
        /// <param name="conventionsRegistrar">The conventions registrar.</param>
        /// <returns>
        /// This builder.
        /// </returns>
        public virtual TBuilder WithConventionsRegistrar(IConventionsRegistrar conventionsRegistrar)
        {
            Requires.NotNull(conventionsRegistrar, nameof(conventionsRegistrar));

            var registrars = this.RegistrationContext.Registrars?.ToList() ?? new List<IConventionsRegistrar>();
            registrars.Add(conventionsRegistrar);
            this.RegistrationContext.Registrars = registrars;

            return (TBuilder)this;
        }

        /// <summary>
        /// Creates the container with the provided configuration asynchronously.
        /// </summary>
        /// <returns>A new container with the provided configuration.</returns>
        public virtual ICompositionContext CreateContainer()
        {
            ICompositionContext? container = null;
            Profiler.WithInfoStopwatch(
                () =>
                {
                    var assemblies = this.GetCompositionAssemblies();

                    container = this.CreateContainerWithConventions(assemblies);
                },
                this.Logger);

            return container!;
        }

        /// <summary>
        /// Factory method for creating the conventions builder.
        /// </summary>
        /// <returns>A newly created conventions builder.</returns>
        protected abstract IConventionsBuilder CreateConventionsBuilder();

        /// <summary>
        /// Creates a new composition container based on the provided conventions and assembly parts.
        /// </summary>
        /// <param name="conventions">The conventions.</param>
        /// <param name="parts">The parts candidating for composition.</param>
        /// <returns>
        /// A new composition container.
        /// </returns>
        protected abstract ICompositionContext CreateContainerCore(IConventionsBuilder conventions, IEnumerable<Type> parts);

        /// <summary>
        /// Gets the composition assemblies.
        /// </summary>
        /// <returns>An enumeration of assemblies used for composition.</returns>
        protected IEnumerable<Assembly> GetCompositionAssemblies()
        {
            return (IEnumerable<Assembly>)this.compositionAssemblies ?? this.GetAssemblies();
        }

        /// <summary>
        /// Gets the convention assemblies.
        /// </summary>
        /// <param name="fallbackAssemblies">The fallback assemblies, used if no convention assemblies are provided.</param>
        /// <returns>An enumeration of assemblies used for conventions.</returns>
        protected IEnumerable<Assembly> GetConventionAssemblies(IEnumerable<Assembly> fallbackAssemblies)
        {
            return this.conventionAssemblies ?? fallbackAssemblies;
        }

        /// <summary>
        /// Gets the convention builder.
        /// </summary>
        /// <param name="assemblies">The assemblies containing the conventions.</param>
        /// <param name="parts">The parts.</param>
        /// <returns>
        /// The convention builder.
        /// </returns>
        protected virtual IConventionsBuilder GetConventions(IEnumerable<Assembly> assemblies, IList<Type> parts)
        {
            var conventions = this.ConventionsBuilder ?? this.CreateConventionsBuilder();

            if (this.Logger.IsDebugEnabled())
            {
                var assemblyNames = assemblies.Select(a => a.GetName().Name).ToList();
                this.Logger.Debug("{operation}. Convention assemblies: {assemblies}.", nameof(this.GetConventions), assemblyNames);
            }

            Profiler.WithInfoStopwatch(
                () =>
                {
                    conventions.RegisterConventionsFrom(assemblies, parts, this.RegistrationContext);
                },
                this.Logger);

            return conventions;
        }

        /// <summary>
        /// Asserts the required service is not missing.
        /// </summary>
        /// <exception cref="InvalidOperationException">Thrown when the requested operation is invalid.</exception>
        /// <typeparam name="TService">Type of the service.</typeparam>
        /// <param name="service">The service.</param>
        protected void AssertRequiredService<TService>(TService service)
        {
            if (service == null)
            {
                throw new InvalidOperationException(string.Format(Strings.CompositionContainerBuilderBase_RequiredServiceMissing_Exception, typeof(TService).FullName));
            }
        }

        /// <summary>
        /// Gets the composition settings.
        /// </summary>
        /// <returns>
        /// The composition settings.
        /// </returns>
        protected virtual CompositionSettings GetSettings()
        {
            return null;
        }

        /// <summary>
        /// Gets the assemblies.
        /// </summary>
        /// <param name="searchPattern">The search pattern.</param>
        /// <returns>The assemblies.</returns>
        private IList<Assembly> GetAssemblies(string? searchPattern = null)
        {
            searchPattern ??= this.GetSettings()?.AssemblyFileNamePattern;

            this.Logger.Debug("{operation}. With assemblies matching pattern '{searchPattern}'.", nameof(this.GetAssemblies), searchPattern);

            IList<Assembly>? assemblies = null;

            Profiler.WithDebugStopwatch(
                () =>
                {
                    var appAssemblies = this.AppRuntime.GetAppAssemblies();
                    appAssemblies = this.WhereNotSystemAssemblies(appAssemblies);

                    if (string.IsNullOrWhiteSpace(searchPattern))
                    {
                        assemblies = appAssemblies.ToList();
                    }
                    else
                    {
                        var regex = new Regex(searchPattern);
                        assemblies = appAssemblies.Where(a => regex.IsMatch(a.FullName)).ToList();
                    }
                },
                this.Logger);

            return assemblies!;
        }

        /// <summary>
        /// Filters out the system assemblies from the provided assemblies.
        /// </summary>
        /// <param name="assemblies">The convention assemblies.</param>
        /// <returns>
        /// An enumerator that allows foreach to be used to process where not system assemblies in this
        /// collection.
        /// </returns>
        private IEnumerable<Assembly> WhereNotSystemAssemblies(IEnumerable<Assembly> assemblies)
        {
            return assemblies.Where(a => !a.IsSystemAssembly());
        }

        /// <summary>
        /// Creates the container with the registered conventions.
        /// </summary>
        /// <param name="assemblies">The assemblies.</param>
        /// <returns>The composition container.</returns>
        private ICompositionContext CreateContainerWithConventions(IEnumerable<Assembly> assemblies)
        {
            var parts = this.GetCompositionParts(assemblies);
            var conventionAssemblies = this.GetConventionAssemblies(assemblies);
            var conventions = this.GetConventions(conventionAssemblies, parts);

            var container = this.CreateContainerCore(conventions, parts);
            return container;
        }

        /// <summary>
        /// Gets the composition parts.
        /// </summary>
        /// <param name="assemblies">The assemblies.</param>
        /// <returns>The composition parts.</returns>
        private IList<Type> GetCompositionParts(IEnumerable<Assembly> assemblies)
        {
            var parts = assemblies
                .SelectMany(a => this.TypeLoader.GetExportedTypes(a))
                .Where(ConventionsBuilderExtensions.IsPartCandidate)
                .ToList();
            if (this.CompositionParts != null)
            {
                parts.AddRange(this.CompositionParts.Where(ConventionsBuilderExtensions.IsPartCandidate));
            }

            return parts;
        }

        /// <summary>
        /// An application service information serviceRegistry.
        /// </summary>
        protected class AppServiceInfoRegistry : IAppServiceInfoProvider
        {
            private IList<IAppServiceInfo> appServiceInfos = new List<IAppServiceInfo>();

            /// <summary>
            /// Adds an <see cref="IAppServiceInfo"/>.
            /// </summary>
            /// <param name="appServiceInfo">The Application service Information to add.</param>
            public void Add(IAppServiceInfo appServiceInfo)
            {
                this.appServiceInfos.Add(appServiceInfo);
            }

            /// <summary>
            /// Gets an enumeration of application service information objects.
            /// </summary>
            /// <param name="candidateTypes">The candidate types which can take part in the composition.</param>
            /// <param name="registrationContext">Context for the registration.</param>
            /// <returns>
            /// An enumeration of application service information objects and their associated contract type.
            /// </returns>
            public IEnumerable<(Type contractType, IAppServiceInfo appServiceInfo)> GetAppServiceInfos(IList<Type> candidateTypes, ICompositionRegistrationContext registrationContext)
            {
                return this.appServiceInfos.Select(i => (i.ContractType, i));
            }
        }
    }
}


text:
require 'test_helper'

class TrackableTest < ActiveSupport::TestCase
  test 'required_fields should contain the fields that Devise uses' do
    assert_same_content Devise::Models::Trackable.required_fields(User), [
      :current_sign_in_at,
      :current_sign_in_ip,
      :last_sign_in_at,
      :last_sign_in_ip,
      :sign_in_count
    ]
  end

  test 'update_tracked_fields should only set attributes but not save the record' do
    user = create_user
    request = mock
    request.stubs(:remote_ip).returns("127.0.0.1")

    assert_nil user.current_sign_in_ip
    assert_nil user.last_sign_in_ip
    assert_nil user.current_sign_in_at
    assert_nil user.last_sign_in_at
    assert_equal 0, user.sign_in_count

    user.update_tracked_fields(request)

    assert_equal "127.0.0.1", user.current_sign_in_ip
    assert_equal "127.0.0.1", user.last_sign_in_ip
    assert_not_nil user.current_sign_in_at
    assert_not_nil user.last_sign_in_at
    assert_equal 1, user.sign_in_count

    user.reload

    assert_nil user.current_sign_in_ip
    assert_nil user.last_sign_in_ip
    assert_nil user.current_sign_in_at
    assert_nil user.last_sign_in_at
    assert_equal 0, user.sign_in_count
  end
end

redpajama_set_name: RedPajamaGithub


text:
<?php

declare(strict_types=1);

namespace Eelly\SDK\User\Service;

/**
 * 买家跟进后台管理.
 */
interface BuyerManageInterface
{
    public function getAdminListPage(array $condition = [], int $page = 1, int $limit = 10): array;

    public function addBuyerManage(array $data): bool;

    public function updateBuyerManage(array $data): bool;

    public function moveBuyerManage(array $manageData, array $newAdmin, array $handleAdmin): bool;

    public function getBuyerManageSummary(array $condition = []): array;
}


text:
package com.beamly

import akka.actor.ActorSystem

import scala.concurrent.duration._
import scala.concurrent.{ ExecutionContext, Future, Promise }
import scala.util.{ Failure, Success, Try }
import scala.{ PartialFunction => ?=> }

package object playse4 extends PlayJsonAllInstances {
  implicit final class FutureTimeoutW[A](val future: Future[A]) extends AnyVal {
    def timeout[B >: A](duration: FiniteDuration, onTimeout: => Future[B])
      (implicit actorSystem: ActorSystem, ec: ExecutionContext)
    : Future[B] = {
      if (future.isCompleted)
        future
      else {
        val promise = Promise[B]()
        val timeout = actorSystem.scheduler.scheduleOnce(duration) {
          if (!promise.isCompleted) promise tryCompleteWith onTimeout
          ()
        }
        promise tryCompleteWith future
        promise.future onComplete (_ => timeout.cancel())
        promise.future
      }
    }
  }

  implicit final class TryW[T](val try0: Try[T]) extends AnyVal {
    @inline def getOrRecover[U >: T](pf: => Throwable ?=> U): U =
      try0 match {
        case Success(x) => x
        case Failure(t) => pf.applyOrElse(t, throw _: Throwable)
      }
  }
}


text:
<?php

namespace Oro\Bundle\WorkflowBundle\Serializer\Normalizer;

class ProcessScalarNormalizer extends AbstractProcessNormalizer
{
    /**
     * {@inheritDoc}
     */
    public function normalize($object, $format = null, array $context = array())
    {
        return $object;
    }

    /**
     * {@inheritDoc}
     */
    public function denormalize($data, $class, $format = null, array $context = array())
    {
        return $data;
    }

    /**
     * {@inheritDoc}
     */
    public function supportsNormalization($data, $format = null)
    {
        return is_scalar($data) || $data === null;
    }

    /**
     * {@inheritDoc}
     */
    public function supportsDenormalization($data, $type, $format = null)
    {
        return is_scalar($data) || $data === null;
    }
}


text:
This sample demonstrates some simple caching approaches using HTML5 local storage as well as HTTP Cookies.

### Applies to ###
-  Office 365 Multi Tenant (MT)
-  Office 365 Dedicated (D)
-  SharePoint 2013 on-premises

### Prerequisites ###
None

### Solution ###
Solution | Author(s)
---------|----------
Performance.Caching | Brian Michely (**Microsoft**)

### Version history ###
Version  | Date | Comments
---------| -----| --------
1.0 | July 21st 2014 | Initial release

### Disclaimer ###
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**

----------

# GENERAL COMMENTS #
This sample shows how one can use a few different mechanisms to cache data and reduce the number of calls to target services. One sample uses HTML5 local storage and the other uses HTTP Cookies. The sample just reads your 'About Me' data from your user profile and loads it into a text area where you can make changes and 'Save' it for later without writing it back to your profile. This sample does not update your profile.  Once you 'Save' it for later, the text gets stored into either a local storage key/value pair, or if using the cookies sample, it stores it into a cookie.

There are a few things to keep in mind. In a way, these two approaches can serve different purposes. We will just call out a few things without writing an entire article on localStorage vs. cookies.

HTML5 Local Storage data stays on the client, while cookies are sent via the header. Cookies give you a limit of 4095 bytes whereas local storage give you up to 5MB.  The localStorage implementation of the Storage interface has no expiration, and so you have to clear the storage either by using javascript (which is shown in this sample) or by clearing your browser cache/local data. Also, localStorage on SSL pages will be isolated from http pages.

Be mindful of what you store in these different mechanisms. You don't want to store things like Access Tokens, passwords or other account information.

# SCENARIO: CACHING WITH HTML5 LOCALSTORAGE #
As mentioned, the sample just reads your 'About Me' data from your user profile and loads it into a text area where you can make changes and 'Save' it for later without writing it back to your profile. This sample does not update your profile.  Once you 'Save' it for later, the text gets stored into either a local storage key/value pair, or if using the cookies sample, it stores it into a cookie.

![Add-in UI](http://i.imgur.com/E6wtIS4.png)

The Cache Expiration setting will set the default number of seconds for the localStorage items. When there is a value specified, and the text in the box is saved, two keys are created/updated -> 'aboutMe' & 'aboutMeTimeStamp'. When the add-in checks localStorage (before a service call is made), it checks to see if the key exists, and checks for and retrieves the timestamp key. It compares the time stamp against expiration settings, and if the key is expired, it makes a call to get the user profile data and refreshes/creates the two keys. If there is no value set in the Cache Expiration, the 'aboutMe' key does not expire.

The 'Clear Cache' button will bust the cache by removing the key, which will trigger a call to get your user profile data and then it will create a new key and store the 'About Me' data in it.

```JavaScript
// Bust the cache
function clearCache(key) {

    // Remove key/value
    localStorage.removeItem(key);
    // Remove key/value expiration
    localStorage.removeItem(key + expiryKeySuffix);

    cachingStatus += "\n" + "...";
    cachingStatus += "\n" + "Cleared the cache...";
    cachingStatus += "\n" + "Retrieving profile data from user profile...";
    $('#status').val(cachingStatus);

    // Retrieve AboutMe data from profile and repopulate text area
    getUserProperties();
}
```

There is some functionality to manage local storage key expiration as this is not built into HTML local storage. This function will check to see if the key is expired for example.

```JavaScript
// Check to see if the key has expired
function isKeyExpired(TimeStampKey) {

    // Retrieve the example setting for expiration in seconds
    var expiryStamp = localStorage.getItem(TimeStampKey);

    if (expiryStamp != null && cacheTimeout != null) {

        // Retrieve the timestamp and compare against specified cache timeout settings to see if it is expired
        var currentTime = Math.floor((new Date().getTime()) / 1000);

        if (currentTime - parseInt(expiryStamp) > parseInt(cacheTimeout)) {
            return true; //Expired
        }
        else {
            return false;
        }
    }
    else {
        //default
        return true;
    }
}
```

# SCENARIO: CACHING WITH HTTP COOKIES #
As mentioned above, the sample just reads your 'About Me' data from your user profile and loads it into a text area where you can make changes and 'Save' it for later without writing it back to your profile. This sample does not update your profile.  Once you 'Save' it for later, the text gets stored into either a local storage key/value pair, or if using the cookies sample, it stores it into a cookie. The screenshot below shows the http cookies sample UI.

![Add-in UI with cookie information](http://i.imgur.com/UrDk8a1.png)

This sample will first check to see if cookies are enabled, then it will check to see if the cookie exists. If it does, it will retrieve the value from it and render in the text area. If not, it will pull from the profile, populate the cookie, set expiration and then render in UI.

<img src="https://telemetry.sharepointpnp.com/pnp/samples/Performance.Caching" />


text:
import { ProtocolType } from './protocols';
import { ServiceConnection } from './serviceConnectionUtils';
/**
 * Get the task-provided credential provider plugins directory (containing netcore and netfx folders)
 */
export declare function getTaskCredProviderPluginsDir(): string;
/**
 * Copy the credential provider (netcore and netfx) to the user profile directory
 */
export declare function installCredProviderToUserProfile(overwrite: boolean): Promise<void>;
export declare function getUserProfileNuGetPluginsDir(): string;
/**
 * Configure the credential provider to provide credentials for feeds within the pipeline's organization,
 * as well as for any provided service connections.
 */
export declare function configureCredProvider(protocol: ProtocolType, serviceConnections: ServiceConnection[]): Promise<void>;
/**
 * Configure the credential provider to provide credentials for feeds within the pipeline's organization,
 * using VSS_NUGET_URI_PREFIXES and VSS_NUGET_ACCESSTOKEN variables to do so.
 */
export declare function configureCredProviderForSameOrganizationFeeds(protocol: ProtocolType): Promise<void>;
/**
 * Configure the credential provider to provide credentials for service connections,
 * using VSS_NUGET_EXTERNAL_FEED_ENDPOINTS to do so.
 */
export declare function configureCredProviderForServiceConnectionFeeds(serviceConnections: ServiceConnection[]): void;
/**
 * Build the JSON for VSS_NUGET_EXTERNAL_FEED_ENDPOINTS
 *
 *  Similar to the older NuGetToolRunner2.buildCredentialJson,
 *  but fails hard on ApiKey based service connections instead of silently continuing.
 */
export declare function buildExternalFeedEndpointsJson(serviceConnections: ServiceConnection[]): string;


text:
namespace org { namespace alljoyn { namespace Humidifier { namespace Actions {

// Signals

} } } }


text:
package com.netthreads.trader.service;

import javax.persistence.NoResultException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.netthreads.trader.dao.TaskStateRepository;
import com.netthreads.trader.domain.TaskState;
import com.netthreads.trader.domain.TaskState.State;
import com.netthreads.trader.exception.DataLayerException;

/**
 * User Service.
 *
 */
@Repository
@Transactional
public class TaskStateService
{
	private TaskStateRepository repository;

	@Autowired
	public TaskStateService(TaskStateRepository repository)
	{
		this.repository = repository;
	}

	/**
	 * Create item.
	 *
	 * @param taskState
	 *
	 * @throws DataLayerException
	 */
	public void create(TaskState taskState) throws DataLayerException
	{
		TaskState target = findByState(taskState.getState());

		if (target == null)
		{
			repository.save(taskState);
		}
		else
		{
			throw new DataLayerException(Errors.ERROR_TASK_STATE_ALREADY_EXISTS);
		}
	}

	/**
	 * Find all.
	 *
	 * @return Target list.
	 * @throws DataLayerException
	 */
	public Iterable<TaskState> findAll() throws DataLayerException
	{
		Iterable<TaskState> items = repository.findAll();

		return items;
	}

	/**
	 * Find by state type.
	 *
	 * @param userName
	 *
	 * @return Target user or null if not found.
	 */
	public TaskState findByState(State state)
	{
		TaskState taskState = null;

		try
		{
			taskState = repository.findByState(state);
		}
		catch (NoResultException e)
		{
			taskState = null;
		}

		return taskState;
	}

	/**
	 * Save
	 *
	 * @param taskState
	 */
	public void save(TaskState taskState)
	{
		repository.save(taskState);
	}

	/**
	 * Delete all.
	 *
	 */
	public void deleteAll()
	{
		repository.deleteAll();
	}
}


text:
"""Custom Phylo Operations
"""

#####################
# IMPORT OPERATIONS #
#####################

from __future__ import absolute_import

import CustomFileOps as CFO
import sys

dendropy = CFO.loadModule("dendropy")

###############
# AUTHOR INFO #
###############

__author__ = "Michael Gruenstaeudl, PhD"
__copyright__ = "Copyright (C) 2015 Michael Gruenstaeudl"
__email__ = "mi.gruenstaeudl@gmail.com"
__version__ = "2015.12.15.1100"

#############
# DEBUGGING #
#############

#import pdb
#pdb.set_trace()

###########
# CLASSES #
###########

class convertNexusToNewick:
    ''' Convert a phylogenetic tree in NEXUS format to a phylogenetic tree in NEWICK format
    Args:
        string
    Returns:
        string
    '''
    def __init__(self, a):
        self.inStr = a
    def go(self):
        treeH = dendropy.Tree.get_from_string(self.inStr, schema="nexus")
        return treeH.as_string(schema='newick')

class getNodeListFromTree:
    ''' class for generating a list of nodes from a phylogenetic tree
    Args:
        string
    Returns:
        str, list
    '''
    def __init__(self, a):
        self.inFn = a
    def go(self):
        nodespecL, nodeL = [], []
        treeH = dendropy.Tree.get_from_path(self.inFn, schema="nexus")
        for c, node in enumerate(treeH.nodes(), start=1):
            tips = [tip.taxon.label.replace(" ", "_") for tip in node.leaf_nodes()]
            if len(tips) > 1:
                nodespecL.append("AddNode Node" + str(c) + " " + " ".join(tips))
                nodeL.append(c)                                         # generate list of relevant node numbers
        node_specs = "\n".join(nodespecL)
        return [node_specs, nodeL]

###############
# DEFINITIONS #
###############

def ConvertNexusToNewick(a):
    return convertNexusToNewick(a).go()

def GetNodeListFromTree(a):
    return getNodeListFromTree(a).go()


text:
.navbar-inverse {
    background-color: #3b5998;
    border-color: #3b5998;
}

.navbar-inverse .navbar-brand {
    color: #fff;
}

.navbar-inverse .navbar-collapse, .navbar-inverse .navbar-form {
    border-color: #2c416e;
}

.navbar-inverse .navbar-toggle:focus, .navbar-inverse .navbar-toggle:hover {
    background-color: #2c416e;
}

.navbar-inverse .navbar-toggle {
    border-color: #2c416e;
}

.login, .login:hover {
    background-color: #4267b2;
    border-color: #2c416e;
}

.login:hover {
    background-color: #395490;
}

.login:active:focus, .login:hover, .login:focus, .login:active, .login.open > .dropdown-toggle.login {
    background-color: #395490;
}


text:
<?php

final class ManiphestCapabilityDefaultEdit
  extends PhabricatorPolicyCapability {

  const CAPABILITY = 'maniphest.default.edit';

  public function getCapabilityKey() {
    return self::CAPABILITY;
  }

  public function getCapabilityName() {
    return pht('Default Edit Policy');
  }

}


text:
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/spinlock.h>
#include <linux/mm.h>

#include <asm/io.h>
#include <asm/irq.h>
#include <asm/uaccess.h>
#include <linux/module.h>
#include <linux/crc32.h>
#include <asm/types.h>
#include <linux/ethtool.h>
#include <linux/mii.h>
#include <linux/phy.h>
#include <linux/sort.h>
#include <linux/if_vlan.h>

#include "gianfar.h"

extern void gfar_start(struct net_device *dev);
extern int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit);

#define GFAR_MAX_COAL_USECS 0xffff
#define GFAR_MAX_COAL_FRAMES 0xff
static void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy,
		     u64 * buf);
static void gfar_gstrings(struct net_device *dev, u32 stringset, u8 * buf);
static int gfar_gcoalesce(struct net_device *dev, struct ethtool_coalesce *cvals);
static int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals);
static void gfar_gringparam(struct net_device *dev, struct ethtool_ringparam *rvals);
static int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rvals);
static void gfar_gdrvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo);

static char stat_gstrings[][ETH_GSTRING_LEN] = {
	"rx-dropped-by-kernel",
	"rx-large-frame-errors",
	"rx-short-frame-errors",
	"rx-non-octet-errors",
	"rx-crc-errors",
	"rx-overrun-errors",
	"rx-busy-errors",
	"rx-babbling-errors",
	"rx-truncated-frames",
	"ethernet-bus-error",
	"tx-babbling-errors",
	"tx-underrun-errors",
	"rx-skb-missing-errors",
	"tx-timeout-errors",
	"tx-rx-64-frames",
	"tx-rx-65-127-frames",
	"tx-rx-128-255-frames",
	"tx-rx-256-511-frames",
	"tx-rx-512-1023-frames",
	"tx-rx-1024-1518-frames",
	"tx-rx-1519-1522-good-vlan",
	"rx-bytes",
	"rx-packets",
	"rx-fcs-errors",
	"receive-multicast-packet",
	"receive-broadcast-packet",
	"rx-control-frame-packets",
	"rx-pause-frame-packets",
	"rx-unknown-op-code",
	"rx-alignment-error",
	"rx-frame-length-error",
	"rx-code-error",
	"rx-carrier-sense-error",
	"rx-undersize-packets",
	"rx-oversize-packets",
	"rx-fragmented-frames",
	"rx-jabber-frames",
	"rx-dropped-frames",
	"tx-byte-counter",
	"tx-packets",
	"tx-multicast-packets",
	"tx-broadcast-packets",
	"tx-pause-control-frames",
	"tx-deferral-packets",
	"tx-excessive-deferral-packets",
	"tx-single-collision-packets",
	"tx-multiple-collision-packets",
	"tx-late-collision-packets",
	"tx-excessive-collision-packets",
	"tx-total-collision",
	"reserved",
	"tx-dropped-frames",
	"tx-jabber-frames",
	"tx-fcs-errors",
	"tx-control-frames",
	"tx-oversize-frames",
	"tx-undersize-frames",
	"tx-fragmented-frames",
};

/* Fill in a buffer with the strings which correspond to the
 * stats */
static void gfar_gstrings(struct net_device *dev, u32 stringset, u8 * buf)
{
	struct gfar_private *priv = netdev_priv(dev);

	if (priv->device_flags & FSL_GIANFAR_DEV_HAS_RMON)
		memcpy(buf, stat_gstrings, GFAR_STATS_LEN * ETH_GSTRING_LEN);
	else
		memcpy(buf, stat_gstrings,
				GFAR_EXTRA_STATS_LEN * ETH_GSTRING_LEN);
}

/* Fill in an array of 64-bit statistics from various sources.
 * This array will be appended to the end of the ethtool_stats
 * structure, and returned to user space
 */
static void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy, u64 * buf)
{
	int i;
	struct gfar_private *priv = netdev_priv(dev);
	struct gfar __iomem *regs = priv->gfargrp[0].regs;
	u64 *extra = (u64 *) & priv->extra_stats;

	if (priv->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
		u32 __iomem *rmon = (u32 __iomem *) &regs->rmon;
		struct gfar_stats *stats = (struct gfar_stats *) buf;

		for (i = 0; i < GFAR_RMON_LEN; i++)
			stats->rmon[i] = (u64) gfar_read(&rmon[i]);

		for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++)
			stats->extra[i] = extra[i];
	} else
		for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++)
			buf[i] = extra[i];
}

static int gfar_sset_count(struct net_device *dev, int sset)
{
	struct gfar_private *priv = netdev_priv(dev);

	switch (sset) {
	case ETH_SS_STATS:
		if (priv->device_flags & FSL_GIANFAR_DEV_HAS_RMON)
			return GFAR_STATS_LEN;
		else
			return GFAR_EXTRA_STATS_LEN;
	default:
		return -EOPNOTSUPP;
	}
}

/* Fills in the drvinfo structure with some basic info */
static void gfar_gdrvinfo(struct net_device *dev, struct
	      ethtool_drvinfo *drvinfo)
{
	strncpy(drvinfo->driver, DRV_NAME, GFAR_INFOSTR_LEN);
	strncpy(drvinfo->version, gfar_driver_version, GFAR_INFOSTR_LEN);
	strncpy(drvinfo->fw_version, "N/A", GFAR_INFOSTR_LEN);
	strncpy(drvinfo->bus_info, "N/A", GFAR_INFOSTR_LEN);
	drvinfo->regdump_len = 0;
	drvinfo->eedump_len = 0;
}

static int gfar_ssettings(struct net_device *dev, struct ethtool_cmd *cmd)
{
	struct gfar_private *priv = netdev_priv(dev);
	struct phy_device *phydev = priv->phydev;

	if (NULL == phydev)
		return -ENODEV;

	return phy_ethtool_sset(phydev, cmd);
}

/* Return the current settings in the ethtool_cmd structure */
static int gfar_gsettings(struct net_device *dev, struct ethtool_cmd *cmd)
{
	struct gfar_private *priv = netdev_priv(dev);
	struct phy_device *phydev = priv->phydev;
	struct gfar_priv_rx_q *rx_queue = NULL;
	struct gfar_priv_tx_q *tx_queue = NULL;

	if (NULL == phydev)
		return -ENODEV;
	tx_queue = priv->tx_queue[0];
	rx_queue = priv->rx_queue[0];

	/* etsec-1.7 and older versions have only one txic
	 * and rxic regs although they support multiple queues */
	cmd->maxtxpkt = get_icft_value(tx_queue->txic);
	cmd->maxrxpkt = get_icft_value(rx_queue->rxic);

	return phy_ethtool_gset(phydev, cmd);
}

/* Return the length of the register structure */
static int gfar_reglen(struct net_device *dev)
{
	return sizeof (struct gfar);
}

/* Return a dump of the GFAR register space */
static void gfar_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf)
{
	int i;
	struct gfar_private *priv = netdev_priv(dev);
	u32 __iomem *theregs = (u32 __iomem *) priv->gfargrp[0].regs;
	u32 *buf = (u32 *) regbuf;

	for (i = 0; i < sizeof (struct gfar) / sizeof (u32); i++)
		buf[i] = gfar_read(&theregs[i]);
}

/* Convert microseconds to ethernet clock ticks, which changes
 * depending on what speed the controller is running at */
static unsigned int gfar_usecs2ticks(struct gfar_private *priv, unsigned int usecs)
{
	unsigned int count;

	/* The timer is different, depending on the interface speed */
	switch (priv->phydev->speed) {
	case SPEED_1000:
		count = GFAR_GBIT_TIME;
		break;
	case SPEED_100:
		count = GFAR_100_TIME;
		break;
	case SPEED_10:
	default:
		count = GFAR_10_TIME;
		break;
	}

	/* Make sure we return a number greater than 0
	 * if usecs > 0 */
	return (usecs * 1000 + count - 1) / count;
}

/* Convert ethernet clock ticks to microseconds */
static unsigned int gfar_ticks2usecs(struct gfar_private *priv, unsigned int ticks)
{
	unsigned int count;

	/* The timer is different, depending on the interface speed */
	switch (priv->phydev->speed) {
	case SPEED_1000:
		count = GFAR_GBIT_TIME;
		break;
	case SPEED_100:
		count = GFAR_100_TIME;
		break;
	case SPEED_10:
	default:
		count = GFAR_10_TIME;
		break;
	}

	/* Make sure we return a number greater than 0 */
	/* if ticks is > 0 */
	return (ticks * count) / 1000;
}

/* Get the coalescing parameters, and put them in the cvals
 * structure.  */
static int gfar_gcoalesce(struct net_device *dev, struct ethtool_coalesce *cvals)
{
	struct gfar_private *priv = netdev_priv(dev);
	struct gfar_priv_rx_q *rx_queue = NULL;
	struct gfar_priv_tx_q *tx_queue = NULL;
	unsigned long rxtime;
	unsigned long rxcount;
	unsigned long txtime;
	unsigned long txcount;

	if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE))
		return -EOPNOTSUPP;

	if (NULL == priv->phydev)
		return -ENODEV;

	rx_queue = priv->rx_queue[0];
	tx_queue = priv->tx_queue[0];

	rxtime  = get_ictt_value(rx_queue->rxic);
	rxcount = get_icft_value(rx_queue->rxic);
	txtime  = get_ictt_value(tx_queue->txic);
	txcount = get_icft_value(tx_queue->txic);
	cvals->rx_coalesce_usecs = gfar_ticks2usecs(priv, rxtime);
	cvals->rx_max_coalesced_frames = rxcount;

	cvals->tx_coalesce_usecs = gfar_ticks2usecs(priv, txtime);
	cvals->tx_max_coalesced_frames = txcount;

	cvals->use_adaptive_rx_coalesce = 0;
	cvals->use_adaptive_tx_coalesce = 0;

	cvals->pkt_rate_low = 0;
	cvals->rx_coalesce_usecs_low = 0;
	cvals->rx_max_coalesced_frames_low = 0;
	cvals->tx_coalesce_usecs_low = 0;
	cvals->tx_max_coalesced_frames_low = 0;

	/* When the packet rate is below pkt_rate_high but above
	 * pkt_rate_low (both measured in packets per second) the
	 * normal {rx,tx}_* coalescing parameters are used.
	 */

	/* When the packet rate is (measured in packets per second)
	 * is above pkt_rate_high, the {rx,tx}_*_high parameters are
	 * used.
	 */
	cvals->pkt_rate_high = 0;
	cvals->rx_coalesce_usecs_high = 0;
	cvals->rx_max_coalesced_frames_high = 0;
	cvals->tx_coalesce_usecs_high = 0;
	cvals->tx_max_coalesced_frames_high = 0;

	/* How often to do adaptive coalescing packet rate sampling,
	 * measured in seconds.  Must not be zero.
	 */
	cvals->rate_sample_interval = 0;

	return 0;
}

/* Change the coalescing values.
 * Both cvals->*_usecs and cvals->*_frames have to be > 0
 * in order for coalescing to be active
 */
static int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals)
{
	struct gfar_private *priv = netdev_priv(dev);
	int i = 0;

	if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE))
		return -EOPNOTSUPP;

	/* Set up rx coalescing */
	/* As of now, we will enable/disable coalescing for all
	 * queues together in case of eTSEC2, this will be modified
	 * along with the ethtool interface */
	if ((cvals->rx_coalesce_usecs == 0) ||
	    (cvals->rx_max_coalesced_frames == 0)) {
		for (i = 0; i < priv->num_rx_queues; i++)
			priv->rx_queue[i]->rxcoalescing = 0;
	} else {
		for (i = 0; i < priv->num_rx_queues; i++)
			priv->rx_queue[i]->rxcoalescing = 1;
	}

	if (NULL == priv->phydev)
		return -ENODEV;

	/* Check the bounds of the values */
	if (cvals->rx_coalesce_usecs > GFAR_MAX_COAL_USECS) {
		pr_info("Coalescing is limited to %d microseconds\n",
			GFAR_MAX_COAL_USECS);
		return -EINVAL;
	}

	if (cvals->rx_max_coalesced_frames > GFAR_MAX_COAL_FRAMES) {
		pr_info("Coalescing is limited to %d frames\n",
			GFAR_MAX_COAL_FRAMES);
		return -EINVAL;
	}

	for (i = 0; i < priv->num_rx_queues; i++) {
		priv->rx_queue[i]->rxic = mk_ic_value(
			cvals->rx_max_coalesced_frames,
			gfar_usecs2ticks(priv, cvals->rx_coalesce_usecs));
	}

	/* Set up tx coalescing */
	if ((cvals->tx_coalesce_usecs == 0) ||
	    (cvals->tx_max_coalesced_frames == 0)) {
		for (i = 0; i < priv->num_tx_queues; i++)
			priv->tx_queue[i]->txcoalescing = 0;
	} else {
		for (i = 0; i < priv->num_tx_queues; i++)
			priv->tx_queue[i]->txcoalescing = 1;
	}

	/* Check the bounds of the values */
	if (cvals->tx_coalesce_usecs > GFAR_MAX_COAL_USECS) {
		pr_info("Coalescing is limited to %d microseconds\n",
			GFAR_MAX_COAL_USECS);
		return -EINVAL;
	}

	if (cvals->tx_max_coalesced_frames > GFAR_MAX_COAL_FRAMES) {
		pr_info("Coalescing is limited to %d frames\n",
			GFAR_MAX_COAL_FRAMES);
		return -EINVAL;
	}

	for (i = 0; i < priv->num_tx_queues; i++) {
		priv->tx_queue[i]->txic = mk_ic_value(
			cvals->tx_max_coalesced_frames,
			gfar_usecs2ticks(priv, cvals->tx_coalesce_usecs));
	}

	gfar_configure_coalescing(priv, 0xFF, 0xFF);

	return 0;
}

/* Fills in rvals with the current ring parameters.  Currently,
 * rx, rx_mini, and rx_jumbo rings are the same size, as mini and
 * jumbo are ignored by the driver */
static void gfar_gringparam(struct net_device *dev, struct ethtool_ringparam *rvals)
{
	struct gfar_private *priv = netdev_priv(dev);
	struct gfar_priv_tx_q *tx_queue = NULL;
	struct gfar_priv_rx_q *rx_queue = NULL;

	tx_queue = priv->tx_queue[0];
	rx_queue = priv->rx_queue[0];

	rvals->rx_max_pending = GFAR_RX_MAX_RING_SIZE;
	rvals->rx_mini_max_pending = GFAR_RX_MAX_RING_SIZE;
	rvals->rx_jumbo_max_pending = GFAR_RX_MAX_RING_SIZE;
	rvals->tx_max_pending = GFAR_TX_MAX_RING_SIZE;

	/* Values changeable by the user.  The valid values are
	 * in the range 1 to the "*_max_pending" counterpart above.
	 */
	rvals->rx_pending = rx_queue->rx_ring_size;
	rvals->rx_mini_pending = rx_queue->rx_ring_size;
	rvals->rx_jumbo_pending = rx_queue->rx_ring_size;
	rvals->tx_pending = tx_queue->tx_ring_size;
}

/* Change the current ring parameters, stopping the controller if
 * necessary so that we don't mess things up while we're in
 * motion.  We wait for the ring to be clean before reallocating
 * the rings. */
static int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rvals)
{
	struct gfar_private *priv = netdev_priv(dev);
	int err = 0, i = 0;

	if (rvals->rx_pending > GFAR_RX_MAX_RING_SIZE)
		return -EINVAL;

	if (!is_power_of_2(rvals->rx_pending)) {
		netdev_err(dev, "Ring sizes must be a power of 2\n");
		return -EINVAL;
	}

	if (rvals->tx_pending > GFAR_TX_MAX_RING_SIZE)
		return -EINVAL;

	if (!is_power_of_2(rvals->tx_pending)) {
		netdev_err(dev, "Ring sizes must be a power of 2\n");
		return -EINVAL;
	}

	if (dev->flags & IFF_UP) {
		unsigned long flags;

		/* Halt TX and RX, and process the frames which
		 * have already been received */
		local_irq_save(flags);
		lock_tx_qs(priv);
		lock_rx_qs(priv);

		gfar_halt(dev);

		unlock_rx_qs(priv);
		unlock_tx_qs(priv);
		local_irq_restore(flags);

		for (i = 0; i < priv->num_rx_queues; i++)
			gfar_clean_rx_ring(priv->rx_queue[i],
					priv->rx_queue[i]->rx_ring_size);

		/* Now we take down the rings to rebuild them */
		stop_gfar(dev);
	}

	/* Change the size */
	for (i = 0; i < priv->num_rx_queues; i++) {
		priv->rx_queue[i]->rx_ring_size = rvals->rx_pending;
		priv->tx_queue[i]->tx_ring_size = rvals->tx_pending;
		priv->tx_queue[i]->num_txbdfree = priv->tx_queue[i]->tx_ring_size;
	}

	/* Rebuild the rings with the new size */
	if (dev->flags & IFF_UP) {
		err = startup_gfar(dev);
		netif_tx_wake_all_queues(dev);
	}
	return err;
}

int gfar_set_features(struct net_device *dev, u32 features)
{
	struct gfar_private *priv = netdev_priv(dev);
	unsigned long flags;
	int err = 0, i = 0;
	u32 changed = dev->features ^ features;

	if (changed & (NETIF_F_HW_VLAN_TX|NETIF_F_HW_VLAN_RX))
		gfar_vlan_mode(dev, features);

	if (!(changed & NETIF_F_RXCSUM))
		return 0;

	if (dev->flags & IFF_UP) {
		/* Halt TX and RX, and process the frames which
		 * have already been received */
		local_irq_save(flags);
		lock_tx_qs(priv);
		lock_rx_qs(priv);

		gfar_halt(dev);

		unlock_tx_qs(priv);
		unlock_rx_qs(priv);
		local_irq_restore(flags);

		for (i = 0; i < priv->num_rx_queues; i++)
			gfar_clean_rx_ring(priv->rx_queue[i],
					priv->rx_queue[i]->rx_ring_size);

		/* Now we take down the rings to rebuild them */
		stop_gfar(dev);

		dev->features = features;

		err = startup_gfar(dev);
		netif_tx_wake_all_queues(dev);
	}
	return err;
}

static uint32_t gfar_get_msglevel(struct net_device *dev)
{
	struct gfar_private *priv = netdev_priv(dev);
	return priv->msg_enable;
}

static void gfar_set_msglevel(struct net_device *dev, uint32_t data)
{
	struct gfar_private *priv = netdev_priv(dev);
	priv->msg_enable = data;
}

#ifdef CONFIG_PM
static void gfar_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
	struct gfar_private *priv = netdev_priv(dev);

	if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) {
		wol->supported = WAKE_MAGIC;
		wol->wolopts = priv->wol_en ? WAKE_MAGIC : 0;
	} else {
		wol->supported = wol->wolopts = 0;
	}
}

static int gfar_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{
	struct gfar_private *priv = netdev_priv(dev);
	unsigned long flags;

	if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) &&
	    wol->wolopts != 0)
		return -EINVAL;

	if (wol->wolopts & ~WAKE_MAGIC)
		return -EINVAL;

	device_set_wakeup_enable(&dev->dev, wol->wolopts & WAKE_MAGIC);

	spin_lock_irqsave(&priv->bflock, flags);
	priv->wol_en =  !!device_may_wakeup(&dev->dev);
	spin_unlock_irqrestore(&priv->bflock, flags);

	return 0;
}
#endif

static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow)
{
	u32 fcr = 0x0, fpr = FPR_FILER_MASK;

	if (ethflow & RXH_L2DA) {
		fcr = RQFCR_PID_DAH |RQFCR_CMP_NOMATCH |
			RQFCR_HASH | RQFCR_AND | RQFCR_HASHTBL_0;
		priv->ftp_rqfpr[priv->cur_filer_idx] = fpr;
		priv->ftp_rqfcr[priv->cur_filer_idx] = fcr;
		gfar_write_filer(priv, priv->cur_filer_idx, fcr, fpr);
		priv->cur_filer_idx = priv->cur_filer_idx - 1;

		fcr = RQFCR_PID_DAL | RQFCR_AND | RQFCR_CMP_NOMATCH |
				RQFCR_HASH | RQFCR_AND | RQFCR_HASHTBL_0;
		priv->ftp_rqfpr[priv->cur_filer_idx] = fpr;
		priv->ftp_rqfcr[priv->cur_filer_idx] = fcr;
		gfar_write_filer(priv, priv->cur_filer_idx, fcr, fpr);
		priv->cur_filer_idx = priv->cur_filer_idx - 1;
	}

	if (ethflow & RXH_VLAN) {
		fcr = RQFCR_PID_VID | RQFCR_CMP_NOMATCH | RQFCR_HASH |
				RQFCR_AND | RQFCR_HASHTBL_0;
		gfar_write_filer(priv, priv->cur_filer_idx, fcr, fpr);
		priv->ftp_rqfpr[priv->cur_filer_idx] = fpr;
		priv->ftp_rqfcr[priv->cur_filer_idx] = fcr;
		priv->cur_filer_idx = priv->cur_filer_idx - 1;
	}

	if (ethflow & RXH_IP_SRC) {
		fcr = RQFCR_PID_SIA | RQFCR_CMP_NOMATCH | RQFCR_HASH |
			RQFCR_AND | RQFCR_HASHTBL_0;
		priv->ftp_rqfpr[priv->cur_filer_idx] = fpr;
		priv->ftp_rqfcr[priv->cur_filer_idx] = fcr;
		gfar_write_filer(priv, priv->cur_filer_idx, fcr, fpr);
		priv->cur_filer_idx = priv->cur_filer_idx - 1;
	}

	if (ethflow & (RXH_IP_DST)) {
		fcr = RQFCR_PID_DIA | RQFCR_CMP_NOMATCH | RQFCR_HASH |
			RQFCR_AND | RQFCR_HASHTBL_0;
		priv->ftp_rqfpr[priv->cur_filer_idx] = fpr;
		priv->ftp_rqfcr[priv->cur_filer_idx] = fcr;
		gfar_write_filer(priv, priv->cur_filer_idx, fcr, fpr);
		priv->cur_filer_idx = priv->cur_filer_idx - 1;
	}

	if (ethflow & RXH_L3_PROTO) {
		fcr = RQFCR_PID_L4P | RQFCR_CMP_NOMATCH | RQFCR_HASH |
			RQFCR_AND | RQFCR_HASHTBL_0;
		priv->ftp_rqfpr[priv->cur_filer_idx] = fpr;
		priv->ftp_rqfcr[priv->cur_filer_idx] = fcr;
		gfar_write_filer(priv, priv->cur_filer_idx, fcr, fpr);
		priv->cur_filer_idx = priv->cur_filer_idx - 1;
	}

	if (ethflow & RXH_L4_B_0_1) {
		fcr = RQFCR_PID_SPT | RQFCR_CMP_NOMATCH | RQFCR_HASH |
			RQFCR_AND | RQFCR_HASHTBL_0;
		priv->ftp_rqfpr[priv->cur_filer_idx] = fpr;
		priv->ftp_rqfcr[priv->cur_filer_idx] = fcr;
		gfar_write_filer(priv, priv->cur_filer_idx, fcr, fpr);
		priv->cur_filer_idx = priv->cur_filer_idx - 1;
	}

	if (ethflow & RXH_L4_B_2_3) {
		fcr = RQFCR_PID_DPT | RQFCR_CMP_NOMATCH | RQFCR_HASH |
			RQFCR_AND | RQFCR_HASHTBL_0;
		priv->ftp_rqfpr[priv->cur_filer_idx] = fpr;
		priv->ftp_rqfcr[priv->cur_filer_idx] = fcr;
		gfar_write_filer(priv, priv->cur_filer_idx, fcr, fpr);
		priv->cur_filer_idx = priv->cur_filer_idx - 1;
	}
}

static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, u64 class)
{
	unsigned int last_rule_idx = priv->cur_filer_idx;
	unsigned int cmp_rqfpr;
	unsigned int *local_rqfpr;
	unsigned int *local_rqfcr;
	int i = 0x0, k = 0x0;
	int j = MAX_FILER_IDX, l = 0x0;
	int ret = 1;

	local_rqfpr = kmalloc(sizeof(unsigned int) * (MAX_FILER_IDX + 1),
		GFP_KERNEL);
	local_rqfcr = kmalloc(sizeof(unsigned int) * (MAX_FILER_IDX + 1),
		GFP_KERNEL);
	if (!local_rqfpr || !local_rqfcr) {
		pr_err("Out of memory\n");
		ret = 0;
		goto err;
	}

	switch (class) {
	case TCP_V4_FLOW:
		cmp_rqfpr = RQFPR_IPV4 |RQFPR_TCP;
		break;
	case UDP_V4_FLOW:
		cmp_rqfpr = RQFPR_IPV4 |RQFPR_UDP;
		break;
	case TCP_V6_FLOW:
		cmp_rqfpr = RQFPR_IPV6 |RQFPR_TCP;
		break;
	case UDP_V6_FLOW:
		cmp_rqfpr = RQFPR_IPV6 |RQFPR_UDP;
		break;
	default:
		pr_err("Right now this class is not supported\n");
		ret = 0;
		goto err;
	}

	for (i = 0; i < MAX_FILER_IDX + 1; i++) {
		local_rqfpr[j] = priv->ftp_rqfpr[i];
		local_rqfcr[j] = priv->ftp_rqfcr[i];
		j--;
		if ((priv->ftp_rqfcr[i] == (RQFCR_PID_PARSE |
			RQFCR_CLE |RQFCR_AND)) &&
			(priv->ftp_rqfpr[i] == cmp_rqfpr))
			break;
	}

	if (i == MAX_FILER_IDX + 1) {
		pr_err("No parse rule found, can't create hash rules\n");
		ret = 0;
		goto err;
	}

	/* If a match was found, then it begins the starting of a cluster rule
	 * if it was already programmed, we need to overwrite these rules
	 */
	for (l = i+1; l < MAX_FILER_IDX; l++) {
		if ((priv->ftp_rqfcr[l] & RQFCR_CLE) &&
			!(priv->ftp_rqfcr[l] & RQFCR_AND)) {
			priv->ftp_rqfcr[l] = RQFCR_CLE | RQFCR_CMP_EXACT |
				RQFCR_HASHTBL_0 | RQFCR_PID_MASK;
			priv->ftp_rqfpr[l] = FPR_FILER_MASK;
			gfar_write_filer(priv, l, priv->ftp_rqfcr[l],
				priv->ftp_rqfpr[l]);
			break;
		}

		if (!(priv->ftp_rqfcr[l] & RQFCR_CLE) &&
			(priv->ftp_rqfcr[l] & RQFCR_AND))
			continue;
		else {
			local_rqfpr[j] = priv->ftp_rqfpr[l];
			local_rqfcr[j] = priv->ftp_rqfcr[l];
			j--;
		}
	}

	priv->cur_filer_idx = l - 1;
	last_rule_idx = l;

	/* hash rules */
	ethflow_to_filer_rules(priv, ethflow);

	/* Write back the popped out rules again */
	for (k = j+1; k < MAX_FILER_IDX; k++) {
		priv->ftp_rqfpr[priv->cur_filer_idx] = local_rqfpr[k];
		priv->ftp_rqfcr[priv->cur_filer_idx] = local_rqfcr[k];
		gfar_write_filer(priv, priv->cur_filer_idx,
				local_rqfcr[k], local_rqfpr[k]);
		if (!priv->cur_filer_idx)
			break;
		priv->cur_filer_idx = priv->cur_filer_idx - 1;
	}

err:
	kfree(local_rqfcr);
	kfree(local_rqfpr);
	return ret;
}

static int gfar_set_hash_opts(struct gfar_private *priv, struct ethtool_rxnfc *cmd)
{
	/* write the filer rules here */
	if (!gfar_ethflow_to_filer_table(priv, cmd->data, cmd->flow_type))
		return -EINVAL;

	return 0;
}

static int gfar_check_filer_hardware(struct gfar_private *priv)
{
	struct gfar __iomem *regs = NULL;
	u32 i;

	regs = priv->gfargrp[0].regs;

	/* Check if we are in FIFO mode */
	i = gfar_read(&regs->ecntrl);
	i &= ECNTRL_FIFM;
	if (i == ECNTRL_FIFM) {
		netdev_notice(priv->ndev, "Interface in FIFO mode\n");
		i = gfar_read(&regs->rctrl);
		i &= RCTRL_PRSDEP_MASK | RCTRL_PRSFM;
		if (i == (RCTRL_PRSDEP_MASK | RCTRL_PRSFM)) {
			netdev_info(priv->ndev,
					"Receive Queue Filtering enabled\n");
		} else {
			netdev_warn(priv->ndev,
					"Receive Queue Filtering disabled\n");
			return -EOPNOTSUPP;
		}
	}
	/* Or in standard mode */
	else {
		i = gfar_read(&regs->rctrl);
		i &= RCTRL_PRSDEP_MASK;
		if (i == RCTRL_PRSDEP_MASK) {
			netdev_info(priv->ndev,
					"Receive Queue Filtering enabled\n");
		} else {
			netdev_warn(priv->ndev,
					"Receive Queue Filtering disabled\n");
			return -EOPNOTSUPP;
		}
	}

	/* Sets the properties for arbitrary filer rule
	 * to the first 4 Layer 4 Bytes */
	regs->rbifx = 0xC0C1C2C3;
	return 0;
}

static int gfar_comp_asc(const void *a, const void *b)
{
	return memcmp(a, b, 4);
}

static int gfar_comp_desc(const void *a, const void *b)
{
	return -memcmp(a, b, 4);
}

static void gfar_swap(void *a, void *b, int size)
{
	u32 *_a = a;
	u32 *_b = b;

	swap(_a[0], _b[0]);
	swap(_a[1], _b[1]);
	swap(_a[2], _b[2]);
	swap(_a[3], _b[3]);
}

/* Write a mask to filer cache */
static void gfar_set_mask(u32 mask, struct filer_table *tab)
{
	tab->fe[tab->index].ctrl = RQFCR_AND | RQFCR_PID_MASK | RQFCR_CMP_EXACT;
	tab->fe[tab->index].prop = mask;
	tab->index++;
}

/* Sets parse bits (e.g. IP or TCP) */
static void gfar_set_parse_bits(u32 value, u32 mask, struct filer_table *tab)
{
	gfar_set_mask(mask, tab);
	tab->fe[tab->index].ctrl = RQFCR_CMP_EXACT | RQFCR_PID_PARSE
			| RQFCR_AND;
	tab->fe[tab->index].prop = value;
	tab->index++;
}

static void gfar_set_general_attribute(u32 value, u32 mask, u32 flag,
		struct filer_table *tab)
{
	gfar_set_mask(mask, tab);
	tab->fe[tab->index].ctrl = RQFCR_CMP_EXACT | RQFCR_AND | flag;
	tab->fe[tab->index].prop = value;
	tab->index++;
}

/*
 * For setting a tuple of value and mask of type flag
 * Example:
 * IP-Src = 10.0.0.0/255.0.0.0
 * value: 0x0A000000 mask: FF000000 flag: RQFPR_IPV4
 *
 * Ethtool gives us a value=0 and mask=~0 for don't care a tuple
 * For a don't care mask it gives us a 0
 *
 * The check if don't care and the mask adjustment if mask=0 is done for VLAN
 * and MAC stuff on an upper level (due to missing information on this level).
 * For these guys we can discard them if they are value=0 and mask=0.
 *
 * Further the all masks are one-padded for better hardware efficiency.
 */
static void gfar_set_attribute(u32 value, u32 mask, u32 flag,
		struct filer_table *tab)
{
	switch (flag) {
		/* 3bit */
	case RQFCR_PID_PRI:
		if (!(value | mask))
			return;
		mask |= RQFCR_PID_PRI_MASK;
		break;
		/* 8bit */
	case RQFCR_PID_L4P:
	case RQFCR_PID_TOS:
		if (!~(mask | RQFCR_PID_L4P_MASK))
			return;
		if (!mask)
			mask = ~0;
		else
			mask |= RQFCR_PID_L4P_MASK;
		break;
		/* 12bit */
	case RQFCR_PID_VID:
		if (!(value | mask))
			return;
		mask |= RQFCR_PID_VID_MASK;
		break;
		/* 16bit */
	case RQFCR_PID_DPT:
	case RQFCR_PID_SPT:
	case RQFCR_PID_ETY:
		if (!~(mask | RQFCR_PID_PORT_MASK))
			return;
		if (!mask)
			mask = ~0;
		else
			mask |= RQFCR_PID_PORT_MASK;
		break;
		/* 24bit */
	case RQFCR_PID_DAH:
	case RQFCR_PID_DAL:
	case RQFCR_PID_SAH:
	case RQFCR_PID_SAL:
		if (!(value | mask))
			return;
		mask |= RQFCR_PID_MAC_MASK;
		break;
		/* for all real 32bit masks */
	default:
		if (!~mask)
			return;
		if (!mask)
			mask = ~0;
		break;
	}
	gfar_set_general_attribute(value, mask, flag, tab);
}

/* Translates value and mask for UDP, TCP or SCTP */
static void gfar_set_basic_ip(struct ethtool_tcpip4_spec *value,
		struct ethtool_tcpip4_spec *mask, struct filer_table *tab)
{
	gfar_set_attribute(value->ip4src, mask->ip4src, RQFCR_PID_SIA, tab);
	gfar_set_attribute(value->ip4dst, mask->ip4dst, RQFCR_PID_DIA, tab);
	gfar_set_attribute(value->pdst, mask->pdst, RQFCR_PID_DPT, tab);
	gfar_set_attribute(value->psrc, mask->psrc, RQFCR_PID_SPT, tab);
	gfar_set_attribute(value->tos, mask->tos, RQFCR_PID_TOS, tab);
}

/* Translates value and mask for RAW-IP4 */
static void gfar_set_user_ip(struct ethtool_usrip4_spec *value,
		struct ethtool_usrip4_spec *mask, struct filer_table *tab)
{
	gfar_set_attribute(value->ip4src, mask->ip4src, RQFCR_PID_SIA, tab);
	gfar_set_attribute(value->ip4dst, mask->ip4dst, RQFCR_PID_DIA, tab);
	gfar_set_attribute(value->tos, mask->tos, RQFCR_PID_TOS, tab);
	gfar_set_attribute(value->proto, mask->proto, RQFCR_PID_L4P, tab);
	gfar_set_attribute(value->l4_4_bytes, mask->l4_4_bytes, RQFCR_PID_ARB,
			tab);

}

/* Translates value and mask for ETHER spec */
static void gfar_set_ether(struct ethhdr *value, struct ethhdr *mask,
		struct filer_table *tab)
{
	u32 upper_temp_mask = 0;
	u32 lower_temp_mask = 0;
	/* Source address */
	if (!is_broadcast_ether_addr(mask->h_source)) {

		if (is_zero_ether_addr(mask->h_source)) {
			upper_temp_mask = 0xFFFFFFFF;
			lower_temp_mask = 0xFFFFFFFF;
		} else {
			upper_temp_mask = mask->h_source[0] << 16
					| mask->h_source[1] << 8
					| mask->h_source[2];
			lower_temp_mask = mask->h_source[3] << 16
					| mask->h_source[4] << 8
					| mask->h_source[5];
		}
		/* Upper 24bit */
		gfar_set_attribute(
				value->h_source[0] << 16 | value->h_source[1]
						<< 8 | value->h_source[2],
				upper_temp_mask, RQFCR_PID_SAH, tab);
		/* And the same for the lower part */
		gfar_set_attribute(
				value->h_source[3] << 16 | value->h_source[4]
						<< 8 | value->h_source[5],
				lower_temp_mask, RQFCR_PID_SAL, tab);
	}
	/* Destination address */
	if (!is_broadcast_ether_addr(mask->h_dest)) {

		/* Special for destination is limited broadcast */
		if ((is_broadcast_ether_addr(value->h_dest)
				&& is_zero_ether_addr(mask->h_dest))) {
			gfar_set_parse_bits(RQFPR_EBC, RQFPR_EBC, tab);
		} else {

			if (is_zero_ether_addr(mask->h_dest)) {
				upper_temp_mask = 0xFFFFFFFF;
				lower_temp_mask = 0xFFFFFFFF;
			} else {
				upper_temp_mask = mask->h_dest[0] << 16
						| mask->h_dest[1] << 8
						| mask->h_dest[2];
				lower_temp_mask = mask->h_dest[3] << 16
						| mask->h_dest[4] << 8
						| mask->h_dest[5];
			}

			/* Upper 24bit */
			gfar_set_attribute(
					value->h_dest[0] << 16
							| value->h_dest[1] << 8
							| value->h_dest[2],
					upper_temp_mask, RQFCR_PID_DAH, tab);
			/* And the same for the lower part */
			gfar_set_attribute(
					value->h_dest[3] << 16
							| value->h_dest[4] << 8
							| value->h_dest[5],
					lower_temp_mask, RQFCR_PID_DAL, tab);
		}
	}

	gfar_set_attribute(value->h_proto, mask->h_proto, RQFCR_PID_ETY, tab);

}

/* Convert a rule to binary filter format of gianfar */
static int gfar_convert_to_filer(struct ethtool_rx_flow_spec *rule,
		struct filer_table *tab)
{
	u32 vlan = 0, vlan_mask = 0;
	u32 id = 0, id_mask = 0;
	u32 cfi = 0, cfi_mask = 0;
	u32 prio = 0, prio_mask = 0;

	u32 old_index = tab->index;

	/* Check if vlan is wanted */
	if ((rule->flow_type & FLOW_EXT) && (rule->m_ext.vlan_tci != 0xFFFF)) {
		if (!rule->m_ext.vlan_tci)
			rule->m_ext.vlan_tci = 0xFFFF;

		vlan = RQFPR_VLN;
		vlan_mask = RQFPR_VLN;

		/* Separate the fields */
		id = rule->h_ext.vlan_tci & VLAN_VID_MASK;
		id_mask = rule->m_ext.vlan_tci & VLAN_VID_MASK;
		cfi = rule->h_ext.vlan_tci & VLAN_CFI_MASK;
		cfi_mask = rule->m_ext.vlan_tci & VLAN_CFI_MASK;
		prio = (rule->h_ext.vlan_tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;
		prio_mask = (rule->m_ext.vlan_tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;

		if (cfi == VLAN_TAG_PRESENT && cfi_mask == VLAN_TAG_PRESENT) {
			vlan |= RQFPR_CFI;
			vlan_mask |= RQFPR_CFI;
		} else if (cfi != VLAN_TAG_PRESENT && cfi_mask == VLAN_TAG_PRESENT) {
			vlan_mask |= RQFPR_CFI;
		}
	}

	switch (rule->flow_type & ~FLOW_EXT) {
	case TCP_V4_FLOW:
		gfar_set_parse_bits(RQFPR_IPV4 | RQFPR_TCP | vlan,
				RQFPR_IPV4 | RQFPR_TCP | vlan_mask, tab);
		gfar_set_basic_ip(&rule->h_u.tcp_ip4_spec,
				&rule->m_u.tcp_ip4_spec, tab);
		break;
	case UDP_V4_FLOW:
		gfar_set_parse_bits(RQFPR_IPV4 | RQFPR_UDP | vlan,
				RQFPR_IPV4 | RQFPR_UDP | vlan_mask, tab);
		gfar_set_basic_ip(&rule->h_u.udp_ip4_spec,
				&rule->m_u.udp_ip4_spec, tab);
		break;
	case SCTP_V4_FLOW:
		gfar_set_parse_bits(RQFPR_IPV4 | vlan, RQFPR_IPV4 | vlan_mask,
				tab);
		gfar_set_attribute(132, 0, RQFCR_PID_L4P, tab);
		gfar_set_basic_ip((struct ethtool_tcpip4_spec *) &rule->h_u,
				(struct ethtool_tcpip4_spec *) &rule->m_u, tab);
		break;
	case IP_USER_FLOW:
		gfar_set_parse_bits(RQFPR_IPV4 | vlan, RQFPR_IPV4 | vlan_mask,
				tab);
		gfar_set_user_ip((struct ethtool_usrip4_spec *) &rule->h_u,
				(struct ethtool_usrip4_spec *) &rule->m_u, tab);
		break;
	case ETHER_FLOW:
		if (vlan)
			gfar_set_parse_bits(vlan, vlan_mask, tab);
		gfar_set_ether((struct ethhdr *) &rule->h_u,
				(struct ethhdr *) &rule->m_u, tab);
		break;
	default:
		return -1;
	}

	/* Set the vlan attributes in the end */
	if (vlan) {
		gfar_set_attribute(id, id_mask, RQFCR_PID_VID, tab);
		gfar_set_attribute(prio, prio_mask, RQFCR_PID_PRI, tab);
	}

	/* If there has been nothing written till now, it must be a default */
	if (tab->index == old_index) {
		gfar_set_mask(0xFFFFFFFF, tab);
		tab->fe[tab->index].ctrl = 0x20;
		tab->fe[tab->index].prop = 0x0;
		tab->index++;
	}

	/* Remove last AND */
	tab->fe[tab->index - 1].ctrl &= (~RQFCR_AND);

	/* Specify which queue to use or to drop */
	if (rule->ring_cookie == RX_CLS_FLOW_DISC)
		tab->fe[tab->index - 1].ctrl |= RQFCR_RJE;
	else
		tab->fe[tab->index - 1].ctrl |= (rule->ring_cookie << 10);

	/* Only big enough entries can be clustered */
	if (tab->index > (old_index + 2)) {
		tab->fe[old_index + 1].ctrl |= RQFCR_CLE;
		tab->fe[tab->index - 1].ctrl |= RQFCR_CLE;
	}

	/* In rare cases the cache can be full while there is free space in hw */
	if (tab->index > MAX_FILER_CACHE_IDX - 1)
		return -EBUSY;

	return 0;
}

/* Copy size filer entries */
static void gfar_copy_filer_entries(struct gfar_filer_entry dst[0],
		struct gfar_filer_entry src[0], s32 size)
{
	while (size > 0) {
		size--;
		dst[size].ctrl = src[size].ctrl;
		dst[size].prop = src[size].prop;
	}
}

/* Delete the contents of the filer-table between start and end
 * and collapse them */
static int gfar_trim_filer_entries(u32 begin, u32 end, struct filer_table *tab)
{
	int length;
	if (end > MAX_FILER_CACHE_IDX || end < begin)
		return -EINVAL;

	end++;
	length = end - begin;

	/* Copy */
	while (end < tab->index) {
		tab->fe[begin].ctrl = tab->fe[end].ctrl;
		tab->fe[begin++].prop = tab->fe[end++].prop;

	}
	/* Fill up with don't cares */
	while (begin < tab->index) {
		tab->fe[begin].ctrl = 0x60;
		tab->fe[begin].prop = 0xFFFFFFFF;
		begin++;
	}

	tab->index -= length;
	return 0;
}

/* Make space on the wanted location */
static int gfar_expand_filer_entries(u32 begin, u32 length,
		struct filer_table *tab)
{
	if (length == 0 || length + tab->index > MAX_FILER_CACHE_IDX || begin
			> MAX_FILER_CACHE_IDX)
		return -EINVAL;

	gfar_copy_filer_entries(&(tab->fe[begin + length]), &(tab->fe[begin]),
			tab->index - length + 1);

	tab->index += length;
	return 0;
}

static int gfar_get_next_cluster_start(int start, struct filer_table *tab)
{
	for (; (start < tab->index) && (start < MAX_FILER_CACHE_IDX - 1); start++) {
		if ((tab->fe[start].ctrl & (RQFCR_AND | RQFCR_CLE))
				== (RQFCR_AND | RQFCR_CLE))
			return start;
	}
	return -1;
}

static int gfar_get_next_cluster_end(int start, struct filer_table *tab)
{
	for (; (start < tab->index) && (start < MAX_FILER_CACHE_IDX - 1); start++) {
		if ((tab->fe[start].ctrl & (RQFCR_AND | RQFCR_CLE))
				== (RQFCR_CLE))
			return start;
	}
	return -1;
}

/*
 * Uses hardwares clustering option to reduce
 * the number of filer table entries
 */
static void gfar_cluster_filer(struct filer_table *tab)
{
	s32 i = -1, j, iend, jend;

	while ((i = gfar_get_next_cluster_start(++i, tab)) != -1) {
		j = i;
		while ((j = gfar_get_next_cluster_start(++j, tab)) != -1) {
			/*
			 * The cluster entries self and the previous one
			 * (a mask) must be identical!
			 */
			if (tab->fe[i].ctrl != tab->fe[j].ctrl)
				break;
			if (tab->fe[i].prop != tab->fe[j].prop)
				break;
			if (tab->fe[i - 1].ctrl != tab->fe[j - 1].ctrl)
				break;
			if (tab->fe[i - 1].prop != tab->fe[j - 1].prop)
				break;
			iend = gfar_get_next_cluster_end(i, tab);
			jend = gfar_get_next_cluster_end(j, tab);
			if (jend == -1 || iend == -1)
				break;
			/*
			 * First we make some free space, where our cluster
			 * element should be. Then we copy it there and finally
			 * delete in from its old location.
			 */

			if (gfar_expand_filer_entries(iend, (jend - j), tab)
					== -EINVAL)
				break;

			gfar_copy_filer_entries(&(tab->fe[iend + 1]),
					&(tab->fe[jend + 1]), jend - j);

			if (gfar_trim_filer_entries(jend - 1,
					jend + (jend - j), tab) == -EINVAL)
				return;

			/* Mask out cluster bit */
			tab->fe[iend].ctrl &= ~(RQFCR_CLE);
		}
	}
}

/* Swaps the masked bits of a1<>a2 and b1<>b2 */
static void gfar_swap_bits(struct gfar_filer_entry *a1,
		struct gfar_filer_entry *a2, struct gfar_filer_entry *b1,
		struct gfar_filer_entry *b2, u32 mask)
{
	u32 temp[4];
	temp[0] = a1->ctrl & mask;
	temp[1] = a2->ctrl & mask;
	temp[2] = b1->ctrl & mask;
	temp[3] = b2->ctrl & mask;

	a1->ctrl &= ~mask;
	a2->ctrl &= ~mask;
	b1->ctrl &= ~mask;
	b2->ctrl &= ~mask;

	a1->ctrl |= temp[1];
	a2->ctrl |= temp[0];
	b1->ctrl |= temp[3];
	b2->ctrl |= temp[2];
}

/*
 * Generate a list consisting of masks values with their start and
 * end of validity and block as indicator for parts belonging
 * together (glued by ANDs) in mask_table
 */
static u32 gfar_generate_mask_table(struct gfar_mask_entry *mask_table,
		struct filer_table *tab)
{
	u32 i, and_index = 0, block_index = 1;

	for (i = 0; i < tab->index; i++) {

		/* LSByte of control = 0 sets a mask */
		if (!(tab->fe[i].ctrl & 0xF)) {
			mask_table[and_index].mask = tab->fe[i].prop;
			mask_table[and_index].start = i;
			mask_table[and_index].block = block_index;
			if (and_index >= 1)
				mask_table[and_index - 1].end = i - 1;
			and_index++;
		}
		/* cluster starts and ends will be separated because they should
		 * hold their position */
		if (tab->fe[i].ctrl & RQFCR_CLE)
			block_index++;
		/* A not set AND indicates the end of a depended block */
		if (!(tab->fe[i].ctrl & RQFCR_AND))
			block_index++;

	}

	mask_table[and_index - 1].end = i - 1;

	return and_index;
}

/*
 * Sorts the entries of mask_table by the values of the masks.
 * Important: The 0xFF80 flags of the first and last entry of a
 * block must hold their position (which queue, CLusterEnable, ReJEct,
 * AND)
 */
static void gfar_sort_mask_table(struct gfar_mask_entry *mask_table,
		struct filer_table *temp_table, u32 and_index)
{
	/* Pointer to compare function (_asc or _desc) */
	int (*gfar_comp)(const void *, const void *);

	u32 i, size = 0, start = 0, prev = 1;
	u32 old_first, old_last, new_first, new_last;

	gfar_comp = &gfar_comp_desc;

	for (i = 0; i < and_index; i++) {

		if (prev != mask_table[i].block) {
			old_first = mask_table[start].start + 1;
			old_last = mask_table[i - 1].end;
			sort(mask_table + start, size,
					sizeof(struct gfar_mask_entry),
					gfar_comp, &gfar_swap);

			/* Toggle order for every block. This makes the
			 * thing more efficient! */
			if (gfar_comp == gfar_comp_desc)
				gfar_comp = &gfar_comp_asc;
			else
				gfar_comp = &gfar_comp_desc;

			new_first = mask_table[start].start + 1;
			new_last = mask_table[i - 1].end;

			gfar_swap_bits(&temp_table->fe[new_first],
					&temp_table->fe[old_first],
					&temp_table->fe[new_last],
					&temp_table->fe[old_last],
					RQFCR_QUEUE | RQFCR_CLE |
						RQFCR_RJE | RQFCR_AND
					);

			start = i;
			size = 0;
		}
		size++;
		prev = mask_table[i].block;
	}

}

/*
 * Reduces the number of masks needed in the filer table to save entries
 * This is done by sorting the masks of a depended block. A depended block is
 * identified by gluing ANDs or CLE. The sorting order toggles after every
 * block. Of course entries in scope of a mask must change their location with
 * it.
 */
static int gfar_optimize_filer_masks(struct filer_table *tab)
{
	struct filer_table *temp_table;
	struct gfar_mask_entry *mask_table;

	u32 and_index = 0, previous_mask = 0, i = 0, j = 0, size = 0;
	s32 ret = 0;

	/* We need a copy of the filer table because
	 * we want to change its order */
	temp_table = kmalloc(sizeof(*temp_table), GFP_KERNEL);
	if (temp_table == NULL)
		return -ENOMEM;
	memcpy(temp_table, tab, sizeof(*temp_table));

	mask_table = kcalloc(MAX_FILER_CACHE_IDX / 2 + 1,
			sizeof(struct gfar_mask_entry), GFP_KERNEL);

	if (mask_table == NULL) {
		ret = -ENOMEM;
		goto end;
	}

	and_index = gfar_generate_mask_table(mask_table, tab);

	gfar_sort_mask_table(mask_table, temp_table, and_index);

	/* Now we can copy the data from our duplicated filer table to
	 * the real one in the order the mask table says */
	for (i = 0; i < and_index; i++) {
		size = mask_table[i].end - mask_table[i].start + 1;
		gfar_copy_filer_entries(&(tab->fe[j]),
				&(temp_table->fe[mask_table[i].start]), size);
		j += size;
	}

	/* And finally we just have to check for duplicated masks and drop the
	 * second ones */
	for (i = 0; i < tab->index && i < MAX_FILER_CACHE_IDX; i++) {
		if (tab->fe[i].ctrl == 0x80) {
			previous_mask = i++;
			break;
		}
	}
	for (; i < tab->index && i < MAX_FILER_CACHE_IDX; i++) {
		if (tab->fe[i].ctrl == 0x80) {
			if (tab->fe[i].prop == tab->fe[previous_mask].prop) {
				/* Two identical ones found!
				 * So drop the second one! */
				gfar_trim_filer_entries(i, i, tab);
			} else
				/* Not identical! */
				previous_mask = i;
		}
	}

	kfree(mask_table);
end:	kfree(temp_table);
	return ret;
}

/* Write the bit-pattern from software's buffer to hardware registers */
static int gfar_write_filer_table(struct gfar_private *priv,
		struct filer_table *tab)
{
	u32 i = 0;
	if (tab->index > MAX_FILER_IDX - 1)
		return -EBUSY;

	/* Avoid inconsistent filer table to be processed */
	lock_rx_qs(priv);

	/* Fill regular entries */
	for (; i < MAX_FILER_IDX - 1 && (tab->fe[i].ctrl | tab->fe[i].ctrl); i++)
		gfar_write_filer(priv, i, tab->fe[i].ctrl, tab->fe[i].prop);
	/* Fill the rest with fall-troughs */
	for (; i < MAX_FILER_IDX - 1; i++)
		gfar_write_filer(priv, i, 0x60, 0xFFFFFFFF);
	/* Last entry must be default accept
	 * because that's what people expect */
	gfar_write_filer(priv, i, 0x20, 0x0);

	unlock_rx_qs(priv);

	return 0;
}

static int gfar_check_capability(struct ethtool_rx_flow_spec *flow,
		struct gfar_private *priv)
{

	if (flow->flow_type & FLOW_EXT)	{
		if (~flow->m_ext.data[0] || ~flow->m_ext.data[1])
			netdev_warn(priv->ndev,
					"User-specific data not supported!\n");
		if (~flow->m_ext.vlan_etype)
			netdev_warn(priv->ndev,
					"VLAN-etype not supported!\n");
	}
	if (flow->flow_type == IP_USER_FLOW)
		if (flow->h_u.usr_ip4_spec.ip_ver != ETH_RX_NFC_IP4)
			netdev_warn(priv->ndev,
					"IP-Version differing from IPv4 not supported!\n");

	return 0;
}

static int gfar_process_filer_changes(struct gfar_private *priv)
{
	struct ethtool_flow_spec_container *j;
	struct filer_table *tab;
	s32 i = 0;
	s32 ret = 0;

	/* So index is set to zero, too! */
	tab = kzalloc(sizeof(*tab), GFP_KERNEL);
	if (tab == NULL)
		return -ENOMEM;

	/* Now convert the existing filer data from flow_spec into
	 * filer tables binary format */
	list_for_each_entry(j, &priv->rx_list.list, list) {
		ret = gfar_convert_to_filer(&j->fs, tab);
		if (ret == -EBUSY) {
			netdev_err(priv->ndev, "Rule not added: No free space!\n");
			goto end;
		}
		if (ret == -1) {
			netdev_err(priv->ndev, "Rule not added: Unsupported Flow-type!\n");
			goto end;
		}
	}

	i = tab->index;

	/* Optimizations to save entries */
	gfar_cluster_filer(tab);
	gfar_optimize_filer_masks(tab);

	pr_debug("\n\tSummary:\n"
		"\tData on hardware: %d\n"
		"\tCompression rate: %d%%\n",
		tab->index, 100 - (100 * tab->index) / i);

	/* Write everything to hardware */
	ret = gfar_write_filer_table(priv, tab);
	if (ret == -EBUSY) {
		netdev_err(priv->ndev, "Rule not added: No free space!\n");
		goto end;
	}

end:	kfree(tab);
	return ret;
}

static void gfar_invert_masks(struct ethtool_rx_flow_spec *flow)
{
	u32 i = 0;

	for (i = 0; i < sizeof(flow->m_u); i++)
		flow->m_u.hdata[i] ^= 0xFF;

	flow->m_ext.vlan_etype ^= 0xFFFF;
	flow->m_ext.vlan_tci ^= 0xFFFF;
	flow->m_ext.data[0] ^= ~0;
	flow->m_ext.data[1] ^= ~0;
}

static int gfar_add_cls(struct gfar_private *priv,
		struct ethtool_rx_flow_spec *flow)
{
	struct ethtool_flow_spec_container *temp, *comp;
	int ret = 0;

	temp = kmalloc(sizeof(*temp), GFP_KERNEL);
	if (temp == NULL)
		return -ENOMEM;
	memcpy(&temp->fs, flow, sizeof(temp->fs));

	gfar_invert_masks(&temp->fs);
	ret = gfar_check_capability(&temp->fs, priv);
	if (ret)
		goto clean_mem;
	/* Link in the new element at the right @location */
	if (list_empty(&priv->rx_list.list)) {
		ret = gfar_check_filer_hardware(priv);
		if (ret != 0)
			goto clean_mem;
		list_add(&temp->list, &priv->rx_list.list);
		goto process;
	} else {

		list_for_each_entry(comp, &priv->rx_list.list, list) {
			if (comp->fs.location > flow->location) {
				list_add_tail(&temp->list, &comp->list);
				goto process;
			}
			if (comp->fs.location == flow->location) {
				netdev_err(priv->ndev,
						"Rule not added: ID %d not free!\n",
					flow->location);
				ret = -EBUSY;
				goto clean_mem;
			}
		}
		list_add_tail(&temp->list, &priv->rx_list.list);
	}

process:
	ret = gfar_process_filer_changes(priv);
	if (ret)
		goto clean_list;
	priv->rx_list.count++;
	return ret;

clean_list:
	list_del(&temp->list);
clean_mem:
	kfree(temp);
	return ret;
}

static int gfar_del_cls(struct gfar_private *priv, u32 loc)
{
	struct ethtool_flow_spec_container *comp;
	u32 ret = -EINVAL;

	if (list_empty(&priv->rx_list.list))
		return ret;

	list_for_each_entry(comp, &priv->rx_list.list, list) {
		if (comp->fs.location == loc) {
			list_del(&comp->list);
			kfree(comp);
			priv->rx_list.count--;
			gfar_process_filer_changes(priv);
			ret = 0;
			break;
		}
	}

	return ret;

}

static int gfar_get_cls(struct gfar_private *priv, struct ethtool_rxnfc *cmd)
{
	struct ethtool_flow_spec_container *comp;
	u32 ret = -EINVAL;

	list_for_each_entry(comp, &priv->rx_list.list, list) {
		if (comp->fs.location == cmd->fs.location) {
			memcpy(&cmd->fs, &comp->fs, sizeof(cmd->fs));
			gfar_invert_masks(&cmd->fs);
			ret = 0;
			break;
		}
	}

	return ret;
}

static int gfar_get_cls_all(struct gfar_private *priv,
		struct ethtool_rxnfc *cmd, u32 *rule_locs)
{
	struct ethtool_flow_spec_container *comp;
	u32 i = 0;

	list_for_each_entry(comp, &priv->rx_list.list, list) {
		if (i == cmd->rule_cnt)
			return -EMSGSIZE;
		rule_locs[i] = comp->fs.location;
		i++;
	}

	cmd->data = MAX_FILER_IDX;

	return 0;
}

static int gfar_set_nfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
{
	struct gfar_private *priv = netdev_priv(dev);
	int ret = 0;

	mutex_lock(&priv->rx_queue_access);

	switch (cmd->cmd) {
	case ETHTOOL_SRXFH:
		ret = gfar_set_hash_opts(priv, cmd);
		break;
	case ETHTOOL_SRXCLSRLINS:
		if (cmd->fs.ring_cookie != RX_CLS_FLOW_DISC &&
			cmd->fs.ring_cookie >= priv->num_rx_queues) {
			ret = -EINVAL;
			break;
		}
		ret = gfar_add_cls(priv, &cmd->fs);
		break;
	case ETHTOOL_SRXCLSRLDEL:
		ret = gfar_del_cls(priv, cmd->fs.location);
		break;
	default:
		ret = -EINVAL;
	}

	mutex_unlock(&priv->rx_queue_access);

	return ret;
}

static int gfar_get_nfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
		void *rule_locs)
{
	struct gfar_private *priv = netdev_priv(dev);
	int ret = 0;

	switch (cmd->cmd) {
	case ETHTOOL_GRXRINGS:
		cmd->data = priv->num_rx_queues;
		break;
	case ETHTOOL_GRXCLSRLCNT:
		cmd->rule_cnt = priv->rx_list.count;
		break;
	case ETHTOOL_GRXCLSRULE:
		ret = gfar_get_cls(priv, cmd);
		break;
	case ETHTOOL_GRXCLSRLALL:
		ret = gfar_get_cls_all(priv, cmd, (u32 *) rule_locs);
		break;
	default:
		ret = -EINVAL;
		break;
	}

	return ret;
}

const struct ethtool_ops gfar_ethtool_ops = {
	.get_settings = gfar_gsettings,
	.set_settings = gfar_ssettings,
	.get_drvinfo = gfar_gdrvinfo,
	.get_regs_len = gfar_reglen,
	.get_regs = gfar_get_regs,
	.get_link = ethtool_op_get_link,
	.get_coalesce = gfar_gcoalesce,
	.set_coalesce = gfar_scoalesce,
	.get_ringparam = gfar_gringparam,
	.set_ringparam = gfar_sringparam,
	.get_strings = gfar_gstrings,
	.get_sset_count = gfar_sset_count,
	.get_ethtool_stats = gfar_fill_stats,
	.get_msglevel = gfar_get_msglevel,
	.set_msglevel = gfar_set_msglevel,
#ifdef CONFIG_PM
	.get_wol = gfar_get_wol,
	.set_wol = gfar_set_wol,
#endif
	.set_rxnfc = gfar_set_nfc,
	.get_rxnfc = gfar_get_nfc,
};


text:
using System.Text.RegularExpressions;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Tagging;

namespace Emoji.Tagging
{
	internal sealed class EmojiTagger : RegexTagger<EmojiTag>
	{
		private readonly IEmojiStore _store;
		private readonly IEmojiLocationHandler _locationHandler;

		internal EmojiTagger(ITextBuffer buffer, IEmojiStore store, IEmojiLocationHandler locationHandler)
			: base(buffer, new Regex(@":(?<name>[0-9a-zA-Z\-\+_]+):", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase))
		{
			_store = store;
			_locationHandler = locationHandler;
		}

		protected override EmojiTag TryCreateTagForMatch(Match match)
		{
			var name = match.Groups["name"].Value;

			Emoji emoji;
			return _store.TryGetEmoji(name, out emoji)
				? new EmojiTag(emoji)
				: null;
		}

		protected override ITagSpan<EmojiTag> TryCreateTagSpan(SnapshotSpan span, EmojiTag tag)
		{
			return _locationHandler.CanHazEmoji(span)
				? new TagSpan<EmojiTag>(span, tag)
				: null;
		}
	}
}


text:
var clearValues = function(){
 	$('#day').val("").focus();
	$('#name').val("");
	$('#link').val("");
}

//Cancel events for form filling
var okCancelEvents = function (selector, callbacks) {
  var ok = callbacks.ok || function () {};
  var cancel = callbacks.cancel || function () {};

  var events = {};
  events['keyup '+selector+', keydown '+selector+', focusout '+selector] =
    function (evt) {
      if (evt.type === "keydown" && evt.which === 27) {
        // escape = cancel
        cancel.call(this, evt);

      } else if (evt.type === "keyup" && evt.which === 13) {
        // blur/return/enter = ok/submit if non-empty
        var value = String(evt.target.value || "");
        if (value)
          ok.call(this, value, evt);
        else
          cancel.call(this, evt);
      }
    };

  return events;
};

//create Meteor.Collection for project
Projects = new Meteor.Collection ("projects");

//list all projects into the webpage
if (Meteor.isClient) {
  Template.main.projects = function(){
	return Projects.find();
}

//Save input text into Meteor.Collection of projects
Template.main.events(okCancelEvents(
	'#link',
	{
		ok: function (text, evt) {
			var day = $('#day').val();
			var name = $('#name').val();
			Projects.insert({day:day,name:name,link:text});
		clearValues();
		}
	}));
}

if (Meteor.isServer) {

}


text:
<?php
namespace Core\Controller;

use Core\Model\Column;

use Core\Model\Table;
use Core\Model\Route;
use Core\Model\Action;
use Core\Model\Controller;
use Core\Model\ArrayToTextParser;
use Core\Model\Module;
use Core\Model\Create;

class SetupController extends AbstractController
{
    public function createAction()
    {
        $create = new Create();
        $create->create($this->getConsole());
    }

    public function createModuleAction()
    {
        $p = $this->getRequest()->getParams();
        $module = new Module();
        $module->setConsole($this->getConsole());
        $module->create($p['name']);
    }

    public function createControllerAction()
    {
        $params = $this->getRequest()->getParams();
        $name   = $params['name'];

        $controller = new Controller();
        $controller->setConsole($this->getConsole());
        $controller->create($name);
    }

    public function createActionAction()
    {
        $action = new Action();
        $action->setConsole($this->getConsole());
        $action->create();
    }

    public function createRouteAction()
    {
    	$routes = new Route();
    	$routes->setConsole($this->getConsole());
    	$routes->create();
    }

    public function createTableAction()
    {
        $table = new Table();
        $table->setConsole($this->getConsole());
        $table->create();
    }

    public function addColumnAction()
    {
        $columm = new Column();
        $columm->setConsole($this->getConsole());
        $columm->create();
    }
}


text:
package org.jetbrains.idea.svn.commandLine;

import consulo.util.dataholder.Key;

/**
 * @author Konstantin Kolosovsky.
 */
public class LineCommandAdapter implements LineCommandListener {

  private boolean myCancelled;

  @Override
  public void cancel() {
    myCancelled = true;
  }

  @Override
  public boolean isCanceled() {
    return myCancelled;
  }

  @Override
  public void onLineAvailable(String line, Key outputType) {
  }

  @Override
  public void processTerminated(int exitCode) {
  }

  @Override
  public void startFailed(Throwable exception) {
  }
}


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

    <include layout="@layout/activity_main_wide" />
</merge>


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

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">

	<bean id="processEngineConfiguration"
		class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">

		<!-- Database configurations -->
		<property name="history" value="audit" />
		<property name="databaseSchemaUpdate" value="true" />

		<!-- job executor configurations -->
		<property name="jobExecutorActivate" value="false" />

		<property name="bpmnParseFactory">
			<bean class="com.mossle.bpm.converter.MyBpmnParseFactory" />
		</property>

		<property name="postBpmnParseHandlers">
			<list>
				<bean class="com.mossle.bpm.converter.extend.handlers.MyStartEventParseHandler" />
				<bean class="com.mossle.bpm.converter.extend.handlers.MyUserTaskParseHandler" />
			</list>
		</property>

	</bean>

</beans>


text:
package com.facebook.buck.features.apple.project;

import com.facebook.buck.core.util.immutables.BuckStyleTuple;
import java.nio.file.Path;
import org.immutables.value.Value;

@Value.Immutable
@BuckStyleTuple
abstract class AbstractCopyInXcode {

  public enum SourceType {
    FILE,
    FOLDER_CONTENTS,
  }

  public enum DestinationBase {
    UNLOCALIZED_RESOURCES,
    TEMPDIR,
  }

  public abstract SourceType getSourceType();

  public abstract Path getSourcePath();

  public abstract DestinationBase getDestinationBase();

  public abstract Path getDestinationPath();
}


text:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.containerinstance.fluent.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;

/** The information for the output stream from container attach. */
@Fluent
public final class ContainerAttachResponseInner {
    /*
     * The uri for the output stream from the attach.
     */
    @JsonProperty(value = "webSocketUri")
    private String webSocketUri;

    /*
     * The password to the output stream from the attach. Send as an
     * Authorization header value when connecting to the websocketUri.
     */
    @JsonProperty(value = "password")
    private String password;

    /**
     * Get the webSocketUri property: The uri for the output stream from the attach.
     *
     * @return the webSocketUri value.
     */
    public String webSocketUri() {
        return this.webSocketUri;
    }

    /**
     * Set the webSocketUri property: The uri for the output stream from the attach.
     *
     * @param webSocketUri the webSocketUri value to set.
     * @return the ContainerAttachResponseInner object itself.
     */
    public ContainerAttachResponseInner withWebSocketUri(String webSocketUri) {
        this.webSocketUri = webSocketUri;
        return this;
    }

    /**
     * Get the password property: The password to the output stream from the attach. Send as an Authorization header
     * value when connecting to the websocketUri.
     *
     * @return the password value.
     */
    public String password() {
        return this.password;
    }

    /**
     * Set the password property: The password to the output stream from the attach. Send as an Authorization header
     * value when connecting to the websocketUri.
     *
     * @param password the password value to set.
     * @return the ContainerAttachResponseInner object itself.
     */
    public ContainerAttachResponseInner withPassword(String password) {
        this.password = password;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
    }
}


text:
gtf-to-gff3(1) -- convert GTF file to GFF3 format
=====================================================================================

## SYNOPSIS

`gtf-to-gff3` GTF_FILE [OPTIONS]

`gtf-to-gff3` --version

## DESCRIPTION

**gtf-to-gff3** takes a GTF file and converts the data in that file
to GFF3 format. The default output is stdout, but the `-o` option can
be used to use an output file instead.

The difference between these two formats is in the format of the
ninth column, and all this tool is doing is to change the attributes
column from the GTF format to GFF3 format.

stdin can be used as the data source if "-" is specified instead of
the input file.

## OPTIONS

General options:

 * `-o`, `--output OUT`:
   Output will be written to the file <var>out</var>, instead of stdout.

 * `--version`:
   Output version information and exit.

## BUGS

See https://github.com/mamarjan/gff3-pltools/issues

## COPYRIGHT

`gtf-to-gff3` is copyright (C) 2012 Marjan Povolni.

## SEE ALSO

gff3-filter(1), gff3-ffetch(1), gff3-select(1)

[SYNOPSIS]: #SYNOPSIS "SYNOPSIS"
[DESCRIPTION]: #DESCRIPTION "DESCRIPTION"
[OPTIONS]: #OPTIONS "OPTIONS"
[BUGS]: #BUGS "BUGS"
[COPYRIGHT]: #COPYRIGHT "COPYRIGHT"
[SEE ALSO]: #SEE-ALSO "SEE ALSO"

[gff3-count-features(1)]: gff3-count-features.1.html
[gff3-to-gtf(1)]: gff3-to-gtf.1.html
[gff3-ffetch(1)]: gff3-ffetch.1.html
[gff3-to-json(1)]: gff3-to-json.1.html
[gff3-sort(1)]: gff3-sort.1.html
[gtf-to-gff3(1)]: gtf-to-gff3.1.html
[gff3-select(1)]: gff3-select.1.html
[gff3-filter(1)]: gff3-filter.1.html


text:
package com.griddynamics.jagger.invoker;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.griddynamics.jagger.invoker.Invokers.doNothing;
import static com.griddynamics.jagger.invoker.Invokers.emptyListener;

import com.griddynamics.jagger.engine.e1.collector.invocation.InvocationListener;

/**
 * Encapsulates algorithm of load testing.
 *
 * @author Mairbek Khadikov
 */
public abstract class Scenario<Q, R, E> {

    // strange program design - listeners look like foreign elements
    private LoadInvocationListener<Q, R, E> listener = doNothing();
    private InvocationListener<Q, R, E> invocationListener = emptyListener();

    @Deprecated
    protected LoadInvocationListener<Q, R, E> getListener() {
        return listener;
    }

    // from 1.2.4 all listeners are wrapped in loadInvocationListener
    @Deprecated
    public void setListener(LoadInvocationListener<Q, R, E> listener) {
        checkNotNull(listener);
        this.listener = Invokers.logErrors(listener);
    }

    protected InvocationListener<Q, R, E> getInvocationListener(){
        return invocationListener;
    }

    public void setInvocationListener(InvocationListener<Q, R, E> invocationListener) {
        checkNotNull(invocationListener);
        this.invocationListener = invocationListener;
    }

    /**
     * Executes load testing unit of work
     * @return {@code true} if any useful work (i.e. some load testing) was done during the transaction
     * {@code false} either (for example, when all planned testing is done already)
     */
    public abstract boolean doTransaction();

}


text:
namespace TraktApiSharp.Tests.Objects.Get.Shows.Json.Writer
{
    public partial class ShowWatchedProgressObjectJsonWriter_Tests
    {

    }
}


text:
"""
    Stakeholder engagement API

    This API enables Intelligent Engagement for your Business. iEngage is a platform that combines process, augmented intelligence and rewards to help you intelligently engage customers.

    OpenAPI spec version: 1.0

    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

from __future__ import absolute_import

import os
import sys
import unittest

import iengage_client
from iengage_client.rest import ApiException
from iengage_client.models.verve_response_idea import VerveResponseIdea

class TestVerveResponseIdea(unittest.TestCase):
    """ VerveResponseIdea unit test stubs """

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def testVerveResponseIdea(self):
        """
        Test VerveResponseIdea
        """
        model = iengage_client.models.verve_response_idea.VerveResponseIdea()

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