text:
module MailerHelper
  include PermsHelper

  def tool_name
    @tool_name ||= ApplicationService.application_name
  end

  def helpdesk_email(org: nil)
    org&.helpdesk_email || Rails.configuration.x.organisation.helpdesk_email
  end

  # Returns an unordered HTML list with the permissions associated to the user passed
  def privileges_list(user)
    return '' unless user.respond_to?(:perms) && user.perms.respond_to?(:each)

    names = name_and_text
    r = '
'
    user.perms.each do |p|
      r += "
#{names[p.name.to_sym]}
" if names.key?(p.name.to_sym)
    end
    r += '
'
  end

  # Returns the messaging for the specified role
  def role_text(role)
    if role.administrator?
      {
        type: _('co-owner'),
        placeholder1: _('write and edit the plan in a collaborative manner.'),
        placeholder2: _('You can also grant rights to other collaborators.')
      }
    elsif role.editor?
      {
        type: _('editor'),
        placeholder1: _('write and edit the plan in a collaborative manner.'),
        placeholder2: nil
      }
    else
      {
        type: _('read-only'),
        placeholder1: _('read the plan and leave comments.'),
        placeholder2: nil
      }
    end
  end
end


text:
A monolithic notebook app, in a component

## Installation
```
npm install --save @nteract/notebook-app-component
```

## Usage

This component is not for the faint of heart. It requires you to setup the redux store used by the other nteract apps. You can check out desktop or jupyter extension for examples.

```jsx
import NotebookApp from "@nteract/notebook-app-component";

<NotebookApp
  // The desktop app always keeps the same contentRef in a
  // browser window
  contentRef={contentRef}
/>
```

redpajama_set_name: RedPajamaGithub


text:
@interface PNLeaveRequest ()

#pragma mark - Properties

// Stores reference on channels list
@property (nonatomic, strong) NSArray *channels;

// Stores reference on client identifier on the
// moment of request creation
@property (nonatomic, copy) NSString *clientIdentifier;

// Stores reference on whether connection should
// be closed before sending this message or not
@property (nonatomic, assign, getter = shouldCloseConnection) BOOL closeConnection;

// Stores whether leave request was sent to subscribe
// on new channels or as result of user request
@property (nonatomic, assign, getter = isSendingByUserRequest) BOOL sendingByUserRequest;

@end

@implementation PNLeaveRequest

#pragma mark - Class methods

+ (PNLeaveRequest *)leaveRequestForChannel:(PNChannel *)channel byUserRequest:(BOOL)isLeavingByUserRequest {

    return [self leaveRequestForChannels:@[channel] byUserRequest:isLeavingByUserRequest];
}

+ (PNLeaveRequest *)leaveRequestForChannels:(NSArray *)channels byUserRequest:(BOOL)isLeavingByUserRequest {

    return [[[self class] alloc] initForChannels:channels byUserRequest:isLeavingByUserRequest];
}

#pragma mark - Instance methods

- (id)initForChannels:(NSArray *)channels byUserRequest:(BOOL)isLeavingByUserRequest {

    // Check whether initialization successful or not
    if((self = [super init])) {

        self.sendingByUserRequest = isLeavingByUserRequest;
        self.closeConnection = YES;
        self.channels = [NSArray arrayWithArray:channels];
        self.clientIdentifier = [PubNub escapedClientIdentifier];
    }

    return self;
}

- (NSString *)callbackMethodName {

    return PNServiceResponseCallbacks.leaveChannelCallback;
}

- (NSString *)resourcePath {

    return [NSString stringWithFormat:@"/v2/presence/sub_key/%@/channel/%@/leave?uuid=%@&callback=%@_%@%@",
                                      [PubNub sharedInstance].configuration.subscriptionKey,
                                      [[self.channels valueForKey:@"escapedName"] componentsJoinedByString:@","],
                                      self.clientIdentifier,
                                      [self callbackMethodName],
                                      self.shortIdentifier,
                                      ([self authorizationField]?[NSString stringWithFormat:@"&%@", [self authorizationField]]:@"")];
}

