text:
namespace Serilog.PerformanceTests;

/// <summary>
/// Determines the cost of rendering an event out to one of the typical text targets,
/// like the console or a text file.
/// </summary>
[MemoryDiagnoser]
public class OutputTemplateRenderingBenchmark
{
    const string DefaultFileOutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}";
    static readonly LogEvent HelloWorldEvent = Some.InformationEvent("Hello, {Name}", "World");
    static readonly MessageTemplateTextFormatter Formatter = new(DefaultFileOutputTemplate, CultureInfo.InvariantCulture);

    readonly NullTextWriter _output = new();

    [Benchmark]
    public void FormatToOutput()
    {
        Formatter.Format(HelloWorldEvent, _output);
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:scrollbarStyle="outsideOverlay">

    <LinearLayout
	    android:layout_width="match_parent"
	    android:layout_height="wrap_content"
	    android:orientation="vertical"
	    android:gravity="center"
        android:padding="8dp">

	    <TextView
			android:layout_width="match_parent"
		    android:layout_height="wrap_content"
		    android:textSize="@dimen/title_text"
		    android:padding="8dp"
		    android:textColor="#FF000000"
		    android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
		    android:text="Flat"/>

	    <LinearLayout
	        android:layout_width="match_parent"
	        android:layout_height="wrap_content"
	        android:orientation="horizontal"
	        android:weightSum="1.0"
	        android:gravity="center">

	        <com.rey.material.widget.Button
                style="@style/FlatButtonRippleStyle"
		        android:id="@+id/button_bt_flat"
		        android:layout_width="0dp"
		        android:layout_height="@dimen/bt_height"
		        android:layout_weight="0.4"
		        android:textColor="#FF000000"
		        android:textAppearance="@style/Base.TextAppearance.AppCompat.Button"
		        android:text="BUTTON"/>

	        <View
	            android:layout_width="0dp"
		        android:layout_height="1dp"
		        android:layout_weight="0.1"/>

	        <com.rey.material.widget.Button
                style="@style/FlatColorButtonRippleStyle"
		        android:id="@+id/button_bt_flat_color"
		        android:layout_width="0dp"
		        android:layout_height="@dimen/bt_height"
		        android:layout_weight="0.4"
		        android:textColor="#FF2196F3"
		        android:textAppearance="@style/Base.TextAppearance.AppCompat.Button"
		        android:text="BUTTON"
		        app:rd_delayClick="true"/>

	    </LinearLayout>

	    <LinearLayout
	        android:layout_width="match_parent"
	        android:layout_height="wrap_content"
	        android:orientation="horizontal"
	        android:weightSum="1.0"
	        android:gravity="center"
	        android:paddingTop="8dp">

	        <com.rey.material.widget.Button
                style="@style/FlatWaveButtonRippleStyle"
		        android:id="@+id/button_bt_flat_wave"
		        android:layout_width="0dp"
		        android:layout_height="@dimen/bt_height"
		        android:layout_weight="0.4"
		        android:textColor="#FF000000"
		        android:textAppearance="@style/Base.TextAppearance.AppCompat.Button"
		        android:text="BUTTON"/>

	        <View
	            android:layout_width="0dp"
		        android:layout_height="1dp"
		        android:layout_weight="0.1"/>

	        <com.rey.material.widget.Button
                style="@style/FlatWaveColorButtonRippleStyle"
		        android:id="@+id/button_bt_flat_wave_color"
		        android:layout_width="0dp"
		        android:layout_height="@dimen/bt_height"
		        android:layout_weight="0.4"
		        android:textColor="#FF2196F3"
		        android:textAppearance="@style/Base.TextAppearance.AppCompat.Button"
		        android:text="BUTTON"
		        app:rd_delayClick="true"/>

	    </LinearLayout>

	    <TextView
			android:layout_width="match_parent"
		    android:layout_height="wrap_content"
		    android:textSize="@dimen/title_text"
		    android:padding="8dp"
		    android:textColor="#FF000000"
		    android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
		    android:text="Raise"/>

	    <LinearLayout
	        android:layout_width="match_parent"
	        android:layout_height="wrap_content"
	        android:orientation="horizontal"
	        android:weightSum="1.0"
	        android:gravity="center">

	        <com.rey.material.widget.Button
                style="@style/RaiseButtonRippleStyle"
		        android:id="@+id/button_bt_raise"
		        android:layout_width="0dp"
		        android:layout_height="@dimen/bt_height"
		        android:layout_weight="0.4"
		        android:textColor="#FF000000"
		        android:textAppearance="@style/Base.TextAppearance.AppCompat.Button"
		        android:text="BUTTON"/>

	        <View
	            android:layout_width="0dp"
		        android:layout_height="1dp"
		        android:layout_weight="0.1"/>

	        <com.rey.material.widget.Button
                style="@style/RaiseColorButtonRippleStyle"
		        android:id="@+id/button_bt_raise_color"
		        android:layout_width="0dp"
		        android:layout_height="@dimen/bt_height"
		        android:layout_weight="0.4"
		        android:textColor="#FFFFFFFF"
		        android:textAppearance="@style/Base.TextAppearance.AppCompat.Button"
		        android:text="BUTTON"
		        app:rd_delayClick="true"/>

	    </LinearLayout>

	    <LinearLayout
	        android:layout_width="match_parent"
	        android:layout_height="wrap_content"
	        android:orientation="horizontal"
	        android:weightSum="1.0"
	        android:gravity="center"
	        android:paddingTop="8dp">

	        <com.rey.material.widget.Button
                style="@style/RaiseWaveButtonRippleStyle"
		        android:id="@+id/button_bt_raise_wave"
		        android:layout_width="0dp"
		        android:layout_height="@dimen/bt_height"
		        android:layout_weight="0.4"
		        android:textColor="#FF000000"
		        android:textAppearance="@style/Base.TextAppearance.AppCompat.Button"
		        android:text="BUTTON"/>

	        <View
	            android:layout_width="0dp"
		        android:layout_height="1dp"
		        android:layout_weight="0.1"/>

	        <com.rey.material.widget.Button
                style="@style/RaiseWaveColorButtonRippleStyle"
		        android:id="@+id/button_bt_raise_wave_color"
		        android:layout_width="0dp"
		        android:layout_height="@dimen/bt_height"
		        android:layout_weight="0.4"
		        android:textColor="#FFFFFFFF"
		        android:textAppearance="@style/Base.TextAppearance.AppCompat.Button"
		        android:text="BUTTON"
		        app:rd_delayClick="true"/>

	    </LinearLayout>

	    <TextView
			android:layout_width="match_parent"
		    android:layout_height="wrap_content"
		    android:textSize="@dimen/title_text"
		    android:padding="8dp"
		    android:textColor="#FF000000"
		    android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
		    android:text="Float"/>

	    <LinearLayout
	        android:layout_width="match_parent"
	        android:layout_height="wrap_content"
	        android:orientation="horizontal"
	        android:weightSum="1.0"
	        android:gravity="center">

            <com.rey.material.widget.FloatingActionButton
                style="@style/FloatingActionButton"
                android:id="@+id/button_bt_float"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

	        <View
	            android:layout_width="100dp"
		        android:layout_height="1dp"/>

            <com.rey.material.widget.FloatingActionButton
                style="@style/FloatingColorActionButton"
                android:id="@+id/button_bt_float_color"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

	    </LinearLayout>

	    <LinearLayout
	        android:layout_width="match_parent"
	        android:layout_height="wrap_content"
	        android:orientation="horizontal"
	        android:weightSum="1.0"
	        android:gravity="center"
	        android:padding="8dp">

            <com.rey.material.widget.FloatingActionButton
                style="@style/FloatingWaveActionButton"
                android:id="@+id/button_bt_float_wave"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

	        <View
	            android:layout_width="100dp"
		        android:layout_height="1dp"/>

            <com.rey.material.widget.FloatingActionButton
                style="@style/FloatingWaveColorActionButton"
                android:id="@+id/button_bt_float_wave_color"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

        </LinearLayout>

	</LinearLayout>

</ScrollView>

redpajama_set_name: RedPajamaGithub


text:
package org.apache.servicecomb.swagger.converter.model;

import org.apache.servicecomb.swagger.converter.property.ArrayPropertyConverter;

import com.fasterxml.jackson.databind.JavaType;

import io.swagger.models.ArrayModel;
import io.swagger.models.Swagger;

public class ArrayModelConverter extends AbstractModelConverter {
  @Override
  public JavaType doConvert(Swagger swagger, Object model) {
    ArrayModel arrayModel = (ArrayModel) model;

    if (arrayModel.getItems() != null) {
      return ArrayPropertyConverter.findJavaType(swagger, arrayModel.getItems(), false);
    }

    // don't know when will this happen.
    throw new IllegalStateException("not support null array model items.");
  }
}


text:
% Copyright (c) 2015, William Breathitt Gray
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are
% met:
%
% 1. Redistributions of source code must retain the above copyright
%    notice, this list of conditions and the following disclaimer.
%
% 2. Redistributions in binary form must reproduce the above copyright
%    notice, this list of conditions and the following disclaimer in the
%    documentation and/or other materials provided with the
%    distribution.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
% "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
% A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
% HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
% SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
% LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
% DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
% THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
% (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
% OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\documentclass[crop]{standalone}
\usepackage{etoolbox,tikz}
\begin{document}
\begin{tikzpicture}
        \draw[help lines] (0,0) grid (10,10);
        \draw[<->] (10,0) -- (0,0) -- (0,10);
        \foreach \i in {0,...,10}{
                \node[below] at (\i, 0){\i};
                \node[left] at (0, \i){\i};
        }
        \foreach \i in {1,...,10}{
                \foreach \j in {2,3,5,7}{
                        \ifnumless{\i*\j}{11}{
                                \draw[fill] (\j,\i*\j) circle[radius=0.1];
                        }{}
                }
        }
        \draw[dashed,ultra thick,->] (2,6) node[above left]{y=6} -- (9.5,6);
\end{tikzpicture}
\end{document}


text:
module.exports = function configure (utils) {

  function parse (row, callback) {
    var detail = utils.select(row, 'Raw-Values');
    if(!detail) {
      return callback( );
    }

    detail = detail.split(',');
    var carbs = detail[2].split('=')[1];
    var data = {
      carbs: parseInt(carbs),
      value: carbs,
      type: 'carbs',
      units: detail[3].split('=')[1],
      deviceTime: utils.reformatISO(utils.select(row, 'Timestamp'))
    };
    return callback(null, data);
  }

  function isValid (data) {
    return (
      !isNaN(data.carbs) &&
      data.units &&
      data.type == 'carbs'
    );
  }

  var pattern = /BolusWizardBolusEstimate/g;
  var stream = utils.pipeline(utils.split( ), utils.map(parse), utils.validator(isValid));
  var parser = { pattern: pattern, stream: stream, parse: parse };
  return parser;
}


text:
using System;
using System.Windows.Input;

using UsingCustomMVVM.Helpers;
using UsingCustomMVVM.Services;

using Windows.ApplicationModel;

namespace UsingCustomMVVM.ViewModels
{
    public class SettingsViewModel : Observable
    {
        // TODO UWPTemplates: Add other settings as necessary. For help see https://github.com/Microsoft/WindowsTemplateStudio/blob/master/docs/pages/settings.md
        private bool _isLightThemeEnabled;
        public bool IsLightThemeEnabled
        {
            get { return _isLightThemeEnabled; }
            set { Set(ref _isLightThemeEnabled, value); }
        }

        private string _appDescription;
        public string AppDescription
        {
            get { return _appDescription; }
            set { Set(ref _appDescription, value); }
        }

        public ICommand SwitchThemeCommand { get; private set; }

        public SettingsViewModel()
        {
            SwitchThemeCommand = new RelayCommand(async () => { await ThemeSelectorService.SwitchThemeAsync(); });
        }

        public void Initialize()
        {
            IsLightThemeEnabled = ThemeSelectorService.IsLightThemeEnabled;
            AppDescription = GetAppDescription();
        }

        private string GetAppDescription()
        {
            var package = Package.Current;
            var packageId = package.Id;
            var version = packageId.Version;

            return $"{package.DisplayName} - {version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
        }
    }
}


text:
void allowConnections();
void *handleConnections(void*);
void *handleFriend(void*);
void *handleStdin(void*);
void *handleServer(void*);
void closeLocalSockets();
void terminateFriendThreads();
void exitHandler();
void termination_handler(int);
int getUserFd(const std::string&);
bool hasFriend(const std::string&);
Location getFriendAddress(const std::string&);
void removeFriendInfo(const std::string&);
void removeConnectedFriend(const int&);
bool hasInviteFrom(const std::string&);
void removeInviteFrom(const std::string&);
bool hasSentInviteTo(const std::string&);
void removeSentInviteTo(const std::string&);
void displayHelp();

bool logged_in;
int local_socket;
int server_socket;
std::string client_username;
std::string server_hostname;
std::vector<std::shared_ptr<User>> friend_info;
std::vector<std::string> received_invites;
std::vector<std::string> sent_invites;
std::map<int, std::string> connected_friends;
std::map<int, pthread_t> connected_threads;
pthread_t connection_thread;
pthread_t stdin_thread;
pthread_t server_thread;
pthread_attr_t joined_thread_attr;
pthread_attr_t detached_thread_attr;
pthread_mutex_t friend_info_mutex;
pthread_mutex_t received_invites_mutex;
pthread_mutex_t sent_invites_mutex;
pthread_mutex_t connected_friends_mutex;
pthread_mutex_t connected_threads_mutex;

int main(int argc, char *argv[])
{
	if (argc != 3) {
		std::cerr << "usage: ./messenger_client server_hostname server_port\n";
		exit(EXIT_FAILURE);
	}

	signal(SIGINT, termination_handler);

	struct addrinfo hints;
	struct addrinfo *info;

	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_INET;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_flags = AI_CANONNAME;

	if (getaddrinfo(argv[1], argv[2], &hints, &info) != 0) {
		std::cerr << "Failed to get server address information\n";
		exit(EXIT_FAILURE);
	}

	if ((server_socket = socket(info->ai_family, info->ai_socktype, info->ai_protocol)) < 0) {
		std::cerr << "Failed to create client-to-server socket\n";
		exit(EXIT_FAILURE);
	}

	if (connect(server_socket, info->ai_addr, info->ai_addrlen) < 0) {
		std::cerr << "Failed to connect to " << argv[1] << " on port " << argv[2] << '\n';
		exit(EXIT_FAILURE);
	}

	std::cout << "You are now connected to " << argv[1] << " on port " << argv[2] << ". Enter \"help\" for a list of commands.\n";

	logged_in = false;
	server_hostname = argv[1];

	if (pthread_mutex_init(&friend_info_mutex, nullptr) != 0) {
		std::cerr << "Failed to initialize friend_info_mutex\n";
		exit(EXIT_FAILURE);
	}

	if (pthread_mutex_init(&received_invites_mutex, nullptr) != 0) {
		std::cerr << "Failed to initialize received_invites_mutex\n";
		exit(EXIT_FAILURE);
	}

	if (pthread_mutex_init(&sent_invites_mutex, nullptr) != 0) {
		std::cerr << "Failed to initialize sent_invites_mutex\n";
		exit(EXIT_FAILURE);
	}

	if (pthread_mutex_init(&connected_friends_mutex, nullptr) != 0) {
		std::cerr << "Failed to initialize connected_friends_mutex\n";
		exit(EXIT_FAILURE);
	}

	if (pthread_mutex_init(&connected_threads_mutex, nullptr) != 0) {
		std::cerr << "Failed to initialize connected_threads_mutex\n";
		exit(EXIT_FAILURE);
	}

	pthread_attr_init(&joined_thread_attr);
	pthread_attr_setdetachstate(&joined_thread_attr, PTHREAD_CREATE_JOINABLE);
	pthread_attr_init(&detached_thread_attr);
    pthread_attr_setdetachstate(&detached_thread_attr, PTHREAD_CREATE_DETACHED);

	if (pthread_create(&stdin_thread, &joined_thread_attr, handleStdin, nullptr) != 0) {
		std::cerr << "Failed to create thread for standard input\n";
		exit(EXIT_FAILURE);
	}

	if (pthread_create(&server_thread, &joined_thread_attr, handleServer, nullptr) != 0) {
		std::cerr << "Failed to create thread for server messages\n";
		exit(EXIT_FAILURE);
	}

	pthread_join(stdin_thread, NULL);
	pthread_join(server_thread, NULL);

	return EXIT_SUCCESS;
}

void allowConnections()
{
	struct sockaddr_in local_address;
	socklen_t local_address_length;
	struct addrinfo hints;
	struct addrinfo *info;
	char buffer[256];

	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_INET;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_flags = AI_CANONNAME;

	// create socket for other clients to connect to
	if ((local_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		std::cerr << "Failed to create client's local socket\n";
		exit(EXIT_FAILURE);
	}

	memset(&local_address, 0, sizeof(local_address));
	local_address.sin_family = AF_INET;
	local_address.sin_port = htons(0);
	local_address.sin_addr.s_addr = htonl(INADDR_ANY);

	local_address_length = sizeof(local_address);

	if (bind(local_socket, (struct sockaddr *)&local_address, local_address_length) < 0) {
		std::cerr << "Failed to bind address to client's local socket\n";
		exit(EXIT_FAILURE);
	}

	if (listen(local_socket, 5) < 0) {
		std::cerr << "Failed to set client's local socket as passive\n";
		exit(EXIT_FAILURE);
	}

	if (getsockname(local_socket, (struct sockaddr *)&local_address, &local_address_length) < 0) {
		std::cerr << "Failed to get address to which client's local socket is bound\n";
		exit(EXIT_FAILURE);
	}

	char hostname[256];

	if (gethostname(hostname, sizeof(hostname)) < 0) {
		std::cerr << "Failed to get client's hostname\n";
		exit(EXIT_FAILURE);
	}

	if (getaddrinfo(hostname, nullptr, &hints, &info) != 0) {
		std::cerr << "Failed to get client address information\n";
		exit(EXIT_FAILURE);
	}

	// send client's address information to server
	snprintf(buffer, sizeof(buffer), "LOCATION %s %d", info->ai_canonname, ntohs(local_address.sin_port));
	write(server_socket, buffer, sizeof(buffer));

	// create thread for accepting connections from friends
	if (pthread_create(&connection_thread, &detached_thread_attr, handleConnections, nullptr) != 0) {
		std::cerr << "Failed to create thread for accepting connections\n";
		exit(EXIT_FAILURE);
	}
}

void *handleConnections(void *arg)
{
	int new_socket;
	struct sockaddr_in new_addr;
	socklen_t new_addr_len = sizeof(new_addr);
	pthread_t new_thread;

	while (true) {
		if ((new_socket = accept(local_socket, (struct sockaddr *)&new_addr, &new_addr_len)) >= 0) {
			if (pthread_create(&new_thread, &detached_thread_attr, handleFriend, (void*)&new_socket) != 0) {
				continue;
			}
			pthread_mutex_lock(&connected_threads_mutex);
			connected_threads.insert(std::make_pair(new_socket, new_thread));
			pthread_mutex_unlock(&connected_threads_mutex);
		}
	}
}

void *handleFriend(void *sock)
{
	int socket_fd = *(int*)sock;
	char response[256];
	while (true) {
		if (read(socket_fd, response, sizeof(response)) > 0) {
			std::istringstream strm(response);
			std::string type;
			strm >> type;
			pthread_mutex_lock(&connected_friends_mutex);
			if (type == "USER") {
				// newly connected friend is informing client of username
				std::string username;
				strm >> username;
				connected_friends.insert(std::make_pair(socket_fd, username));
			} else {
				// just a regular message
				std::cout << '[' << connected_friends[socket_fd] << "]: " <<  response << '\n';
			}
			pthread_mutex_unlock(&connected_friends_mutex);
		}
	}
	return nullptr;
}

void *handleStdin(void *arg)
{
	char buffer[256];
	std::string input;
	while (true) {
		std::getline(std::cin, input);
		trimString(input);
		std::istringstream strm(input);
		std::string command;
		strm >> command;
		if (!logged_in) {
			if (command == "register") {
				// register with server
				std::string username;
				std::string password;
				strm >> username >> password;

				if (username.empty() || password.empty()) {
					std::cout << "Syntax: register [username] [password]\n";
					continue;
				}

				snprintf(buffer, sizeof(buffer), "REGISTER %s %s", username.c_str(), createHash(password));
				write(server_socket, buffer, sizeof(buffer));
			} else if (command == "login") {
				// login to server
				std::string username;
				std::string password;
				strm >> username >> password;

				if (username.empty() || password.empty()) {
					std::cout << "Syntax: login [username] [password]\n";
					continue;
				}

				snprintf(buffer, sizeof(buffer), "LOGIN %s %s", username.c_str(), createHash(password));
				write(server_socket, buffer, sizeof(buffer));
			} else if (command == "help") {
				displayHelp();
			} else if (command == "exit") {
				strncpy(buffer, "EXIT", sizeof(buffer));
				write(server_socket, buffer, sizeof(buffer));
				close(server_socket);
				exit(EXIT_SUCCESS);
			} else {
				std::cout << "Unrecognized command\n";
			}
		} else {
			if (command == "message") {
				std::string username;
				std::string message;
				strm >> username;
				strm.ignore();
				getline(strm, message);

				if (username.empty() || message.empty()) {
					std::cout << "Syntax: message [friend username] [message]\n";
					continue;
				}

				if (username == client_username) {
					std::cout << "You can't message yourself\n";
					continue;
				}

				pthread_mutex_lock(&connected_friends_mutex);
				// file descriptor to write to
				int friend_fd = getUserFd(username);
				if (friend_fd < 0) {
					// not connected, need to first establish connection
					Location friend_address;
					pthread_mutex_lock(&friend_info_mutex);
					try {
						friend_address = getFriendAddress(username);
					} catch (std::string err) {
						std::cout << err << '\n';
						pthread_mutex_unlock(&friend_info_mutex);
						continue;
					}
					pthread_mutex_unlock(&friend_info_mutex);

					struct addrinfo hints;
					struct addrinfo *info;
					int new_socket;

					memset(&hints, 0, sizeof(hints));
					hints.ai_family = AF_INET;
					hints.ai_socktype = SOCK_STREAM;
					hints.ai_flags = AI_CANONNAME;

					if (getaddrinfo(friend_address.hostname.c_str(), friend_address.port.c_str(), &hints, &info) != 0) {
						std::cout << "Failed to get address information of friend " << username << '\n';
						continue;
					}
					if ((new_socket = socket(info->ai_family, info->ai_socktype, info->ai_protocol)) < 0) {
						std::cout << "Failed to create socket to friend " << username << '\n';
						continue;
					}
					if (connect(new_socket, info->ai_addr, info->ai_addrlen) < 0) {
						std::cout << "Failed to establish connection with friend " << username << '\n';
						continue;
					}

					friend_fd = new_socket;

					// let friend know of username
					sprintf(buffer, "USER %s", client_username.c_str());
					write(friend_fd, buffer, sizeof(buffer));

					// create thread to handle messages from newly connected friend
					pthread_t new_thread;
					if (pthread_create(&new_thread, &detached_thread_attr, handleFriend, (void*)&friend_fd) != 0) {
						continue;
					}
					pthread_mutex_lock(&connected_threads_mutex);
					connected_threads.insert(std::make_pair(friend_fd, new_thread));
					pthread_mutex_unlock(&connected_threads_mutex);
					connected_friends.insert(std::make_pair(friend_fd, username));
				}
				pthread_mutex_unlock(&connected_friends_mutex);
				// send the message
				strncpy(buffer, message.c_str(), sizeof(buffer));
				write(friend_fd, buffer, sizeof(buffer));
			} else if (command == "invite") {
				std::string username;
				std::string message;
				strm >> username;
				strm.ignore();
				getline(strm, message);

				if (username.empty()) {
					std::cout << "Syntax: invite [username] [optional message]\n";
					continue;
				}

				if (username == client_username) {
					std::cout << "You can't invite yourself\n";
					continue;
				}

				// check if this user is already a friend
				pthread_mutex_lock(&friend_info_mutex);
				if (hasFriend(username)) {
					std::cout << "You are already friends with " << username << '\n';
					continue;
				}
				pthread_mutex_unlock(&friend_info_mutex);

				// check if there is a pending invite to this user
				pthread_mutex_lock(&sent_invites_mutex);
				if (hasSentInviteTo(username)) {
					std::cout << "You have already sent an invite to " << username << '\n';
					continue;
				}
				pthread_mutex_unlock(&sent_invites_mutex);

				// check if there is a pending invite from this user
				pthread_mutex_lock(&received_invites_mutex);
				if (hasInviteFrom(username)) {
					std::cout << "You have a pending invite from " << username << '\n';
					continue;
				}
				pthread_mutex_unlock(&received_invites_mutex);

				snprintf(buffer, sizeof(buffer), "INVITE %s %s", username.c_str(), message.c_str());
				write(server_socket, buffer, sizeof(buffer));
				pthread_mutex_lock(&sent_invites_mutex);
				sent_invites.push_back(username);
				pthread_mutex_unlock(&sent_invites_mutex);
			} else if (command == "accept") {
				std::string username;
				std::string message;
				strm >> username;
				strm.ignore();
				getline(strm, message);

				if (username.empty()) {
					std::cout << "Syntax: accept [username] [optional message]\n";
					continue;
				}

				pthread_mutex_lock(&received_invites_mutex);
				if (hasInviteFrom(username)) {
					snprintf(buffer, sizeof(buffer), "INVITE_ACCEPT %s %s", username.c_str(), message.c_str());
					write(server_socket, buffer, sizeof(buffer));
					removeInviteFrom(username);
				} else {
					std::cout << "You have not received an invite from " << username << " to accept\n";
				}
				pthread_mutex_unlock(&received_invites_mutex);
			} else if (command == "logout") {
				strncpy(buffer, "LOGOUT", sizeof(buffer));
				write(server_socket, buffer, sizeof(buffer));
				// terminate connection and friend threads
				pthread_cancel(connection_thread);
				terminateFriendThreads();
				// only close local sockets, keep server socket open
				closeLocalSockets();
				// clear friend information
				friend_info.clear();
				// clear online friends
				connected_friends.clear();
				// clear invites
				received_invites.clear();
				sent_invites.clear();
				// reset username
				client_username = "";
				std::cout << "You have logged out of " << server_hostname << '\n';
				logged_in = false;
			} else if (command == "help") {
				displayHelp();
			} else {
				std::cout << "Unrecognized command\n";
			}
		}
	}
	return nullptr;
}

void *handleServer(void *arg)
{
	char response[256];
	while (true) {
		if (read(server_socket, response, sizeof(response)) > 0) {
			std::istringstream strm(response);
			std::string type;
			strm >> type;
			if (type == "REGISTER") {
				std::string username;
				int status_code;
				strm >> username >> status_code;
				if (status_code == 200) {
					std::cout << "You have successfully registered as " << username << ". Please login.\n";
				} else {
					std::cout << "Username " << username << " is unavailable. Please choose another.\n";
				}
			} else if (type == "LOGIN") {
				std::string username;
				int status_code;
				strm >> username >> status_code;
				if (status_code == 200) {
					std::cout << "You have successfully logged in as " << username << ". Enter \"help\" for a list of commands.\n";
					logged_in = true;
					client_username = username;
					allowConnections();
				} else {
					std::cout << "Credentials are incorrect, or user " << username << " is already logged in. Try again.\n";
				}
			} else if (type == "LOCATION") {
				std::string username;
				std::string address;
				std::string port;
				strm >> username >> address >> port;
				std::cout << "Friend " << username << " is online\n";
				pthread_mutex_lock(&friend_info_mutex);
				friend_info.push_back(std::make_shared<User>(username, address, port));
				pthread_mutex_unlock(&friend_info_mutex);
			} else if (type == "INVITE_FROM") {
				std::string username;
				std::string message;
				strm.ignore();
				strm >> username;
				getline(strm, message);
				std::cout << "You have received an invite from " << username << ": " << message << '\n';
				pthread_mutex_lock(&received_invites_mutex);
				received_invites.push_back(username);
				pthread_mutex_unlock(&received_invites_mutex);
			} else if (type == "INVITE_ACCEPT") {
				std::string username;
				std::string message;
				strm >> username;
				strm.ignore();
				getline(strm, message);
				std::cout << username << " has accepted your invitation: " << message << '\n';
				pthread_mutex_lock(&sent_invites_mutex);
				removeSentInviteTo(username);
				pthread_mutex_unlock(&sent_invites_mutex);
			} else if (type == "INVITE_FAILED") {
				std::string username;
				strm >> username;
				std::cout << "Failed to send invite to " << username << ". User does not exist.\n";
				pthread_mutex_lock(&sent_invites_mutex);
				removeSentInviteTo(username);
				pthread_mutex_unlock(&sent_invites_mutex);
			} else if (type == "SHUTDOWN") {
				std::cout << server_hostname << " has shut down\n";
				exitHandler();
			} else if (type == "TERMINATE" || type == "LOGOUT") {
				std::string username;
				strm >> username;
				std::cout << "Friend " << username << " has logged out\n";
				// remove location information for friend
				pthread_mutex_lock(&friend_info_mutex);
				removeFriendInfo(username);
				pthread_mutex_unlock(&friend_info_mutex);
				pthread_mutex_lock(&connected_friends_mutex);
				// if friend was connected, remove from connections and terminate thread
				int fd = getUserFd(username);
				if (fd != -1) {
					removeConnectedFriend(fd);
				}
				pthread_mutex_unlock(&connected_friends_mutex);
			} else {
				// some other message, just display it
				std::cout << response << '\n';
			}
		}
	}
	return nullptr;
}

void closeLocalSockets()
{
	for (auto itr = connected_friends.begin(); itr != connected_friends.end(); ++itr) {
		close(itr->first);
	}
	close(local_socket);
}

int getUserFd(const std::string &username)
{
	// return file descriptor of friend with username username
	for (auto itr = connected_friends.begin(); itr != connected_friends.end(); ++itr) {
		if (itr->second == username) {
			return itr->first;
		}
	}
	return -1;
}

bool hasFriend(const std::string &username)
{
	for (auto itr = friend_info.begin(); itr != friend_info.end(); ++itr) {
		if ((*itr)->getUsername() == username) {
			return true;
		}
	}
	return false;
}

Location getFriendAddress(const std::string &username)
{
	for (auto itr = friend_info.begin(); itr != friend_info.end(); ++itr) {
		if ((*itr)->getUsername() == username) {
			return (*itr)->getAddressInfo();
		}
	}

	throw "Friend " + username + " not found";
}

void removeFriendInfo(const std::string &username)
{
	// remove friend's location information
	for (auto itr = friend_info.begin(); itr != friend_info.end(); ++itr) {
		if ((*itr)->getUsername() == username) {
			friend_info.erase(itr);
			break;
		}
	}
}

void removeConnectedFriend(const int &fd)
{
	close(fd);
	connected_friends.erase(fd);
	pthread_cancel(connected_threads[fd]);
	connected_threads.erase(fd);
}

bool hasInviteFrom(const std::string &username)
{
	for (auto itr = received_invites.begin(); itr != received_invites.end(); ++itr) {
		if (*itr == username) {
			return true;
		}
	}
	return false;
}

void removeInviteFrom(const std::string &username)
{
	for (auto itr = received_invites.begin(); itr != received_invites.end(); ++itr) {
		if (*itr == username) {
			received_invites.erase(itr);
			break;
		}
	}
}

bool hasSentInviteTo(const std::string &username)
{
	for (auto itr = sent_invites.begin(); itr != sent_invites.end(); ++itr) {
		if (*itr == username) {
			return true;
		}
	}
	return false;
}

void removeSentInviteTo(const std::string &username)
{
	for (auto itr = sent_invites.begin(); itr != sent_invites.end(); ++itr) {
		if (*itr == username) {
			sent_invites.erase(itr);
			break;
		}
	}
}

void terminateFriendThreads()
{
	for (auto itr = connected_threads.begin(); itr != connected_threads.end(); ++itr) {
		pthread_cancel(itr->second);
	}
	connected_threads.clear();
}

void exitHandler()
{
	if (logged_in) {
		terminateFriendThreads();
		closeLocalSockets();
	}
	close(server_socket);
	pthread_mutex_destroy(&friend_info_mutex);
	pthread_mutex_destroy(&received_invites_mutex);
	pthread_mutex_destroy(&sent_invites_mutex);
	pthread_mutex_destroy(&connected_friends_mutex);
	pthread_mutex_destroy(&connected_threads_mutex);
	exit(EXIT_SUCCESS);
}

void termination_handler(int sig_num)
{
	char terminate_cmd[] = "TERMINATE";
	write(server_socket, terminate_cmd, sizeof(terminate_cmd));
	exitHandler();
}

void displayHelp()
{
	if (!logged_in) {
		std::cout << "register [username] [password] - register as new user\n";
		std::cout << "login [username] [password] - login as user\n";
		std::cout << "exit - exit the program\n";
	} else {
		std::cout << "message [friend username] [message] - send message to friend\n";
		std::cout << "invite [username] [optional message] - send friend invite\n";
		std::cout << "accept [username] [optional message] - accept friend invite\n";
		std::cout << "logout - logout of the server\n";
	}
	std::cout << "help - display this help of commands\n";
}


text:
package com.example.yetti.toneplayer.model;

import android.os.Parcel;
import android.os.Parcelable;

public class Artist implements Parcelable {
    private String mArtistName;
    private long mSongCount;
    private String mArtistArtUrl;
    private String mArtistGenre;

    public Artist(final String pArtistName, final long pSongCount, final String pArtistArtUrl, final String pArtistGenre ) {
        this.mArtistName = pArtistName;
        this.mSongCount = pSongCount;
        this.mArtistArtUrl = pArtistArtUrl;
        this.mArtistGenre = pArtistGenre;
    }
    public Artist(){

    }

    @Override
    public String toString() {
        return "ARTIST NAME " + mArtistName + " ARTIST SONG COUNT " + mSongCount + " ARTIST GENRE " + mArtistGenre + " ARTIST ARTWORK URL " + mArtistArtUrl;
    }

    protected Artist(final Parcel in) {
        mArtistName = in.readString();
        mSongCount = in.readLong();
        mArtistArtUrl = in.readString();
        mArtistGenre = in.readString();
    }

    public static final Creator<Artist> CREATOR = new Creator<Artist>() {

        @Override
        public Artist createFromParcel(final Parcel in) {
            return new Artist(in);
        }

        @Override
        public Artist[] newArray(final int size) {
            return new Artist[size];
        }
    };

    public String getArtistName() {
        return mArtistName;
    }

    public void setArtistName(final String pArtistName) {
        mArtistName = pArtistName;
    }

    public long getSongCount() {
        return mSongCount;
    }

    public void setSongCount(final long pSongCount) {
        mSongCount = pSongCount;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(final Parcel dest, final int flags) {

        dest.writeString(mArtistName);
        dest.writeLong(mSongCount);
        dest.writeString(mArtistArtUrl);
        dest.writeString(mArtistGenre);
    }

    public String getArtistArtUrl() {
        return mArtistArtUrl;
    }

    public void setArtistArtUrl(final String pArtistArtUrl) {
        mArtistArtUrl = pArtistArtUrl;
    }

    public String getArtistGenre() {
        return mArtistGenre;
    }

    public void setArtistGenre(final String pArtistGenre) {
        mArtistGenre = pArtistGenre;
    }
}


text:
<?php

namespace Drupal\shortcut\Tests;

use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Url;
use Drupal\shortcut\Entity\Shortcut;
use Drupal\shortcut\Entity\ShortcutSet;

/**
 * Create, view, edit, delete, and change shortcut links.
 *
 * @group shortcut
 */
class ShortcutLinksTest extends ShortcutTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = array('router_test', 'views', 'block');

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();

    $this->drupalPlaceBlock('page_title_block');
  }

  /**
   * Tests that creating a shortcut works properly.
   */
  public function testShortcutLinkAdd() {
    $set = $this->set;

    // Create an alias for the node so we can test aliases.
    $path = array(
      'source' => '/node/' . $this->node->id(),
      'alias' => '/' . $this->randomMachineName(8),
    );
    $this->container->get('path.alias_storage')->save($path['source'], $path['alias']);

    // Create some paths to test.
    $test_cases = [
      '/',
      '/admin',
      '/admin/config/system/site-information',
      '/node/' . $this->node->id() . '/edit',
      $path['alias'],
      '/router_test/test2',
      '/router_test/test3/value',
    ];

    $test_cases_non_access = [
      '/admin',
      '/admin/config/system/site-information',
    ];

    // Check that each new shortcut links where it should.
    foreach ($test_cases as $test_path) {
      $title = $this->randomMachineName();
      $form_data = array(
        'title[0][value]' => $title,
        'link[0][uri]' => $test_path,
      );
      $this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link', $form_data, t('Save'));
      $this->assertResponse(200);
      $this->assertText(t('Added a shortcut for @title.', array('@title' => $title)));
      $saved_set = ShortcutSet::load($set->id());
      $paths = $this->getShortcutInformation($saved_set, 'link');
      $this->assertTrue(in_array('internal:' . $test_path, $paths), 'Shortcut created: ' . $test_path);

      if (in_array($test_path, $test_cases_non_access)) {
        $this->assertNoLink($title, SafeMarkup::format('Shortcut link %url not accessible on the page.', ['%url' => $test_path]));
      }
      else {
        $this->assertLink($title, 0, SafeMarkup::format('Shortcut link %url found on the page.', ['%url' => $test_path]));
      }
    }
    $saved_set = ShortcutSet::load($set->id());
    // Test that saving and re-loading a shortcut preserves its values.
    $shortcuts = $saved_set->getShortcuts();
    foreach ($shortcuts as $entity) {
      // Test the node routes with parameters.
      $entity->save();
      $loaded = Shortcut::load($entity->id());
      $this->assertEqual($entity->link->uri, $loaded->link->uri);
      $this->assertEqual($entity->link->options, $loaded->link->options);
    }

    // Log in as non admin user, to check that access is checked when creating
    // shortcuts.
    $this->drupalLogin($this->shortcutUser);
    $title = $this->randomMachineName();
    $form_data = [
      'title[0][value]' => $title,
      'link[0][uri]' => '/admin',
    ];
    $this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link', $form_data, t('Save'));
    $this->assertResponse(200);
    $this->assertRaw(t("The path '@link_path' is inaccessible.", ['@link_path' => '/admin']));

    $form_data = [
      'title[0][value]' => $title,
      'link[0][uri]' => '/node',
    ];
    $this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link', $form_data, t('Save'));
    $this->assertLink($title, 0, 'Shortcut link found on the page.');

    // Create a new shortcut set and add a link to it.
    $this->drupalLogin($this->adminUser);
    $edit = array(
      'label' => $this->randomMachineName(),
      'id' => strtolower($this->randomMachineName()),
    );
    $this->drupalPostForm('admin/config/user-interface/shortcut/add-set', $edit, t('Save'));
    $title = $this->randomMachineName();
    $form_data = [
      'title[0][value]' => $title,
      'link[0][uri]' => '/admin',
    ];
    $this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $edit['id'] . '/add-link', $form_data, t('Save'));
    $this->assertResponse(200);
  }

  /**
   * Tests that the "add to shortcut" and "remove from shortcut" links work.
   */
  public function testShortcutQuickLink() {
    \Drupal::service('theme_handler')->install(array('seven'));
    $this->config('system.theme')->set('admin', 'seven')->save();
    $this->config('node.settings')->set('use_admin_theme', '1')->save();
    $this->container->get('router.builder')->rebuild();

    $this->drupalLogin($this->rootUser);
    $this->drupalGet('admin/config/system/cron');

    // Test the "Add to shortcuts" link.
    $this->clickLink('Add to Default shortcuts');
    $this->assertText('Added a shortcut for Cron.');
    $this->assertLink('Cron', 0, 'Shortcut link found on page');

    $this->drupalGet('admin/structure');
    $this->assertLink('Cron', 0, 'Shortcut link found on different page');

    // Test the "Remove from shortcuts" link.
    $this->clickLink('Cron');
    $this->clickLink('Remove from Default shortcuts');
    $this->assertText('The shortcut Cron has been deleted.');
    $this->assertNoLink('Cron', 'Shortcut link removed from page');

    $this->drupalGet('admin/structure');
    $this->assertNoLink('Cron', 'Shortcut link removed from different page');

    $this->drupalGet('admin/people');

    // Test the "Add to shortcuts" link for a page generated by views.
    $this->clickLink('Add to Default shortcuts');
    $this->assertText('Added a shortcut for People.');
    // Due to the structure of the markup in the link ::assertLink() doesn't
    // works here.
    $link = $this->xpath('//a[normalize-space()=:label]', array(':label' => 'Remove from Default shortcuts'));
    $this->assertTrue(!empty($link), 'Link Remove from Default shortcuts found.');

    // Test the "Remove from  shortcuts" link for a page generated by views.
    $this->clickLink('Remove from Default shortcuts');
    $this->assertText('The shortcut People has been deleted.');
    // Due to the structure of the markup in the link ::assertLink() doesn't
    // works here.
    $link = $this->xpath('//a[normalize-space()=:label]', array(':label' => 'Add to Default shortcuts'));
    $this->assertTrue(!empty($link), 'Link Add to Default shortcuts found.');

    // Test two pages which use same route name but different route parameters.
    $this->drupalGet('node/add/page');
    // Add Shortcut for Basic Page.
    $this->clickLink('Add to Default shortcuts');
    $this->assertText('Added a shortcut for Create Basic page.');
    // Assure that Article does not have its shortcut indicated as set.
    $this->drupalGet('node/add/article');
    $link = $this->xpath('//a[normalize-space()=:label]', array(':label' => 'Remove from Default shortcuts'));
    $this->assertTrue(empty($link), 'Link Remove to Default shortcuts not found for Create Article page.');
    // Add Shortcut for Article.
    $this->clickLink('Add to Default shortcuts');
    $this->assertText('Added a shortcut for Create Article.');
  }

  /**
   * Tests that shortcut links can be renamed.
   */
  public function testShortcutLinkRename() {
    $set = $this->set;

    // Attempt to rename shortcut link.
    $new_link_name = $this->randomMachineName();

    $shortcuts = $set->getShortcuts();
    $shortcut = reset($shortcuts);
    $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title[0][value]' => $new_link_name), t('Save'));
    $saved_set = ShortcutSet::load($set->id());
    $titles = $this->getShortcutInformation($saved_set, 'title');
    $this->assertTrue(in_array($new_link_name, $titles), 'Shortcut renamed: ' . $new_link_name);
    $this->assertLink($new_link_name, 0, 'Renamed shortcut link appears on the page.');
    $this->assertText(t('The shortcut @link has been updated.', array('@link' => $new_link_name)));
  }

  /**
   * Tests that changing the path of a shortcut link works.
   */
  public function testShortcutLinkChangePath() {
    $set = $this->set;

    // Tests changing a shortcut path.
    $new_link_path = '/admin/config';

    $shortcuts = $set->getShortcuts();
    $shortcut = reset($shortcuts);
    $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title[0][value]' => $shortcut->getTitle(), 'link[0][uri]' => $new_link_path), t('Save'));
    $saved_set = ShortcutSet::load($set->id());
    $paths = $this->getShortcutInformation($saved_set, 'link');
    $this->assertTrue(in_array('internal:' . $new_link_path, $paths), 'Shortcut path changed: ' . $new_link_path);
    $this->assertLinkByHref($new_link_path, 0, 'Shortcut with new path appears on the page.');
    $this->assertText(t('The shortcut @link has been updated.', array('@link' => $shortcut->getTitle())));
  }

  /**
   * Tests that changing the route of a shortcut link works.
   */
  public function testShortcutLinkChangeRoute() {
    $this->drupalLogin($this->rootUser);
    $this->drupalGet('admin/content');
    $this->assertResponse(200);
    // Disable the view.
    entity_load('view', 'content')->disable()->save();
    /** @var \Drupal\Core\Routing\RouteBuilderInterface $router_builder */
    $router_builder = \Drupal::service('router.builder');
    $router_builder->rebuildIfNeeded();
    $this->drupalGet('admin/content');
    $this->assertResponse(200);
  }

  /**
   * Tests deleting a shortcut link.
   */
  public function testShortcutLinkDelete() {
    $set = $this->set;

    $shortcuts = $set->getShortcuts();
    $shortcut = reset($shortcuts);
    $this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id() . '/delete', array(), 'Delete');
    $saved_set = ShortcutSet::load($set->id());
    $ids = $this->getShortcutInformation($saved_set, 'id');
    $this->assertFalse(in_array($shortcut->id(), $ids), 'Successfully deleted a shortcut.');

    // Delete all the remaining shortcut links.
    entity_delete_multiple('shortcut', array_filter($ids));

    // Get the front page to check that no exceptions occur.
    $this->drupalGet('');
  }

  /**
   * Tests that the add shortcut link is not displayed for 404/403 errors.
   *
   * Tests that the "Add to shortcuts" link is not displayed on a page not
   * found or a page the user does not have access to.
   */
  public function testNoShortcutLink() {
    // Change to a theme that displays shortcuts.
    \Drupal::service('theme_handler')->install(array('seven'));
    $this->config('system.theme')
      ->set('default', 'seven')
      ->save();

    $this->drupalGet('page-that-does-not-exist');
    $result = $this->xpath('//a[contains(@class, "shortcut-action--add")]');
    $this->assertTrue(empty($result), 'Add to shortcuts link was not shown on a page not found.');

    // The user does not have access to this path.
    $this->drupalGet('admin/modules');
    $result = $this->xpath('//a[contains(@class, "shortcut-action--add")]');
    $this->assertTrue(empty($result), 'Add to shortcuts link was not shown on a page the user does not have access to.');

    // Verify that the testing mechanism works by verifying the shortcut link
    // appears on admin/content.
    $this->drupalGet('admin/content');
    $result = $this->xpath('//a[contains(@class, "shortcut-action--remove")]');
    $this->assertTrue(!empty($result), 'Remove from shortcuts link was shown on a page the user does have access to.');

    // Verify that the shortcut link appears on routing only pages.
    $this->drupalGet('router_test/test2');
    $result = $this->xpath('//a[contains(@class, "shortcut-action--add")]');
    $this->assertTrue(!empty($result), 'Add to shortcuts link was shown on a page the user does have access to.');
  }

  /**
   * Tests that the 'access shortcuts' permissions works properly.
   */
  public function testAccessShortcutsPermission() {
    // Change to a theme that displays shortcuts.
    \Drupal::service('theme_handler')->install(array('seven'));
    $this->config('system.theme')
      ->set('default', 'seven')
      ->save();

    // Add cron to the default shortcut set.
    $this->drupalLogin($this->rootUser);
    $this->drupalGet('admin/config/system/cron');
    $this->clickLink('Add to Default shortcuts');

    // Verify that users without the 'access shortcuts' permission can't see the
    // shortcuts.
    $this->drupalLogin($this->drupalCreateUser(array('access toolbar')));
    $this->assertNoLink('Shortcuts', 'Shortcut link not found on page.');

    // Verify that users without the 'administer site configuration' permission
    // can't see the cron shortcuts.
    $this->drupalLogin($this->drupalCreateUser(array('access toolbar', 'access shortcuts')));
    $this->assertNoLink('Shortcuts', 'Shortcut link not found on page.');
    $this->assertNoLink('Cron', 'Cron shortcut link not found on page.');

    // Verify that users with the 'access shortcuts' permission can see the
    // shortcuts.
    $this->drupalLogin($this->drupalCreateUser(array(
      'access toolbar', 'access shortcuts', 'administer site configuration',
    )));
    $this->clickLink('Shortcuts', 0, 'Shortcut link found on page.');
    $this->assertLink('Cron', 0, 'Cron shortcut link found on page.');

    $this->verifyAccessShortcutsPermissionForEditPages();
  }

  /**
   * Tests the shortcuts are correctly ordered by weight in the toolbar.
   */
  public function testShortcutLinkOrder() {
    // Ensure to give permissions to access the shortcuts.
    $this->drupalLogin($this->drupalCreateUser(array('access toolbar', 'access shortcuts', 'access content overview', 'administer content types')));
    $this->drupalGet(Url::fromRoute('<front>'));
    $shortcuts = $this->cssSelect('#toolbar-item-shortcuts-tray .toolbar-menu a');
    $this->assertEqual((string) $shortcuts[0], 'Add content');
    $this->assertEqual((string) $shortcuts[1], 'All content');
    foreach($this->set->getShortcuts() as $shortcut) {
      $shortcut->setWeight($shortcut->getWeight() * -1)->save();
    }
    $this->drupalGet(Url::fromRoute('<front>'));
    $shortcuts = $this->cssSelect('#toolbar-item-shortcuts-tray .toolbar-menu a');
    $this->assertEqual((string) $shortcuts[0], 'All content');
    $this->assertEqual((string) $shortcuts[1], 'Add content');
  }

  /**
   * Tests that the 'access shortcuts' permission is required for shortcut set
   * administration page access.
   */
  private function verifyAccessShortcutsPermissionForEditPages() {
    // Create a user with customize links and switch sets permissions  but
    // without the 'access shortcuts' permission.
    $test_permissions = array(
      'customize shortcut links',
      'switch shortcut sets',
    );
    $noaccess_user = $this->drupalCreateUser($test_permissions);
    $this->drupalLogin($noaccess_user);

    // Verify that set administration pages are inaccessible without the
    // 'access shortcuts' permission.
    $edit_paths = array(
      'admin/config/user-interface/shortcut/manage/default/customize',
      'admin/config/user-interface/shortcut/manage/default',
      'user/' . $noaccess_user->id() . '/shortcuts',
    );

    foreach ($edit_paths as $path) {
      $this->drupalGet($path);
      $message = format_string('Access is denied on %s', array('%s' => $path));
      $this->assertResponse(403, $message);
    }
  }

  /**
   * Tests that the 'access shortcuts' permission is required to access the
   * shortcut block.
   */
  public function testShortcutBlockAccess() {
    // Creates a block instance and place in a region through api.
    $block = $this->drupalPlaceBlock('shortcuts');

    // Verify that users with the 'access shortcuts' permission can see the
    // shortcut block.
    $this->drupalLogin($this->shortcutUser);
    $this->drupalGet('');
    $this->assertBlockAppears($block);

    $this->drupalLogout();

    // Verify that users without the 'access shortcuts' permission can see the
    // shortcut block.
    $this->drupalLogin($this->drupalCreateUser(array()));
    $this->drupalGet('');
    $this->assertNoBlockAppears($block);
  }

}


