text:
using System;
using System.Linq;
using System.Threading.Tasks;
using Abp.Collections.Extensions;
using Abp.Dependency;
using Abp.Localization;
using Abp.Threading;

namespace Abp.Authorization
{
    /// <summary>
    /// Extension methods for <see cref="IPermissionChecker"/>
    /// </summary>
    public static class PermissionCheckerExtensions
    {
        /// <summary>
        /// Checks if given user is granted for given permission.
        /// </summary>
        /// <param name="permissionChecker">Permission checker</param>
        /// <param name="user">User</param>
        /// <param name="requiresAll">True, to require all given permissions are granted. False, to require one or more.</param>
        /// <param name="permissionNames">Name of the permissions</param>
        public static async Task<bool> IsGrantedAsync(this IPermissionChecker permissionChecker, UserIdentifier user, bool requiresAll, params string[] permissionNames)
        {
            if (permissionNames.IsNullOrEmpty())
            {
                return true;
            }

            if (requiresAll)
            {
                foreach (var permissionName in permissionNames)
                {
                    if (!(await permissionChecker.IsGrantedAsync(user, permissionName)))
                    {
                        return false;
                    }
                }

                return true;
            }
            else
            {
                foreach (var permissionName in permissionNames)
                {
                    if (await permissionChecker.IsGrantedAsync(user, permissionName))
                    {
                        return true;
                    }
                }

                return false;
            }
        }

        /// <summary>
        /// Checks if given user is granted for given permission.
        /// </summary>
        /// <param name="permissionChecker">Permission checker</param>
        /// <param name="user">User</param>
        /// <param name="requiresAll">True, to require all given permissions are granted. False, to require one or more.</param>
        /// <param name="permissionNames">Name of the permissions</param>
        public static bool IsGranted(this IPermissionChecker permissionChecker, UserIdentifier user, bool requiresAll, params string[] permissionNames)
        {
            if (permissionNames.IsNullOrEmpty())
            {
                return true;
            }

            if (requiresAll)
            {
                foreach (var permissionName in permissionNames)
                {
                    if (!(permissionChecker.IsGranted(user, permissionName)))
                    {
                        return false;
                    }
                }

                return true;
            }
            else
            {
                foreach (var permissionName in permissionNames)
                {
                    if (permissionChecker.IsGranted(user, permissionName))
                    {
                        return true;
                    }
                }

                return false;
            }
        }

        /// <summary>
        /// Checks if current user is granted for given permission.
        /// </summary>
        /// <param name="permissionChecker">Permission checker</param>
        /// <param name="requiresAll">True, to require all given permissions are granted. False, to require one or more.</param>
        /// <param name="permissionNames">Name of the permissions</param>
        public static async Task<bool> IsGrantedAsync(this IPermissionChecker permissionChecker, bool requiresAll, params string[] permissionNames)
        {
            if (permissionNames.IsNullOrEmpty())
            {
                return true;
            }

            if (requiresAll)
            {
                foreach (var permissionName in permissionNames)
                {
                    if (!(await permissionChecker.IsGrantedAsync(permissionName)))
                    {
                        return false;
                    }
                }

                return true;
            }
            else
            {
                foreach (var permissionName in permissionNames)
                {
                    if (await permissionChecker.IsGrantedAsync(permissionName))
                    {
                        return true;
                    }
                }

                return false;
            }
        }

        /// <summary>
        /// Checks if current user is granted for given permission.
        /// </summary>
        /// <param name="permissionChecker">Permission checker</param>
        /// <param name="requiresAll">True, to require all given permissions are granted. False, to require one or more.</param>
        /// <param name="permissionNames">Name of the permissions</param>
        public static bool IsGranted(this IPermissionChecker permissionChecker, bool requiresAll, params string[] permissionNames)
        {
            if (permissionNames.IsNullOrEmpty())
            {
                return true;
            }

            if (requiresAll)
            {
                foreach (var permissionName in permissionNames)
                {
                    if (!(permissionChecker.IsGranted(permissionName)))
                    {
                        return false;
                    }
                }

                return true;
            }
            else
            {
                foreach (var permissionName in permissionNames)
                {
                    if (permissionChecker.IsGranted(permissionName))
                    {
                        return true;
                    }
                }

                return false;
            }
        }

        /// <summary>
        /// Authorizes current user for given permission or permissions,
        /// throws <see cref="AbpAuthorizationException"/> if not authorized.
        /// User it authorized if any of the <see cref="permissionNames"/> are granted.
        /// </summary>
        /// <param name="permissionChecker">Permission checker</param>
        /// <param name="permissionNames">Name of the permissions to authorize</param>
        /// <exception cref="AbpAuthorizationException">Throws authorization exception if</exception>
        public static Task AuthorizeAsync(this IPermissionChecker permissionChecker, params string[] permissionNames)
        {
            return AuthorizeAsync(permissionChecker, false, permissionNames);
        }