- (NSString *)debugResourcePath {

    NSMutableArray *resourcePathComponents = [[[self resourcePath] componentsSeparatedByString:@"/"] mutableCopy];
    [resourcePathComponents replaceObjectAtIndex:4 withObject:PNObfuscateString([PubNub sharedInstance].configuration.subscriptionKey)];

    return [resourcePathComponents componentsJoinedByString:@"/"];
}

#pragma mark -

@end


text: Arquivos da disciplina ELC1067 ano 2015 - 1o semestre da UFSM.


text:
#ifndef __MDCLIAPI_HPP_INCLUDED__
#define __MDCLIAPI_HPP_INCLUDED__

#include "zmsg.hpp"
#include "mdp.h"

//  Structure of our class
//  We access these properties only via class methods

class mdcli {
public:

   //  ---------------------------------------------------------------------
   //  Constructor

   mdcli (std::string broker, int verbose)
   {
       s_version_assert (2, 1);

       m_broker = broker;
       m_context = new zmq::context_t (1);
       m_verbose = verbose;
       m_timeout = 2500;           //  msecs
       m_client = 0;

       s_catch_signals ();
       connect_to_broker ();
   }

   //  ---------------------------------------------------------------------
   //  Destructor

   virtual
   ~mdcli ()
   {
       delete m_client;
       delete m_context;
   }

   //  ---------------------------------------------------------------------
   //  Connect or reconnect to broker

   void connect_to_broker ()
   {
       if (m_client) {
           delete m_client;
       }
       m_client = new zmq::socket_t (*m_context, ZMQ_DEALER);
       int linger = 0;
       m_client->setsockopt (ZMQ_LINGER, &linger, sizeof (linger));
       m_client->connect (m_broker.c_str());
       if (m_verbose)
           s_console ("I: connecting to broker at %s...", m_broker.c_str());
   }

   //  ---------------------------------------------------------------------
   //  Set request timeout

   void
   set_timeout (int timeout)
   {
       m_timeout = timeout;
   }

   //  ---------------------------------------------------------------------
   //  Send request to broker
   //  Takes ownership of request message and destroys it when sent.

   int
   send (std::string service, zmsg *&request_p)
   {
       assert (request_p);
       zmsg *request = request_p;

       //  Prefix request with protocol frames
       //  Frame 0: empty (REQ emulation)
       //  Frame 1: "MDPCxy" (six bytes, MDP/Client x.y)
       //  Frame 2: Service name (printable string)
       request->push_front ((char*)service.c_str());
       request->push_front ((char*)MDPC_CLIENT);
       request->push_front ((char*)"");
       if (m_verbose) {
           s_console ("I: send request to '%s' service:", service.c_str());
           request->dump ();
       }
       request->send (*m_client);
       return 0;
   }

   //  ---------------------------------------------------------------------
   //  Returns the reply message or NULL if there was no reply. Does not
   //  attempt to recover from a broker failure, this is not possible
   //  without storing all unanswered requests and resending them all...

   zmsg *
   recv ()
   {
       //  Poll socket for a reply, with timeout
       zmq::pollitem_t items [] = { { *m_client, 0, ZMQ_POLLIN, 0 } };
       zmq::poll (items, 1, m_timeout * 1000);

       //  If we got a reply, process it
       if (items [0].revents & ZMQ_POLLIN) {
           zmsg *msg = new zmsg (*m_client);
           if (m_verbose) {
               s_console ("I: received reply:");
               msg->dump ();
           }
           //  Don't try to handle errors, just assert noisily
           assert (msg->parts () >= 4);

           assert (msg->pop_front ().length() == 0);  // empty message

           std::basic_string<unsigned char> header = msg->pop_front();
           assert (header.compare((unsigned char *)MDPC_CLIENT) == 0);

           std::basic_string<unsigned char> service = msg->pop_front();
           assert (service.compare((unsigned char *)service.c_str()) == 0);

           return msg;     //  Success
       }
       if (s_interrupted)
           std::cout << "W: interrupt received, killing client..." << std::endl;
       else
       if (m_verbose)
           s_console ("W: permanent error, abandoning request");

       return 0;
   }

private:
   std::string m_broker;
   zmq::context_t * m_context;
   zmq::socket_t * m_client;     //  Socket to broker
   int m_verbose;                //  Print activity to stdout
   int m_timeout;                //  Request timeout
};