text:
from __future__ import absolute_import, division, print_function

__metaclass__ = type

################################################################################
# Documentation
################################################################################

ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}

DOCUMENTATION = '''
---
module: gcp_compute_snapshot_info
description:
- Gather info for GCP Snapshot
short_description: Gather info for GCP Snapshot
version_added: '2.9'
author: Google Inc. (@googlecloudplatform)
requirements:
- python >= 2.6
- requests >= 2.18.4
- google-auth >= 1.3.0
options:
  filters:
    description:
    - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
    - Each additional filter in the list will act be added as an AND condition (filter1
      and filter2) .
    type: list
  project:
    description:
    - The Google Cloud Platform project to use.
    type: str
  auth_kind:
    description:
    - The type of credential used.
    type: str
    required: true
    choices:
    - application
    - machineaccount
    - serviceaccount
  service_account_contents:
    description:
    - The contents of a Service Account JSON file, either in a dictionary or as a
      JSON string that represents it.
    type: jsonarg
  service_account_file:
    description:
    - The path of a Service Account JSON file if serviceaccount is selected as type.
    type: path
  service_account_email:
    description:
    - An optional service account email address if machineaccount is selected and
      the user does not wish to use the default email.
    type: str
  scopes:
    description:
    - Array of scopes to be used
    type: list
  env_type:
    description:
    - Specifies which Ansible environment you're running this module within.
    - This should not be set unless you know what you're doing.
    - This only alters the User Agent string for any API requests.
    type: str
notes:
- for authentication, you can set service_account_file using the c(gcp_service_account_file)
  env variable.
- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS)
  env variable.
- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
  env variable.
- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
- Environment variables values will only be used if the playbook values are not set.
- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
'''