        /// <summary>
        /// Authorizes current user for given permission or permissions,
        /// throws <see cref="AbpAuthorizationException"/> if not authorized.
        /// User it authorized if any of the <see cref="permissionNames"/> are granted.
        /// </summary>
        /// <param name="permissionChecker">Permission checker</param>
        /// <param name="permissionNames">Name of the permissions to authorize</param>
        /// <exception cref="AbpAuthorizationException">Throws authorization exception if</exception>
        public static void Authorize(this IPermissionChecker permissionChecker, params string[] permissionNames)
        {
            Authorize(permissionChecker, false, permissionNames);
        }

        /// <summary>
        /// Authorizes current user for given permission or permissions,
        /// throws <see cref="AbpAuthorizationException"/> if not authorized.
        /// </summary>
        /// <param name="permissionChecker">Permission checker</param>
        /// <param name="requireAll">
        /// If this is set to true, all of the <see cref="permissionNames"/> must be granted.
        /// If it's false, at least one of the <see cref="permissionNames"/> must be granted.
        /// </param>
        /// <param name="permissionNames">Name of the permissions to authorize</param>
        /// <exception cref="AbpAuthorizationException">Throws authorization exception if</exception>
        public static async Task AuthorizeAsync(this IPermissionChecker permissionChecker, bool requireAll, params string[] permissionNames)
        {
            if (await IsGrantedAsync(permissionChecker, requireAll, permissionNames))
            {
                return;
            }

            var localizedPermissionNames = LocalizePermissionNames(permissionChecker, permissionNames);

            if (requireAll)
            {
                throw new AbpAuthorizationException(
                    string.Format(
                        L(
                            permissionChecker,
                            "AllOfThesePermissionsMustBeGranted",
                            "Required permissions are not granted. All of these permissions must be granted: {0}"
                        ),
                        string.Join(", ", localizedPermissionNames)
                    )
                );
            }
            else
            {
                throw new AbpAuthorizationException(
                    string.Format(
                        L(
                            permissionChecker,
                            "AtLeastOneOfThesePermissionsMustBeGranted",
                            "Required permissions are not granted. At least one of these permissions must be granted: {0}"
                        ),
                        string.Join(", ", localizedPermissionNames)
                    )
                );
            }
        }

        /// <summary>
        /// Authorizes current user for given permission or permissions,
        /// throws <see cref="AbpAuthorizationException"/> if not authorized.
        /// </summary>
        /// <param name="permissionChecker">Permission checker</param>
        /// <param name="requireAll">
        /// If this is set to true, all of the <see cref="permissionNames"/> must be granted.
        /// If it's false, at least one of the <see cref="permissionNames"/> must be granted.
        /// </param>
        /// <param name="permissionNames">Name of the permissions to authorize</param>
        /// <exception cref="AbpAuthorizationException">Throws authorization exception if</exception>
        public static void Authorize(this IPermissionChecker permissionChecker, bool requireAll, params string[] permissionNames)
        {
            if (IsGranted(permissionChecker, requireAll, permissionNames))
            {
                return;
            }

            var localizedPermissionNames = LocalizePermissionNames(permissionChecker, permissionNames);

            if (requireAll)
            {
                throw new AbpAuthorizationException(
                    string.Format(
                        L(
                            permissionChecker,
                            "AllOfThesePermissionsMustBeGranted",
                            "Required permissions are not granted. All of these permissions must be granted: {0}"
                        ),
                        string.Join(", ", localizedPermissionNames)
                    )
                );
            }
            else
            {
                throw new AbpAuthorizationException(
                    string.Format(
                        L(
                            permissionChecker,
                            "AtLeastOneOfThesePermissionsMustBeGranted",
                            "Required permissions are not granted. At least one of these permissions must be granted: {0}"
                        ),
                        string.Join(", ", localizedPermissionNames)
                    )
                );
            }
        }

        public static string L(IPermissionChecker permissionChecker, string name, string defaultValue)
        {
            if (!(permissionChecker is IIocManagerAccessor))
            {
                return defaultValue;
            }

            var iocManager = (permissionChecker as IIocManagerAccessor).IocManager;
            using (var localizationManager = iocManager.ResolveAsDisposable<ILocalizationManager>())
            {
                return localizationManager.Object.GetString(AbpConsts.LocalizationSourceName, name);
            }
        }

        public static string[] LocalizePermissionNames(IPermissionChecker permissionChecker, string[] permissionNames)
        {
            if (!(permissionChecker is IIocManagerAccessor))
            {
                return permissionNames;
            }

            var iocManager = (permissionChecker as IIocManagerAccessor).IocManager;
            using (var localizationContext = iocManager.ResolveAsDisposable<ILocalizationContext>())
            {
                using (var permissionManager = iocManager.ResolveAsDisposable<IPermissionManager>())
                {
                    return permissionNames.Select(permissionName =>
                    {
                        var permission = permissionManager.Object.GetPermissionOrNull(permissionName);
                        return permission?.DisplayName == null
                            ? permissionName
                            : permission.DisplayName.Localize(localizationContext.Object);
                    }).ToArray();
                }
            }
        }
    }
}


text:
package eu.appbucket.beaconmonitor.ui.fragments;

import eu.appbucket.beaconmonitor.R;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;

public class BikeViewFragment extends Fragment {