#endif


text:
import { Observable } from '../../Observable';
import { find } from '../../operator/find';
Observable.prototype.find = find;
//# sourceMappingURL=find.js.map


text:
<?php

namespace Thin\Service;

use Illuminate\Pagination\Paginator;

use Slim\Slim;

class Pagination implements ServiceInterface
{

    /**
     * Setup the pagination service.
     *
     * @param \Slim\Slim $app The application instance.
     */
    public static function setup(Slim $app)
    {
        $key = $app->config('pagination.key');
        if (empty($key)) {
            $key = 'page';
        }
        Paginator::currentPageResolver(function () use ($app, $key) {
            return $app->request->get($key);
        });
    }
}


text:
package org.simpleflatmapper.datastax.impl.setter;

import com.datastax.driver.core.*;
import org.simpleflatmapper.datastax.DatastaxColumnKey;
import org.simpleflatmapper.datastax.SettableDataMapperBuilder;
import org.simpleflatmapper.datastax.impl.SettableDataSetterFactory;
import org.simpleflatmapper.map.FieldMapper;
import org.simpleflatmapper.map.SourceMapper;
import org.simpleflatmapper.map.MapperConfig;
import org.simpleflatmapper.map.property.FieldMapperColumnDefinition;
import org.simpleflatmapper.map.mapper.ConstantTargetFieldMapperFactoryImpl;
import org.simpleflatmapper.reflect.ReflectionService;
import org.simpleflatmapper.reflect.Setter;
import org.simpleflatmapper.reflect.meta.ClassMeta;

import java.lang.reflect.Type;
import java.util.Iterator;

public class UDTObjectSettableDataSetter<T> implements Setter<SettableByIndexData, T> {
    private final int index;
    private final UserType udtType;
    private final FieldMapper<T, SettableByIndexData> mapper;

    public UDTObjectSettableDataSetter(int index, UserType udtType, FieldMapper<T, SettableByIndexData> mapper) {
        this.index = index;
        this.udtType = udtType;
        this.mapper = mapper;
    }

    @Override
    public void set(SettableByIndexData target, T value) throws Exception {
        if (value == null) {
            target.setToNull(index);
        } else {
            UDTValue udtValue = udtType.newValue();
            mapper.mapTo(value, udtValue, null);
            target.setUDTValue(index, udtValue);
        }
    }

    public static <T> Setter<SettableByIndexData, T> newInstance(Type target,  UserType tt, int index, MapperConfig<DatastaxColumnKey, ?> config,
                                                                                ReflectionService reflectionService) {
        FieldMapper<T, SettableByIndexData> mapper = newUDTMapper(target, tt, config, reflectionService);
        return new UDTObjectSettableDataSetter<T>(index, tt, mapper);
    }

    public static <T> FieldMapper<T, SettableByIndexData> newUDTMapper(Type target, UserType tt,
                                                                        MapperConfig<DatastaxColumnKey, ?> config,
                                                                        ReflectionService reflectionService) {
        SettableDataMapperBuilder<T> builder = newFieldMapperBuilder(config, reflectionService, target);
        Iterator<UserType.Field> iterator = tt.iterator();
        int i = 0;
        while(iterator.hasNext()) {
            UserType.Field f = iterator.next();
            builder.addColumn(new DatastaxColumnKey(f.getName(), i, f.getType()));
            i++;
        }
        return builder.mapper();
    }