EXAMPLES = '''
- name: get info on a snapshot
  gcp_compute_snapshot_info:
    filters:
    - name = test_object
    project: test_project
    auth_kind: serviceaccount
    service_account_file: "/tmp/auth.pem"
'''

RETURN = '''
resources:
  description: List of resources
  returned: always
  type: complex
  contains:
    creationTimestamp:
      description:
      - Creation timestamp in RFC3339 text format.
      returned: success
      type: str
    id:
      description:
      - The unique identifier for the resource.
      returned: success
      type: int
    diskSizeGb:
      description:
      - Size of the snapshot, specified in GB.
      returned: success
      type: int
    name:
      description:
      - Name of the resource; provided by the client when the resource is created.
        The name must be 1-63 characters long, and comply with RFC1035. Specifically,
        the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
        which means the first character must be a lowercase letter, and all following
        characters must be a dash, lowercase letter, or digit, except the last character,
        which cannot be a dash.
      returned: success
      type: str
    description:
      description:
      - An optional description of this resource.
      returned: success
      type: str
    storageBytes:
      description:
      - A size of the the storage used by the snapshot. As snapshots share storage,
        this number is expected to change with snapshot creation/deletion.
      returned: success
      type: int
    licenses:
      description:
      - A list of public visible licenses that apply to this snapshot. This can be
        because the original image had licenses attached (such as a Windows image).
        snapshotEncryptionKey nested object Encrypts the snapshot using a customer-supplied
        encryption key.
      returned: success
      type: list
    labels:
      description:
      - Labels to apply to this Snapshot.
      returned: success
      type: dict
    labelFingerprint:
      description:
      - The fingerprint used for optimistic locking of this resource. Used internally
        during updates.
      returned: success
      type: str
    sourceDisk:
      description:
      - A reference to the disk used to create this snapshot.
      returned: success
      type: dict
    zone:
      description:
      - A reference to the zone where the disk is hosted.
      returned: success
      type: str
    snapshotEncryptionKey:
      description:
      - The customer-supplied encryption key of the snapshot. Required if the source
        snapshot is protected by a customer-supplied encryption key.
      returned: success
      type: complex
      contains:
        rawKey:
          description:
          - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
            base64 to either encrypt or decrypt this resource.
          returned: success
          type: str
        sha256:
          description:
          - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
            key that protects this resource.
          returned: success
          type: str
        kmsKeyName:
          description:
          - The name of the encryption key that is stored in Google Cloud KMS.
          returned: success
          type: str
    sourceDiskEncryptionKey:
      description:
      - The customer-supplied encryption key of the source snapshot. Required if the
        source snapshot is protected by a customer-supplied encryption key.
      returned: success
      type: complex
      contains:
        rawKey:
          description:
          - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
            base64 to either encrypt or decrypt this resource.
          returned: success
          type: str
        kmsKeyName:
          description:
          - The name of the encryption key that is stored in Google Cloud KMS.
          returned: success
          type: str
'''