    private static final String LOG_TAG = "BikeViewFragment";

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_bike_info, container, false);

        setupView(rootView);
        return rootView;
    }

    private void setupView(View rootView) {
        Bundle args = getArguments();
        String title = args.getString("title");
        String desc = args.getString("desc");
        int imageRes = args.getInt("image");

        //Set values on screen
        EditText textTag = (EditText) rootView.findViewById(R.id.bike_info_text_tag_value);
        EditText textTitle = (EditText) rootView.findViewById(R.id.bike_info_text_name_value);
        EditText textDesc = (EditText) rootView.findViewById(R.id.bike_info_text_description_value);
        ImageView imageBike = (ImageView) rootView.findViewById(R.id.bike_info_image);

        textTitle.setText(title);
        textDesc.setText(desc);
        imageBike.setImageResource(imageRes);

        //TODO: Pull tag data from DB
    }
}

redpajama_set_name: RedPajamaGithub


text:
#include "entities/instance_object.h"

#include "cnet.h"

#include "assets/renderable.h"

instance_object* instance_object_new() {
  instance_object* io = malloc(sizeof(instance_object));

  io->num_instances = 0;
  io->instances = malloc(sizeof(instance_data) * 0);

  if (net_is_client()) {
    glGenBuffers(1, &io->world_buffer);
  }

  io->bound = sphere_unit();
  io->renderable = asset_hndl_null();
  io->collision_body = asset_hndl_null();

  return io;
}

void instance_object_delete(instance_object* io) {

  if (net_is_client()) {
    glDeleteBuffers(1, &io->world_buffer);
  }

  free(io->instances);
  free(io);
}

void instance_object_update(instance_object* io) {

  if (net_is_server()) { return; }

  /* TODO: Make struct member */
  mat4* world_data = malloc(sizeof(mat4) * io->num_instances);

  for (int i = 0; i < io->num_instances; i++) {
    instance_data id = io->instances[i];
    io->instances[i].world = mat4_world(id.position, id.scale, id.rotation);
    io->instances[i].world_normal = mat3_transpose(mat3_inverse(mat4_to_mat3(io->instances[i].world)));
    world_data[i] = mat4_transpose(io->instances[i].world);
  }

  glBindBuffer(GL_ARRAY_BUFFER, io->world_buffer);
  glBufferData(GL_ARRAY_BUFFER, sizeof(mat4) * io->num_instances, world_data, GL_STATIC_DRAW);
  glBindBuffer(GL_ARRAY_BUFFER, 0);

  free(world_data);

  io->bound = sphere_unit();

  if (!asset_hndl_isnull(&io->renderable)) {

    renderable* r = asset_hndl_ptr(&io->renderable);
    sphere rbound = sphere_unit();
    for (int i = 0; i < r->num_surfaces; i++) {
      rbound = sphere_merge(rbound, r->surfaces[i]->bound);
    }

    for (int i = 0; i < io->num_instances; i++) {
      io->bound = sphere_merge(io->bound, sphere_transform(rbound, io->instances[i].world));
    }

  }

}

void instance_object_add_instance(instance_object* io, vec3 position, vec3 scale, quat rotation) {

  instance_data id;
  id.position = position;
  id.scale = scale;
  id.rotation = rotation;
  id.world = mat4_world(id.position, id.scale, id.rotation);
  id.world_normal = mat3_transpose(mat3_inverse(mat4_to_mat3(id.world)));

  io->num_instances++;
  io->instances = realloc(io->instances, sizeof(instance_data) * io->num_instances);
  io->instances[io->num_instances-1] = id;

  instance_object_update(io);

}

void instance_object_rem_instance(instance_object* io, int i) {

  if (i >= io->num_instances) {
    error("Cannot remove instance %i: instance object only has %i instances!", i, io->num_instances);
    return;
  }

  memmove( &io->instances[i+0], &io->instances[i+1],
    sizeof(instance_data) * (io->num_instances-i-1));

  io->num_instances--;
  io->instances = realloc(io->instances, sizeof(instance_data) * io->num_instances);

  instance_object_update(io);

}

mat4 instance_object_world(instance_object* io, int i) {
  return io->instances[i].world;
}

mat3 instance_object_world_normal(instance_object* io, int i) {
  return io->instances[i].world_normal;
}


text:
//
//  QLSMagicFileAttributes.m
//  QuickLookStephen
//
//  Created by Nick Hutchinson on 31/07/12.
//

#import "QLSFileAttributes.h"
#import "RegexKitLite.h"

@interface QLSFileAttributes ()

@property (readwrite) BOOL isTextFile;
@property (readwrite) NSString *mimeType;
@property (readwrite) CFStringEncoding fileEncoding;
@property (readwrite) NSURL *url;

@end

@implementation QLSFileAttributes