    public static <T> SettableDataMapperBuilder<T> newFieldMapperBuilder(MapperConfig<DatastaxColumnKey, ?> config,
                                                                         ReflectionService reflectionService,  Type target) {
        ClassMeta<T> classMeta = reflectionService.getClassMeta(target);
        return new SettableDataMapperBuilder<T>(classMeta, config, ConstantTargetFieldMapperFactoryImpl.newInstance(new SettableDataSetterFactory(config, reflectionService), SettableByIndexData.class));
    }
}


text:
namespace Osmosis {
namespace Client
{

typedef TaskQueue< boost::filesystem::path > PathTaskQueue;
typedef TaskQueue< struct Digested > DigestedTaskQueue;
typedef TaskQueue< struct ToVerify > ToVerifyTaskQueue;

} // namespace Client
} // namespace Osmosis

#endif // __OSMOSIS_CLIENT_TYPEDEFS_H__


text:
require 'spec_helper'

describe Game do
  let(:game)    { Game.new(player1, player2) }
  let(:player1) { Player.new(1) }
  let(:player2) { Player.new(2) }

  before(:each) do
    # initialize game
    game
  end

  context "when determing if the game is over" do
    it "should be over when a player is out of pieces" do
      (player1.pieces.size - 1).times do |i|
        player1.lose_piece(player1.pieces[0])
      end
      expect {
        player1.lose_piece(player1.pieces[0])
      }.to change(game, :playing?).from(true).to(false)
    end

    it "should be over when the take_turn method raises and EndGame exception" do
      game.should_receive(:take_turn).and_raise(EndGame.new)
      expect {
        game.play!
      }.to change(game, :playing?).from(true).to(false)
    end

    it "should be over when a player is prevented from making any moves" do
      # remove all player1 pieces except from the corner
      pieces = player1.pieces.clone
      pieces.each do |piece|
        player1.lose_piece(piece) unless piece.position == [7, 0]
      end
      player1.pieces.size.should == 1

      # Mock moving a piece into place to prevent a jump
      player2.add_piece(5, 2)
      expect {
        expect {
          player2.add_piece(6, 1)
        }.to change { player1.available_moves.empty? }.from(false).to(true)
      }.to change(game, :playing?).from(true).to(false)
    end
  end

  context "when a jump is available" do
    it "should only allow the player to make a jump" do
      # once a jump becomes possible, the player's only move should be that jump
      expect {
        expect {
          player2.add_piece(4, 3)
        }.to change(player1, :has_jump?).from(false).to(true)
      }.to change { player1.moveable_pieces.size }.to(2)
    end

    it "should not allow a player to move a piece that does not have a jump" do
      player2.add_piece(4, 3)
      player1.should be_has_jump

      non_jump_ready_piece = player1.pieces.detect { |piece| piece.position == [1, 2] }
      player1.moveable_pieces.should_not include(non_jump_ready_piece)

      lambda { player1.pieces.detect { |piece| piece.position == [1, 2] }.move_to(0, 3) }.should raise_error
      expect {
        player1.pieces.detect { |piece| piece.position == [3, 2] }.move_to(5, 4)
      }.to change { player2.pieces.size }.by(-1)
    end

    it "should let the player make one jump when available" do
      # setup a situation with a single jump
      player2.add_piece(6, 3)
      game.send(:whose_turn=, player1)

      expect {
        piece = player1.pieces.detect { |piece| piece.position == [7, 2] }
        game.toggle_turn piece, piece.move_to(5, 4)
      }.to change(game, :whose_turn).to(player2)
    end

    it "should let the player make multiple jumps" do
      # setup a situation with multiple jumps
      player2.add_piece(6, 3)
      landing_piece = player2.pieces.detect { |piece| piece.position == [7, 6] }
      player2.lose_piece(landing_piece)

      game.send(:whose_turn=, player1)
      expect {
        piece = player1.pieces.detect { |piece| piece.position == [7, 2] }
        game.toggle_turn piece, piece.move_to(5, 4)
      }.to_not change(game, :whose_turn)
      expect {
        piece = player1.pieces.detect { |piece| piece.position == [5, 4] }
        game.toggle_turn piece, piece.move_to(7, 6)
      }.to change(game, :whose_turn).to(player2)
    end

    it "should not let a piece make multiple jumps on the same turn it is kinged" do
      # setup a situation where a player can jump to get kinged, and have another jump available after
      player1.pieces.detect { |piece| piece.position == [1, 2] }.remove!
      player1.pieces.detect { |piece| piece.position == [3, 0] }.remove!
      player1.pieces.detect { |piece| piece.position == [5, 2] }.remove!

      game.send(:whose_turn=, player2)
      piece = player2.add_piece(1, 2)
      expect {
        expect {
          player2.should be_has_jump
          game.toggle_turn(piece, piece.move_to(3, 0))
          player2.should be_has_jump
        }.to change(piece, :kinged?).from(false).to(true)
      }.to change(game, :whose_turn).from(player2).to(player1)
    end

    it "should let a piece make multiple jumps on the same turn it reaches the end and is already kinged" do
      # setup a situation where a player can jump to get kinged, and have another jump available after
      player1.pieces.detect { |piece| piece.position == [1, 2] }.remove!
      player1.pieces.detect { |piece| piece.position == [3, 0] }.remove!
      player1.pieces.detect { |piece| piece.position == [5, 2] }.remove!

      game.send(:whose_turn=, player2)
      piece = player2.add_piece(1, 2)
      piece.king_me!
      expect {
        expect {
          player2.should be_has_jump
          game.toggle_turn(piece, piece.move_to(3, 0))
          player2.should be_has_jump
        }.to_not change(piece, :kinged?).from(true)
      }.to_not change(game, :whose_turn).from(player2)
    end

    it "should only allow the same piece to make multiple jumps" do
      # setup a situation where 2 pieces can make a jump, do the jump, and confirm the turn is over
      player1.pieces.detect { |piece| piece.position == [2, 1] }.remove!
      player1.pieces.detect { |piece| piece.position == [4, 1] }.remove!

      piece1 = player2.add_piece(0, 3)
      piece2 = player2.add_piece(6, 3)

      game.send(:whose_turn=, player2)
      expect {
        game.toggle_turn(piece1, piece1.move_to(2, 1))
      }.to change(game, :whose_turn).from(player2).to(player1)
    end
  end