################################################################################
# Imports
################################################################################
from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
import json

################################################################################
# Main
################################################################################

def main():
    module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))

    if not module.params['scopes']:
        module.params['scopes'] = ['https://www.googleapis.com/auth/compute']

    return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
    module.exit_json(**return_value)

def collection(module):
    return "https://www.googleapis.com/compute/v1/projects/{project}/global/snapshots".format(**module.params)

def fetch_list(module, link, query):
    auth = GcpSession(module, 'compute')
    return auth.list(link, return_if_object, array_name='items', params={'filter': query})

def query_options(filters):
    if not filters:
        return ''

    if len(filters) == 1:
        return filters[0]
    else:
        queries = []
        for f in filters:
            # For multiple queries, all queries should have ()
            if f[0] != '(' and f[-1] != ')':
                queries.append("(%s)" % ''.join(f))
            else:
                queries.append(f)

        return ' '.join(queries)

def return_if_object(module, response):
    # If not found, return nothing.
    if response.status_code == 404:
        return None

    # If no content, return nothing.
    if response.status_code == 204:
        return None

    try:
        module.raise_for_status(response)
        result = response.json()
    except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
        module.fail_json(msg="Invalid JSON response with error: %s" % inst)

    if navigate_hash(result, ['error', 'errors']):
        module.fail_json(msg=navigate_hash(result, ['error', 'errors']))

    return result

if __name__ == "__main__":
    main()


text:
package ru.st.selenium.applogic;

import java.util.ArrayList;
import java.util.List;

import ru.st.selenium.model.Film;

public interface FilmHelper {

	void create(Film film);
	void delete(Film film);
	ArrayList<Film> search(String title);
	boolean isFullFilmNameEquals(Film film);
	boolean isInputErrorYear();
	boolean isInputErrorName();
	int getSizeOfFilmList();
	boolean isEmptySearchResult(String string);
	void searchNull(String title);

	boolean isSearchResultAs(ArrayList<Film> filmList, String string);

}


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <title>Testing treeview</title>

    <link rel="stylesheet" href="js/themes/default/style.min.css" media="screen" title="no title" charset="utf-8">

      <input checked="checked" disabled type="checkbox" name="firstlevel" id="firstlevel">firstlevel
      <input checked="checked" disabled type="checkbox" name="secondlevel" id="secondlevel">secondlevel
      <input checked="checked" type="checkbox" name="thirdlevel" id="thirdlevel">thirdlevel
      <input checked="checked" type="checkbox" name="fourthlevel" id="fourthlevel">fourthlevel

      <button class="loadTree">Load tree</button>
      <input type="text" name="" id="filter">