+ (instancetype)attributesForItemAtURL:(NSURL *)aURL
{
  NSString *magicString = [self magicStringForItemAtURL:aURL];
  if (!magicString) return nil;

  NSArray *matches = [magicString rkl_captureComponentsMatchedByRegex:
                         @"(\\S+/\\S+); charset=(\\S+)"];

  if (![matches count]) return nil;

  NSString *mimeType = matches[1];
  NSString *charset = matches[2];

  BOOL mimeTypeIsTextual = [self mimeTypeIsTextual:mimeType];

  CFStringEncoding encoding =
      CFStringConvertIANACharSetNameToEncoding((CFStringRef)charset);

  QLSFileAttributes *attributes = [QLSFileAttributes new];
  attributes.fileEncoding = encoding;
  attributes.isTextFile = mimeTypeIsTextual;
  attributes.mimeType = mimeType;
  attributes.url = aURL;

  return attributes;
}

////////////////////////////////////////////////////////////////////////////////
// Private Methods
////////////////////////////////////////////////////////////////////////////////

+ (NSString *)magicStringForItemAtURL:(NSURL *)aURL
{
  if ([aURL.lastPathComponent isEqualToString:@".DS_Store"]) {
    NSLog(@"Ignore the .DS_Store file.");
      return nil;
  }
  NSString *path = [aURL path];
  NSParameterAssert(path);

  NSMutableDictionary *environment =
      [NSProcessInfo.processInfo.environment mutableCopy];
  environment[@"LC_ALL"] = @"en_US.UTF-8";

  NSTask *task = [NSTask new];
  task.launchPath = @"/usr/bin/file";
  task.arguments = @[@"--mime", @"--brief", path];
  task.environment = environment;
  task.standardOutput = [NSPipe new];

  [task launch];

  NSData *output =
      [[task.standardOutput fileHandleForReading] readDataToEndOfFile];

  [task waitUntilExit];

  if (task.terminationReason != NSTaskTerminationReasonExit
        || task.terminationStatus != 0) {
    return nil;
  }

  NSCharacterSet *whitespaceCharset =
      [NSCharacterSet whitespaceAndNewlineCharacterSet];

  NSString *stringOutput =
      [[NSString alloc] initWithData:output encoding:NSUTF8StringEncoding];

  stringOutput =
      [stringOutput stringByTrimmingCharactersInSet:whitespaceCharset];

  return stringOutput;
}

/**
 * @return YES if mimeType contains "text", or if the mime type conforms to the
 *         public.text UTI.
 */
+ (BOOL)mimeTypeIsTextual:(NSString *)mimeType
{
  NSArray *components = [mimeType componentsSeparatedByString:@"/"];
  if (components.count != 2)
    return NO;

  if ([components[0] rangeOfString:@"text"].location != NSNotFound)
    return YES;

  NSString *UTType =
      CFBridgingRelease(UTTypeCreatePreferredIdentifierForTag(
                            kUTTagClassMIMEType,
                            (__bridge CFStringRef)mimeType,
                            kUTTypeData));

  if (UTTypeConformsTo((__bridge CFStringRef)UTType, kUTTypeText)) {
    return YES;
  }

  return NO;
}

@end


text:
package quark_md;

public class quark_spi_api_tracing_RuntimeProxy_logger_Method extends quark.reflect.Method implements io.datawire.quark.runtime.QObject {
    public quark_spi_api_tracing_RuntimeProxy_logger_Method() {
        super("quark.Logger", "logger", new java.util.ArrayList(java.util.Arrays.asList(new Object[]{"quark.String"})));
    }
    public Object invoke(Object object, java.util.ArrayList<Object> args) {
        quark.spi_api_tracing.RuntimeProxy obj = (quark.spi_api_tracing.RuntimeProxy) (object);
        return (obj).logger((String) ((args).get(0)));
    }
    public String _getClass() {
        return (String) (null);
    }
    public Object _getField(String name) {
        return null;
    }
    public void _setField(String name, Object value) {}
}


text:
package me.snov.sns.actor

import java.util.UUID

import akka.actor.Status.{Failure, Success}
import akka.actor.{Actor, ActorLogging, ActorRef, Props}
import me.snov.sns.actor.DbActor.CmdGetConfiguration
import me.snov.sns.model._
import akka.actor.PoisonPill
import akka.actor.Status

object SubscribeActor {
  def props(dbActor: ActorRef) = Props(classOf[SubscribeActor], dbActor)

  case class CmdSubscribe(topicArn: String, protocol: String, endpoint: String)

  case class CmdUnsubscribe(subscriptionArn: String)

  case class CmdListSubscriptions()

  case class CmdListSubscriptionsByTopic(topicArn: String)

  case class CmdFanOut(topicArn: String, message: Message)

  case class CmdCreateTopic(name: String)

  case class CmdDeleteTopic(arn: String)

  case class CmdListTopics()

  case class CmdSetSubscriptionAttributes(subscriptionArn: String, attributeName: String, attributeValue: String)
  case class CmdGetSubscriptionAttributes(subscriptionArn: String)
}

class SubscribeActor(dbActor: ActorRef) extends Actor with ActorLogging {

  import me.snov.sns.actor.SubscribeActor._

  type TopicArn = String
  type SubscriptionArn = String

  var topics = Map[TopicArn, Topic]()
  var subscriptions = Map[TopicArn, List[Subscription]]()
  var actorPool = Map[SubscriptionArn, ActorRef]()

  dbActor ! CmdGetConfiguration