end


text:
package info.jayharris.klondike;

public interface KlondikeUI {
}


text:
using System.Collections.Generic;
using Vk.Api.Schema.Enums.Filters;

namespace Vk.Api.Schema.Parameters.Group
{
    /// <summary>
    /// Интерфейс для представления параметров запроса для groups.getRequests <para/>
    /// Документация: <see href="https://vk.com/dev/groups.getRequests"/>
    /// </summary>
    public interface IGroupGetRequestsParameters
    {
        /// <summary>
        /// Идентификатор сообщества (указывается без знака «минус»)
        /// </summary>
        /// <remarks>
        /// Обязательный параметр
        /// </remarks>
        int GroupId { get; set; }

        /// <summary>
        /// Смещение, необходимое для выборки определенного подмножества результатов
        /// </summary>
        /// <remarks>
        /// По умолчанию — 0
        /// </remarks>
        int? Offset { get; set; }

        /// <summary>
        /// Число результатов, которые необходимо вернуть
        /// </summary>
        /// <remarks>
        /// По умолчанию 20, максимальное значение 200
        /// </remarks>
        int? Count { get; set; }

        /// <summary>
        /// Список дополнительных полей профилей, которые необходимо вернуть
        /// </summary>
        IEnumerable<UserField> Fields { get; set; }
    }
}