  private def fanOut(topicArn: TopicArn, message: Message) = {
    try {
      if (topics.isDefinedAt(topicArn) && subscriptions.isDefinedAt(topicArn)) {
        subscriptions(topicArn).foreach((s: Subscription) => {
          if (actorPool.isDefinedAt(s.arn)) {
            log.debug(s"Sending message ${message.uuid} to ${s.endpoint}")
             actorPool(s.arn) ! message
          } else {
            throw new RuntimeException(s"No actor for subscription ${s.endpoint}")
          }
        })
      } else {
        throw new TopicNotFoundException(s"Topic not found: $topicArn")
      }

      Success
    } catch {
      case e: Throwable => Failure(e)
    }
  }

  def findSubscription(subscriptionArn: String): Option[Subscription] = {
    subscriptions.values.flatten.find{_.arn == subscriptionArn}
  }

  def producerFor(subscription: Subscription) = {
    val producer = if(subscription.isRawMessageDelivery) {
      context.system.actorOf(RawProducerActor.props(subscription.endpoint, subscription.arn, subscription.topicArn))
    } else {
      context.system.actorOf(ProducerActor.props(subscription.endpoint, subscription.arn, subscription.topicArn))
    }
    producer
  }
  def updateSubscription(subscription: Subscription) = {
    val updatedSubs = subscription :: subscriptions(subscription.topicArn).filter(_.arn != subscription.arn)
    subscriptions += (subscription.topicArn -> updatedSubs)

   val producer = producerFor(subscription)

    //update the producer
    actorPool += (subscription.arn -> producer)
  }

  def setAttribute(subscriptionArn: String, attributeName: String, attributeValue: String) = {
    log.info(s"Setting ${attributeName} to ${attributeValue} for ${subscriptionArn}")
    findSubscription(subscriptionArn).map { sub =>
      val updated = sub.copy(subscriptionAttributes = Some(sub.subscriptionAttributes.getOrElse(Map.empty[String,String]) + (attributeName -> attributeValue)))
      updateSubscription(updated)
      Success
    } getOrElse {
      log.error(s"No subscription found for ${subscriptionArn}")
       Failure(new Exception("Not Found"))
    }
  }
  def getAttributes(subscriptionArn: String): Option[Map[String,String]] = {
    findSubscription(subscriptionArn).flatMap { sub =>
      sub.subscriptionAttributes.map { attrs =>
        attrs ++ Map(
          "SubscriptionArn" -> sub.arn,
          "TopicArn" -> sub.topicArn,
          "Owner" -> sub.owner
        )
      }
    }
  }

  def subscribe(topicArn: TopicArn, protocol: String, endpoint: String): Subscription = {
    val subscription = Subscription(s"${topicArn}:${UUID.randomUUID}", "", topicArn, protocol, endpoint)
    initSubscription(subscription)

    save()

    subscription
  }

  def initSubscription(subscription: Subscription) = {
    val producer = producerFor(subscription)
    val listByTopic = subscription :: subscriptions.getOrElse(subscription.topicArn, List())

    actorPool += (subscription.arn -> producer)
    subscriptions += (subscription.topicArn -> listByTopic)
  }

  def unsubscribe(subscriptionArn: String) = {
    subscriptions = subscriptions.map { case (key, topicSubscriptions) => (key, topicSubscriptions.filter((s: Subscription) => s.arn != subscriptionArn)) }.toMap

    save()

    Success
  }

  def listSubscriptionsByTopic(topicArn: TopicArn): List[Subscription] = {
    subscriptions.getOrElse(topicArn, List())
  }

  def listSubscriptions(): List[Subscription] = {
    subscriptions.values.flatten.toList
  }

  def findOrCreateTopic(name: String): Topic = {
    topics.values.find(_.name == name) match {
      case Some(topic) => topic
      case None =>
        val topic = Topic(s"arn:aws:sns:us-east-1:123456789012:$name", name)
        topics += (topic.arn -> topic)

        save()

        topic
    }
  }

  def delete(arn: TopicArn) = {
    if (topics.isDefinedAt(arn)) {
      topics -= arn

      if (subscriptions.isDefinedAt(arn)) {
        subscriptions -= arn
      }

      save()

      Success
    } else {
      Failure
    }
  }

  def load(configuration: Configuration) = {
    configuration.topics.foreach { topic => topics += (topic.arn -> topic) }
    configuration.subscriptions.foreach { initSubscription }
    log.info("Loaded configuration")
  }

  def save() = {
    dbActor ! new Configuration(subscriptions = listSubscriptions(), topics = topics.values.toList)
  }

  override def receive = {
    case CmdCreateTopic(name) => sender ! findOrCreateTopic(name)
    case CmdDeleteTopic(arn) => sender ! delete(arn)
    case CmdListTopics => sender ! topics.values
    case CmdSubscribe(topicArn, protocol, endpoint) => sender ! subscribe(topicArn, protocol, endpoint)
    case CmdUnsubscribe(subscriptionArn) => sender ! unsubscribe(subscriptionArn)
    case CmdListSubscriptionsByTopic(topicArn) => sender ! listSubscriptionsByTopic(topicArn)
    case CmdListSubscriptions() => sender ! listSubscriptions()
    case CmdFanOut(topicArn, message) => sender ! fanOut(topicArn, message)
    case CmdSetSubscriptionAttributes(subscriptionArn, attributeName, attributeValue) => sender ! setAttribute(subscriptionArn, attributeName, attributeValue)
    case CmdGetSubscriptionAttributes(subscriptionArn) => sender ! getAttributes(subscriptionArn)
    case configuration: Configuration => load(configuration)
  }
}


text:
# frozen_string_literal: true

module BrowseEverythingHelper
  # Extracted from Rack::Mime 1.5.2 for use with earlier versions of Rack/Rails
  # @param [String] value
  # @param [String] matcher
  # @return [TrueClass,FalseClass]
  def mime_match?(value, matcher)
    v1, v2 = value.split('/', 2)
    m1, m2 = matcher.split('/', 2)
    return false if m1 != '*' && v1 != m1
    m2.nil? || m2 == '*' || m2 == v2
  end

  # @param [BrowseEverything::FileEntry] file
  # @return [TrueClass,FalseClass]
  def is_acceptable?(file)
    acceptable = params[:accept] || '*/*'
    acceptable_types = acceptable.split(/,\s*/)
    acceptable_types << 'application/x-directory'
    acceptable_types.any? { |type| mime_match?(file.type, type) }
  end

  def file_size_to_human_size(file_size)
    "#{file_size} bytes"
  end
end


text:
// This file was generated using Parlex's cpp_generator

#ifndef INCLUDED_BLOCK_HPP
#define INCLUDED_BLOCK_HPP

#include <optional>
#include <variant>
#include <vector>

#include "erased.hpp"

#include "parlex/detail/abstract_syntax_tree.hpp"
#include "parlex/detail/builtins.hpp"
#include "parlex/detail/document.hpp"

#include "plange_grammar.hpp"

namespace plc {

struct STATEMENT_SCOPE;

struct BLOCK {
	parlex::detail::document::text<literal_0x7B_t> dontCare0;

	erased<STATEMENT_SCOPE> field_1;

	parlex::detail::document::text<literal_0x7D_t> dontCare2;

	explicit BLOCK(
		parlex::detail::document::text<literal_0x7B_t> && dontCare0, erased<STATEMENT_SCOPE> && field_1, parlex::detail::document::text<literal_0x7D_t> && dontCare2) : dontCare0(std::move(dontCare0)), field_1(std::move(field_1)), dontCare2(std::move(dontCare2)) {}

	BLOCK(BLOCK const & other) = default;
	BLOCK(BLOCK && move) = default;

	static BLOCK build(parlex::detail::ast_node const & n);
	static parlex::detail::state_machine const & state_machine();

};

} // namespace plc

#endif //INCLUDED_BLOCK_HPP


text:
using System.Threading.Tasks;
using Nethereum.JsonRpc.Client;

namespace Nethereum.Geth.RPC.Admin
{
    public interface IAdminImportChain
    {
        RpcRequest BuildRequest(string filePath, object id = null);
        Task<bool> SendRequestAsync(string filePath, object id = null);
    }
}


text:
import { combineReducers } from 'redux';
import { routerReducer } from 'react-router-redux';
import { reducer as formReducer } from 'redux-form';

import auth from './modules/auth';
import currencies from './modules/currencies';

export default combineReducers({
  routing: routerReducer,
  form: formReducer,
  auth,
  currencies,
});


text:
<?php
/**
 * @author @jayS-de <jens.schulze@commercetools.de>
 */

namespace Commercetools\Sunrise\AppBundle\Model\View;

use Commercetools\Sunrise\AppBundle\Model\ViewData;

class LinkList extends ViewData
{
    public $text;
    public $url;
    public $list;
}


text:
#ifndef _PASSENGER_ACCOUNT_H_
#define _PASSENGER_ACCOUNT_H_

#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
#include "StaticString.h"
#include "Exceptions.h"
#include "Utils/StrIntUtils.h"

namespace Passenger {

using namespace boost;
using namespace std;

/*
 * SECURITY NOTES
 *
 * We want to avoid storing plain text passwords in memory, because attackers may be able
 * to read this process's memory, e.g. through core dumps or debuggers. So in this source
 * file, as well as in several others, we follow these guidelines:
 *
 * - Variables and arguments named userSuppliedPassword represent passwords
 *   supplied by a human, i.e. user input. These variables and arguments have the type
 *   'StaticString' instead of 'string', because we want to avoid accidentally copying
 *   the password values.
 * - Variables and arguments named passwordOrHash might also represent passwords. However,
 *   if it is a password, then it is guaranteed NOT to be supplied by a human, e.g. it's
 *   randomly generated. Therefore it's okay for passwordOrHash to be of type 'string'.
 * - If there is a need to copy the password for whatever reason, then it must be cleared
 *   with ZeroMemoryGuard as soon as possible. Do not use memset(), the code
 *   for ZeroMemoryGuard explains why.
 */

class Account {
public:
	enum Rights {
		ALL                       = ~0,
		NONE                      = 0,

		// ApplicationPool::Server rights.
		GET                       = 1 << 0,
		CLEAR                     = 1 << 1,
		DETACH                    = 1 << 2,
		GET_PARAMETERS            = 1 << 3,
		SET_PARAMETERS            = 1 << 4,
		INSPECT_BASIC_INFO        = 1 << 5,
		INSPECT_SENSITIVE_INFO    = 1 << 6,
		//INSPECT_BACKEND_ADDRESSES = 1 << 6,
		//INSPECT_DETACH_KEYS       = 1 << 7,

		// BacktracesServer rights.
		INSPECT_BACKTRACES        = 1 << 8,

		// Other rights.
		EXIT                      = 1 << 31
	};

private:
	string username;
	string passwordOrHash;
	bool hashGiven;
	Rights rights;

public:
	// Urgh, I can't use 'Rights' here as type because apparently bitwise
	// ORing two enums results in an int type.

	static Rights parseRightsString(const string &str, int defaultValue = NONE) {
		vector<string> rights_vec;
		vector<string>::const_iterator it;
		int result = defaultValue;

		split(str, ',', rights_vec);
		for (it = rights_vec.begin(); it != rights_vec.end(); it++) {
			if (*it == "all") {
				result = ALL;
			} else if (*it == "none") {
				result = NONE;

			} else if (*it == "get") {
				result |= GET;
			} else if (*it == "clear") {
				result |= CLEAR;
			} else if (*it == "detach") {
				result |= DETACH;
			} else if (*it == "get_parameters") {
				result |= GET_PARAMETERS;
			} else if (*it == "set_parameters") {
				result |= SET_PARAMETERS;
			} else if (*it == "inspect_basic_info") {
				result |= INSPECT_BASIC_INFO;
			} else if (*it == "inspect_sensitive_info") {
				result |= INSPECT_SENSITIVE_INFO;

			} else if (*it == "inspect_backtraces") {
				result |= INSPECT_BACKTRACES;

			} else if (*it == "exit") {
				result |= EXIT;

			} else if (*it != "") {
				throw ArgumentException("Unknown right '" + *it + "'.");
			}
		}

		return (Rights) result;
	}

	Account(const string &username, const string &passwordOrHash, bool hashGiven, int rights = ALL) {
		this->username       = username;
		this->passwordOrHash = passwordOrHash;
		this->hashGiven      = hashGiven;
		this->rights         = (Rights) rights;
	}

	bool checkPasswordOrHash(const StaticString &userSuppliedPassword) const {
		if (hashGiven) {
			return passwordOrHash == createHash(userSuppliedPassword);
		} else {
			return userSuppliedPassword == passwordOrHash;
		}
	}

	bool hasRights(int rights) const {
		return this->rights & rights;
	}

	void setRights(int rights) {
		this->rights = (Rights) rights;
	}

	string getUsername() const {
		return username;
	}

	string getRawPassword() const {
		return passwordOrHash;
	}

	static string createHash(const StaticString &userSuppliedPassword) {
		// TODO: use bcrypt or something
		return userSuppliedPassword;
	}
};

typedef shared_ptr<Account> AccountPtr;

} // namespace Passenger

#endif /* _PASSENGER_ACCOUNT_H_ */


text:
'use strict';

global.test = true;

var should = require('should');
var chp = require('child_process');
var fs = require('fs');
var orcinusCreate = require('../lib/create');
var orcinusRemove = require('../lib/rm');
const timeout = 120000;
const deployTimeout = 40000

// TODO fix me
// Check for docker binary and aksaramaya's docker image before running unit testing.
// Make sure there is no container running inside docker
//
// var orcinusPs = require('../lib/ps');

describe('Orcinus', function() {
  describe('Create', function() {
    it('should be able to create a cluster instance via API', function(done) {
      this.timeout(timeout);
      let data = {
      	"stack" : "orcinus-unit-testing-stack",
      	"services": {
          "orcinus-ut-web": {
            "ports" : [
              "7001:7001",
            ],
            "environment" : [
	      "FOO=bar",
            ],
            "network": "orcinus-unit-testing-stack",
            "image": "aksaramaya/docker-http-server:v1",
            "cpu": "1",
            "memory": "128mb"
          }
      	}
      }
      orcinusCreate.init(data);
      setTimeout(() => { // wait for docker
        let cmd = 'docker ps | sed -n 2,1p | grep "orcinus-ut-web" | cut -d\' \' -f 1';
        chp.exec(cmd, (err, stdout, stderr) => {
          stdout.length.should.greaterThan(10); // Container ID length was 12
          orcinusRemove.init(data);
          setTimeout(() => {
            done();
          }, 5000);
        });
       }, deployTimeout);
    });
    it('should be able to create a cluster instance from a manifest file', function(done) {
      this.timeout(timeout);
      let data = {
        "stack" : "orcinus-unit-testing-stack",
      	"services": {
          "orcinus-ut-web": {
            "ports" : [
              "7002:7002",
            ],
            "environment" : [
              "FOO=bar",
            ],
            "network": "orcinus-unit-testing-stack",
            "image": "aksaramaya/docker-http-server:v1",
            "cpu": "1",
            "memory": "128mb"
          }
        }
      }
      fs.writeFileSync('./test/test.json', JSON.stringify(data));
      chp.exec('cd ' + process.cwd() + ' && node cli.js create -f test/test.json', (err, stdout, stderr) => {
        console.log(stdout);
        setTimeout(() => { // wait for docker
          let cmd = 'docker ps | sed -n 2,1p | grep "orcinus-ut-web" | cut -d\' \' -f 1';
          chp.exec(cmd, (err, stdout, stderr) => {
            stdout.length.should.greaterThan(10); // Container ID length was 12
    	    chp.exec('cd ' + process.cwd() + ' && node cli.js rm -f test/test.json');
            setTimeout(() => {
              done();
            }, 5000);
          });
        }, deployTimeout);
      });
    });
    it('should be fail to initialize cluster with no service', function(done) {
      this.timeout(timeout);
      let data = {
        "stack" : "orcinus-unit-testing-stack",
      }
      try {
        orcinusCreate.init(data);
      } catch(e) {
        let cmd = 'docker ps | sed -n 2,1p | grep orcinus-ut-web | cut -d\' \' -f 1';
        chp.exec(cmd, (err, stdout, stderr) => {
          done();
        });
      }
    });
    it('should be fail to initialize cluster with non-string stack name', function(done) {
      this.timeout(timeout);
      let data = {
        "stack" : 123,
        "services": {
          "orcinus-ut-web": {
            "image": "aksaramaya/docker-http-server:v1",
            "cpu": "1",
            "memory": "128mb"
          }
        }
      }
      try {
        orcinusCreate.init(data);
      } catch(e) {
        done();
      }
    });
  });
});


text:
require "text"

module OrgSelection

  # This class provides a search mechanism for Orgs that looks at records in the
  # the database along with any available external APIs
  class OrgToHashService

    class << self

      # Convert an Identifiable Model over to hash results like:
      # An Org with id = 123, name = "Foo (foo.org)",
      #             org_identifier (ROR) = "http://example.org/123"
      # becomes:
      # {
      #   id: "123",
      #   ror: "http://ror.org/123",
      #   name: "Foo (foo.org)",
      #   sort_name: "Foo"
      # }
      def to_hash(org:)
        return {} unless org.present?

        out = {
          id: org.id,
          name: org.name,
          sort_name: OrgSelection::SearchService.name_without_alias(name: org.name)
        }
        # tack on any identifiers
        org.identifiers.each do |id|
          next unless id.identifier_scheme.present?

          out[:"#{id.identifier_scheme.name.downcase}"] = id.value
        end
        out
      end

    end

  end

end


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

/**
 * @class App
 * @description React component for injecting code into the app
 * */
class App extends React.PureComponent {
  static propTypes = {
    children: PropTypes.element.isRequired,
  };

  render() {
    // NOTE: If you need to add or modify header, footer etc. of the app,
    // please do that inside the Layout component.
    return React.Children.only(this.props.children);
  }

}

export default App;


text:
from core.himesis import Himesis
import uuid

class HEOperation(Himesis):
    def __init__(self):

        """
        Creates the himesis graph representing the DSLTrans rule EOperation.
        """
        # Flag this instance as compiled now
        self.is_compiled = True

        super(HEOperation, self).__init__(name='HEOperation', num_nodes=0, edges=[])

        # Set the graph attributes
        self["mm__"] = ['HimesisMM']

        self["name"] = """EOperation"""
        self["GUID__"] = uuid.uuid3(uuid.NAMESPACE_DNS,'EOperation')

        # match model. We only support one match model
        self.add_node()
        self.vs[0]["mm__"] = """MatchModel"""

        # apply model node
        self.add_node()
        self.vs[1]["mm__"] = """ApplyModel"""

        # paired with relation between match and apply models
        self.add_node()
        self.vs[2]["mm__"] = """paired_with"""

        # match class EOperation() node
        self.add_node()

        self.vs[3]["mm__"] = """EOperation"""
        self.vs[3]["attr1"] = """+"""
        # match_contains node for class EOperation()
        self.add_node()
        self.vs[4]["mm__"] = """match_contains"""

        # apply class EOperation() node
        self.add_node()

        self.vs[5]["mm__"] = """EOperation"""
        self.vs[5]["attr1"] = """1"""
        # apply_contains node for class EOperation()
        self.add_node()
        self.vs[6]["mm__"] = """apply_contains"""

        # Add the edges
        self.add_edges([
                (0,4), # matchmodel -> match_contains
                (4,3), # match_contains -> match_class EOperation()
                (1,6), # applymodel -> apply_contains
                (6,5), # apply_contains -> apply_class EOperation()
                (0,2), # matchmodel -> pairedwith
                (2,1) # pairedwith -> applyModel
		])

        # Add the attribute equations
        self["equations"] = [((5,'name'),(3,'name')), ((5,'ordered'),(3,'ordered')), ((5,'unique'),(3,'unique')), ((5,'lowerBound'),(3,'lowerBound')), ((5,'upperBound'),(3,'upperBound')), ((5,'ApplyAttribute'),('constant','solveRef')), ]