text:
package com.microsoft.azure.management.deploymentmanager.v2019_11_01_preview.implementation;

import retrofit2.Retrofit;
import com.google.common.reflect.TypeToken;
import com.microsoft.azure.CloudException;
import com.microsoft.azure.management.deploymentmanager.v2019_11_01_preview.ServiceUnitsCreateOrUpdateHeaders;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceFuture;
import com.microsoft.rest.ServiceResponse;
import com.microsoft.rest.ServiceResponseWithHeaders;
import com.microsoft.rest.Validator;
import java.io.IOException;
import java.util.List;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.HTTP;
import retrofit2.http.Path;
import retrofit2.http.PUT;
import retrofit2.http.Query;
import retrofit2.Response;
import rx.functions.Func1;
import rx.Observable;

/**
 * An instance of this class provides access to all the operations defined
 * in ServiceUnits.
 */
public class ServiceUnitsInner {
    /** The Retrofit service to perform REST calls. */
    private ServiceUnitsService service;
    /** The service client containing this operation class. */
    private AzureDeploymentManagerImpl client;

    /**
     * Initializes an instance of ServiceUnitsInner.
     *
     * @param retrofit the Retrofit instance built from a Retrofit Builder.
     * @param client the instance of the service client containing this operation class.
     */
    public ServiceUnitsInner(Retrofit retrofit, AzureDeploymentManagerImpl client) {
        this.service = retrofit.create(ServiceUnitsService.class);
        this.client = client;
    }

    /**
     * The interface defining all the services for ServiceUnits to be
     * used by Retrofit to perform actually REST calls.
     */
    interface ServiceUnitsService {
        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.deploymentmanager.v2019_11_01_preview.ServiceUnits createOrUpdate" })
        @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}")
        Observable<Response<ResponseBody>> createOrUpdate(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("serviceTopologyName") String serviceTopologyName, @Path("serviceName") String serviceName, @Path("serviceUnitName") String serviceUnitName, @Query("api-version") String apiVersion, @Body ServiceUnitResourceInner serviceUnitInfo, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.deploymentmanager.v2019_11_01_preview.ServiceUnits beginCreateOrUpdate" })
        @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}")
        Observable<Response<ResponseBody>> beginCreateOrUpdate(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("serviceTopologyName") String serviceTopologyName, @Path("serviceName") String serviceName, @Path("serviceUnitName") String serviceUnitName, @Query("api-version") String apiVersion, @Body ServiceUnitResourceInner serviceUnitInfo, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.deploymentmanager.v2019_11_01_preview.ServiceUnits get" })
        @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}")
        Observable<Response<ResponseBody>> get(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("serviceTopologyName") String serviceTopologyName, @Path("serviceName") String serviceName, @Path("serviceUnitName") String serviceUnitName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.deploymentmanager.v2019_11_01_preview.ServiceUnits delete" })
        @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}", method = "DELETE", hasBody = true)
        Observable<Response<ResponseBody>> delete(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("serviceTopologyName") String serviceTopologyName, @Path("serviceName") String serviceName, @Path("serviceUnitName") String serviceUnitName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.deploymentmanager.v2019_11_01_preview.ServiceUnits list" })
        @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits")
        Observable<Response<ResponseBody>> list(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("serviceTopologyName") String serviceTopologyName, @Path("serviceName") String serviceName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

    }

    /**
     * Creates or updates a service unit under the service in the service topology.
     * This is an asynchronous operation and can be polled to completion using the operation resource returned by this operation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @param serviceUnitInfo The service unit resource object.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws CloudException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the ServiceUnitResourceInner object if successful.
     */
    public ServiceUnitResourceInner createOrUpdate(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName, ServiceUnitResourceInner serviceUnitInfo) {
        return createOrUpdateWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName, serviceUnitName, serviceUnitInfo).toBlocking().last().body();
    }

    /**
     * Creates or updates a service unit under the service in the service topology.
     * This is an asynchronous operation and can be polled to completion using the operation resource returned by this operation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @param serviceUnitInfo The service unit resource object.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<ServiceUnitResourceInner> createOrUpdateAsync(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName, ServiceUnitResourceInner serviceUnitInfo, final ServiceCallback<ServiceUnitResourceInner> serviceCallback) {
        return ServiceFuture.fromHeaderResponse(createOrUpdateWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName, serviceUnitName, serviceUnitInfo), serviceCallback);
    }

    /**
     * Creates or updates a service unit under the service in the service topology.
     * This is an asynchronous operation and can be polled to completion using the operation resource returned by this operation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @param serviceUnitInfo The service unit resource object.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable for the request
     */
    public Observable<ServiceUnitResourceInner> createOrUpdateAsync(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName, ServiceUnitResourceInner serviceUnitInfo) {
        return createOrUpdateWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName, serviceUnitName, serviceUnitInfo).map(new Func1<ServiceResponseWithHeaders<ServiceUnitResourceInner, ServiceUnitsCreateOrUpdateHeaders>, ServiceUnitResourceInner>() {
            @Override
            public ServiceUnitResourceInner call(ServiceResponseWithHeaders<ServiceUnitResourceInner, ServiceUnitsCreateOrUpdateHeaders> response) {
                return response.body();
            }
        });
    }

    /**
     * Creates or updates a service unit under the service in the service topology.
     * This is an asynchronous operation and can be polled to completion using the operation resource returned by this operation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @param serviceUnitInfo The service unit resource object.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable for the request
     */
    public Observable<ServiceResponseWithHeaders<ServiceUnitResourceInner, ServiceUnitsCreateOrUpdateHeaders>> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName, ServiceUnitResourceInner serviceUnitInfo) {
        if (this.client.subscriptionId() == null) {
            throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
        }
        if (resourceGroupName == null) {
            throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
        }
        if (serviceTopologyName == null) {
            throw new IllegalArgumentException("Parameter serviceTopologyName is required and cannot be null.");
        }
        if (serviceName == null) {
            throw new IllegalArgumentException("Parameter serviceName is required and cannot be null.");
        }
        if (serviceUnitName == null) {
            throw new IllegalArgumentException("Parameter serviceUnitName is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        if (serviceUnitInfo == null) {
            throw new IllegalArgumentException("Parameter serviceUnitInfo is required and cannot be null.");
        }
        Validator.validate(serviceUnitInfo);
        Observable<Response<ResponseBody>> observable = service.createOrUpdate(this.client.subscriptionId(), resourceGroupName, serviceTopologyName, serviceName, serviceUnitName, this.client.apiVersion(), serviceUnitInfo, this.client.acceptLanguage(), this.client.userAgent());
        return client.getAzureClient().getPutOrPatchResultWithHeadersAsync(observable, new TypeToken<ServiceUnitResourceInner>() { }.getType(), ServiceUnitsCreateOrUpdateHeaders.class);
    }

    /**
     * Creates or updates a service unit under the service in the service topology.
     * This is an asynchronous operation and can be polled to completion using the operation resource returned by this operation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @param serviceUnitInfo The service unit resource object.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws CloudException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the ServiceUnitResourceInner object if successful.
     */
    public ServiceUnitResourceInner beginCreateOrUpdate(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName, ServiceUnitResourceInner serviceUnitInfo) {
        return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName, serviceUnitName, serviceUnitInfo).toBlocking().single().body();
    }

    /**
     * Creates or updates a service unit under the service in the service topology.
     * This is an asynchronous operation and can be polled to completion using the operation resource returned by this operation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @param serviceUnitInfo The service unit resource object.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<ServiceUnitResourceInner> beginCreateOrUpdateAsync(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName, ServiceUnitResourceInner serviceUnitInfo, final ServiceCallback<ServiceUnitResourceInner> serviceCallback) {
        return ServiceFuture.fromHeaderResponse(beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName, serviceUnitName, serviceUnitInfo), serviceCallback);
    }

    /**
     * Creates or updates a service unit under the service in the service topology.
     * This is an asynchronous operation and can be polled to completion using the operation resource returned by this operation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @param serviceUnitInfo The service unit resource object.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the ServiceUnitResourceInner object
     */
    public Observable<ServiceUnitResourceInner> beginCreateOrUpdateAsync(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName, ServiceUnitResourceInner serviceUnitInfo) {
        return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName, serviceUnitName, serviceUnitInfo).map(new Func1<ServiceResponseWithHeaders<ServiceUnitResourceInner, ServiceUnitsCreateOrUpdateHeaders>, ServiceUnitResourceInner>() {
            @Override
            public ServiceUnitResourceInner call(ServiceResponseWithHeaders<ServiceUnitResourceInner, ServiceUnitsCreateOrUpdateHeaders> response) {
                return response.body();
            }
        });
    }

    /**
     * Creates or updates a service unit under the service in the service topology.
     * This is an asynchronous operation and can be polled to completion using the operation resource returned by this operation.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @param serviceUnitInfo The service unit resource object.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the ServiceUnitResourceInner object
     */
    public Observable<ServiceResponseWithHeaders<ServiceUnitResourceInner, ServiceUnitsCreateOrUpdateHeaders>> beginCreateOrUpdateWithServiceResponseAsync(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName, ServiceUnitResourceInner serviceUnitInfo) {
        if (this.client.subscriptionId() == null) {
            throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
        }
        if (resourceGroupName == null) {
            throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
        }
        if (serviceTopologyName == null) {
            throw new IllegalArgumentException("Parameter serviceTopologyName is required and cannot be null.");
        }
        if (serviceName == null) {
            throw new IllegalArgumentException("Parameter serviceName is required and cannot be null.");
        }
        if (serviceUnitName == null) {
            throw new IllegalArgumentException("Parameter serviceUnitName is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        if (serviceUnitInfo == null) {
            throw new IllegalArgumentException("Parameter serviceUnitInfo is required and cannot be null.");
        }
        Validator.validate(serviceUnitInfo);
        return service.beginCreateOrUpdate(this.client.subscriptionId(), resourceGroupName, serviceTopologyName, serviceName, serviceUnitName, this.client.apiVersion(), serviceUnitInfo, this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponseWithHeaders<ServiceUnitResourceInner, ServiceUnitsCreateOrUpdateHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<ServiceUnitResourceInner, ServiceUnitsCreateOrUpdateHeaders>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponseWithHeaders<ServiceUnitResourceInner, ServiceUnitsCreateOrUpdateHeaders> clientResponse = beginCreateOrUpdateDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponseWithHeaders<ServiceUnitResourceInner, ServiceUnitsCreateOrUpdateHeaders> beginCreateOrUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().<ServiceUnitResourceInner, CloudException>newInstance(this.client.serializerAdapter())
                .register(201, new TypeToken<ServiceUnitResourceInner>() { }.getType())
                .registerError(CloudException.class)
                .buildWithHeaders(response, ServiceUnitsCreateOrUpdateHeaders.class);
    }

    /**
     * Gets the service unit.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws CloudException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the ServiceUnitResourceInner object if successful.
     */
    public ServiceUnitResourceInner get(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName) {
        return getWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName, serviceUnitName).toBlocking().single().body();
    }

    /**
     * Gets the service unit.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<ServiceUnitResourceInner> getAsync(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName, final ServiceCallback<ServiceUnitResourceInner> serviceCallback) {
        return ServiceFuture.fromResponse(getWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName, serviceUnitName), serviceCallback);
    }

    /**
     * Gets the service unit.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the ServiceUnitResourceInner object
     */
    public Observable<ServiceUnitResourceInner> getAsync(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName) {
        return getWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName, serviceUnitName).map(new Func1<ServiceResponse<ServiceUnitResourceInner>, ServiceUnitResourceInner>() {
            @Override
            public ServiceUnitResourceInner call(ServiceResponse<ServiceUnitResourceInner> response) {
                return response.body();
            }
        });
    }

    /**
     * Gets the service unit.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the ServiceUnitResourceInner object
     */
    public Observable<ServiceResponse<ServiceUnitResourceInner>> getWithServiceResponseAsync(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName) {
        if (this.client.subscriptionId() == null) {
            throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
        }
        if (resourceGroupName == null) {
            throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
        }
        if (serviceTopologyName == null) {
            throw new IllegalArgumentException("Parameter serviceTopologyName is required and cannot be null.");
        }
        if (serviceName == null) {
            throw new IllegalArgumentException("Parameter serviceName is required and cannot be null.");
        }
        if (serviceUnitName == null) {
            throw new IllegalArgumentException("Parameter serviceUnitName is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        return service.get(this.client.subscriptionId(), resourceGroupName, serviceTopologyName, serviceName, serviceUnitName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ServiceUnitResourceInner>>>() {
                @Override
                public Observable<ServiceResponse<ServiceUnitResourceInner>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<ServiceUnitResourceInner> clientResponse = getDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<ServiceUnitResourceInner> getDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().<ServiceUnitResourceInner, CloudException>newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken<ServiceUnitResourceInner>() { }.getType())
                .registerError(CloudException.class)
                .build(response);
    }

    /**
     * Deletes the service unit.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws CloudException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     */
    public void delete(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName) {
        deleteWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName, serviceUnitName).toBlocking().single().body();
    }

    /**
     * Deletes the service unit.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<Void> deleteAsync(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName, final ServiceCallback<Void> serviceCallback) {
        return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName, serviceUnitName), serviceCallback);
    }

    /**
     * Deletes the service unit.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable<Void> deleteAsync(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName) {
        return deleteWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName, serviceUnitName).map(new Func1<ServiceResponse<Void>, Void>() {
            @Override
            public Void call(ServiceResponse<Void> response) {
                return response.body();
            }
        });
    }

    /**
     * Deletes the service unit.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceUnitName The name of the service unit resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable<ServiceResponse<Void>> deleteWithServiceResponseAsync(String resourceGroupName, String serviceTopologyName, String serviceName, String serviceUnitName) {
        if (this.client.subscriptionId() == null) {
            throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
        }
        if (resourceGroupName == null) {
            throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
        }
        if (serviceTopologyName == null) {
            throw new IllegalArgumentException("Parameter serviceTopologyName is required and cannot be null.");
        }
        if (serviceName == null) {
            throw new IllegalArgumentException("Parameter serviceName is required and cannot be null.");
        }
        if (serviceUnitName == null) {
            throw new IllegalArgumentException("Parameter serviceUnitName is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        return service.delete(this.client.subscriptionId(), resourceGroupName, serviceTopologyName, serviceName, serviceUnitName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
                @Override
                public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<Void> clientResponse = deleteDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<Void> deleteDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().<Void, CloudException>newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken<Void>() { }.getType())
                .register(204, new TypeToken<Void>() { }.getType())
                .registerError(CloudException.class)
                .build(response);
    }

    /**
     * Lists the service units under a service in the service topology.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws CloudException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the List<ServiceUnitResourceInner> object if successful.
     */
    public List<ServiceUnitResourceInner> list(String resourceGroupName, String serviceTopologyName, String serviceName) {
        return listWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName).toBlocking().single().body();
    }

    /**
     * Lists the service units under a service in the service topology.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<List<ServiceUnitResourceInner>> listAsync(String resourceGroupName, String serviceTopologyName, String serviceName, final ServiceCallback<List<ServiceUnitResourceInner>> serviceCallback) {
        return ServiceFuture.fromResponse(listWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName), serviceCallback);
    }

    /**
     * Lists the service units under a service in the service topology.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the List<ServiceUnitResourceInner> object
     */
    public Observable<List<ServiceUnitResourceInner>> listAsync(String resourceGroupName, String serviceTopologyName, String serviceName) {
        return listWithServiceResponseAsync(resourceGroupName, serviceTopologyName, serviceName).map(new Func1<ServiceResponse<List<ServiceUnitResourceInner>>, List<ServiceUnitResourceInner>>() {
            @Override
            public List<ServiceUnitResourceInner> call(ServiceResponse<List<ServiceUnitResourceInner>> response) {
                return response.body();
            }
        });
    }

    /**
     * Lists the service units under a service in the service topology.
     *
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceTopologyName The name of the service topology .
     * @param serviceName The name of the service resource.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the List<ServiceUnitResourceInner> object
     */
    public Observable<ServiceResponse<List<ServiceUnitResourceInner>>> listWithServiceResponseAsync(String resourceGroupName, String serviceTopologyName, String serviceName) {
        if (this.client.subscriptionId() == null) {
            throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
        }
        if (resourceGroupName == null) {
            throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
        }
        if (serviceTopologyName == null) {
            throw new IllegalArgumentException("Parameter serviceTopologyName is required and cannot be null.");
        }
        if (serviceName == null) {
            throw new IllegalArgumentException("Parameter serviceName is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        return service.list(this.client.subscriptionId(), resourceGroupName, serviceTopologyName, serviceName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<ServiceUnitResourceInner>>>>() {
                @Override
                public Observable<ServiceResponse<List<ServiceUnitResourceInner>>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<List<ServiceUnitResourceInner>> clientResponse = listDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<List<ServiceUnitResourceInner>> listDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().<List<ServiceUnitResourceInner>, CloudException>newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken<List<ServiceUnitResourceInner>>() { }.getType())
                .registerError(CloudException.class)
                .build(response);
    }

}


text:
<resources>
    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>
    <dimen name="fab_margin">16dp</dimen>

    <dimen name="dialpad_row_height">54dp</dimen>
    <dimen name="dialpad_icon_height">32dp</dimen>
    <dimen name="dialpad_icon_width">32dp</dimen>
    <dimen name="dialpad_margin_right">12dp</dimen>
    <dimen name="dialpad_margin_left">12dp</dimen>
    <dimen name="bottom_tab_height">54dp</dimen>
    <dimen name="list_item_height">54dp</dimen>
    <dimen name="btn_height">54dp</dimen>
    <dimen name="padding">4dp</dimen>
    <dimen name="padding_left">4dp</dimen>
    <dimen name="padding_right">4dp</dimen>
    <dimen name="padding_top">4dp</dimen>
    <dimen name="padding_bottom">4dp</dimen>
    <dimen name="margin">4dp</dimen>
    <dimen name="margin_left">4dp</dimen>
    <dimen name="margin_right">4dp</dimen>
    <dimen name="margin_top">4dp</dimen>
    <dimen name="margin_bottom">4dp</dimen>
    <dimen name="index_view_width">48dp</dimen>
    <dimen name="index_view_height">192dp</dimen>
    <dimen name="index_key_width">36dp</dimen>
    <dimen name="index_key_height">36dp</dimen>
    <dimen name="index_value_width">36dp</dimen>
    <dimen name="index_value_height">36dp</dimen>
    <dimen name="index_key_text_size">24sp</dimen>
    <dimen name="index_value_text_size">24sp</dimen>
    <dimen name="division_line_height">1dp</dimen>
    <dimen name="icon_width">36dp</dimen>
    <dimen name="icon_height">36dp</dimen>
    <dimen name="navigation_bar_height">54dp</dimen>
    <dimen name="corner_radius">3dp</dimen>
</resources>

redpajama_set_name: RedPajamaGithub


text:
PYTHONIC_NS_BEGIN

namespace numpy
{
  namespace wrapper
  {
    template <class T0, class T1>
    auto remainder(T0 const &x, T1 const &y)
        -> decltype(x - y * xsimd::floor(x / y))
    {
      return x - y * xsimd::floor(x / y);
    }
  }

#define NUMPY_NARY_FUNC_NAME remainder
#define NUMPY_NARY_FUNC_SYM wrapper::remainder
#include "pythonic/include/types/numpy_nary_expr.hpp"
}
PYTHONIC_NS_END

#endif


text:
<?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorSpatialGizmoPlugin" inherits="Resource" category="Core" version="3.2">
	<brief_description>
		Used by the editor to define Spatial gizmo types.
	</brief_description>
	<description>
		EditorSpatialGizmoPlugin allows you to define a new type of Gizmo. There are two main ways to do so: extending [EditorSpatialGizmoPlugin] for the simpler gizmos, or creating a new [EditorSpatialGizmo] type. See the tutorial in the documentation for more info.
	</description>
	<tutorials>
		<link>https://docs.godotengine.org/en/latest/tutorials/plugins/editor/spatial_gizmos.html</link>
	</tutorials>
	<methods>
		<method name="add_material">
			<return type="void">
			</return>
			<argument index="0" name="name" type="String">
			</argument>
			<argument index="1" name="material" type="SpatialMaterial">
			</argument>
			<description>
				Adds a new material to the internal material list for the plugin. It can then be accessed with [method get_material]. Should not be overridden.
			</description>
		</method>
		<method name="can_be_hidden" qualifiers="virtual">
			<return type="bool">
			</return>
			<description>
				Override this method to define whether the gizmo can be hidden or not. Returns [code]true[/code] if not overridden.
			</description>
		</method>
		<method name="commit_handle" qualifiers="virtual">
			<return type="void">
			</return>
			<argument index="0" name="gizmo" type="EditorSpatialGizmo">
			</argument>
			<argument index="1" name="index" type="int">
			</argument>
			<argument index="2" name="restore" type="Variant">
			</argument>
			<argument index="3" name="cancel" type="bool" default="false">
			</argument>
			<description>
				Override this method to commit gizmo handles. Called for this plugin's active gizmos.
			</description>
		</method>
		<method name="create_gizmo" qualifiers="virtual">
			<return type="EditorSpatialGizmo">
			</return>
			<argument index="0" name="spatial" type="Spatial">
			</argument>
			<description>
				Override this method to return a custom [EditorSpatialGizmo] for the spatial nodes of your choice, return [code]null[/code] for the rest of nodes. (See also [method has_gizmo])
			</description>
		</method>
		<method name="create_handle_material">
			<return type="void">
			</return>
			<argument index="0" name="name" type="String">
			</argument>
			<argument index="1" name="billboard" type="bool" default="false">
			</argument>
			<description>
				Creates a handle material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorSpatialGizmo.add_handles]. Should not be overridden.
			</description>
		</method>
		<method name="create_icon_material">
			<return type="void">
			</return>
			<argument index="0" name="name" type="String">
			</argument>
			<argument index="1" name="texture" type="Texture">
			</argument>
			<argument index="2" name="on_top" type="bool" default="false">
			</argument>
			<argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
			</argument>
			<description>
				Creates an icon material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorSpatialGizmo.add_unscaled_billboard]. Should not be overridden.
			</description>
		</method>
		<method name="create_material">
			<return type="void">
			</return>
			<argument index="0" name="name" type="String">
			</argument>
			<argument index="1" name="color" type="Color">
			</argument>
			<argument index="2" name="billboard" type="bool" default="false">
			</argument>
			<argument index="3" name="on_top" type="bool" default="false">
			</argument>
			<argument index="4" name="use_vertex_color" type="bool" default="false">
			</argument>
			<description>
				Creates an unshaded material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorSpatialGizmo.add_mesh] and [method EditorSpatialGizmo.add_lines]. Should not be overridden.
			</description>
		</method>
		<method name="get_handle_name" qualifiers="virtual">
			<return type="String">
			</return>
			<argument index="0" name="gizmo" type="EditorSpatialGizmo">
			</argument>
			<argument index="1" name="index" type="int">
			</argument>
			<description>
				Override this method to provide gizmo's handle names. Called for this plugin's active gizmos.
			</description>
		</method>
		<method name="get_handle_value" qualifiers="virtual">
			<return type="Variant">
			</return>
			<argument index="0" name="gizmo" type="EditorSpatialGizmo">
			</argument>
			<argument index="1" name="index" type="int">
			</argument>
			<description>
				Gets actual value of a handle from gizmo. Called for this plugin's active gizmos.
			</description>
		</method>
		<method name="get_material">
			<return type="SpatialMaterial">
			</return>
			<argument index="0" name="name" type="String">
			</argument>
			<argument index="1" name="gizmo" type="EditorSpatialGizmo">
			</argument>
			<description>
				Gets material from the internal list of materials. If an [EditorSpatialGizmo] is provided, it will try to get the corresponding variant (selected and/or editable).
			</description>
		</method>
		<method name="get_name" qualifiers="virtual">
			<return type="String">
			</return>
			<description>
				Override this method to provide the name that will appear in the gizmo visibility menu.
			</description>
		</method>
		<method name="get_priority" qualifiers="virtual">
			<return type="String">
			</return>
			<description>
			</description>
		</method>
		<method name="has_gizmo" qualifiers="virtual">
			<return type="bool">
			</return>
			<argument index="0" name="spatial" type="Spatial">
			</argument>
			<description>
				Override this method to define which Spatial nodes have a gizmo from this plugin. Whenever a [Spatial] node is added to a scene this method is called, if it returns [code]true[/code] the node gets a generic [EditorSpatialGizmo] assigned and is added to this plugin's list of active gizmos.
			</description>
		</method>
		<method name="is_handle_highlighted" qualifiers="virtual">
			<return type="bool">
			</return>
			<argument index="0" name="gizmo" type="EditorSpatialGizmo">
			</argument>
			<argument index="1" name="index" type="int">
			</argument>
			<description>
				Gets whether a handle is highlighted or not. Called for this plugin's active gizmos.
			</description>
		</method>
		<method name="is_selectable_when_hidden" qualifiers="virtual">
			<return type="bool">
			</return>
			<description>
				Override this method to define whether Spatial with this gizmo should be selecteble even when the gizmo is hidden.
			</description>
		</method>
		<method name="redraw" qualifiers="virtual">
			<return type="void">
			</return>
			<argument index="0" name="gizmo" type="EditorSpatialGizmo">
			</argument>
			<description>
				Callback to redraw the provided gizmo. Called for this plugin's active gizmos.
			</description>
		</method>
		<method name="set_handle" qualifiers="virtual">
			<return type="void">
			</return>
			<argument index="0" name="gizmo" type="EditorSpatialGizmo">
			</argument>
			<argument index="1" name="index" type="int">
			</argument>
			<argument index="2" name="camera" type="Camera">
			</argument>
			<argument index="3" name="point" type="Vector2">
			</argument>
			<description>
				Update the value of a handle after it has been updated. Called for this plugin's active gizmos.
			</description>
		</method>
	</methods>
	<constants>
	</constants>
</class>


text:
import json
import time

from mycroft.filesystem import FileSystemAccess

class DeviceIdentity(object):
    def __init__(self, **kwargs):
        self.uuid = kwargs.get("uuid", "")
        self.access = kwargs.get("access", "")
        self.refresh = kwargs.get("refresh", "")
        self.expires_at = kwargs.get("expires_at", 0)

    def is_expired(self):
        return self.refresh and self.expires_at <= time.time()

class IdentityManager(object):
    __identity = None

    @staticmethod
    def load():
        try:
            with FileSystemAccess('identity').open('identity2.json', 'r') as f:
                IdentityManager.__identity = DeviceIdentity(**json.load(f))
        except:
            IdentityManager.__identity = DeviceIdentity()
        return IdentityManager.__identity

    @staticmethod
    def save(login=None):
        if login:
            IdentityManager.update(login)
        with FileSystemAccess('identity').open('identity2.json', 'w') as f:
            json.dump(IdentityManager.__identity.__dict__, f)

    @staticmethod
    def update(login={}):
        expiration = login.get("expiration", 0)
        IdentityManager.__identity.uuid = login.get("uuid", "")
        IdentityManager.__identity.access = login.get("accessToken", "")
        IdentityManager.__identity.refresh = login.get("refreshToken", "")
        IdentityManager.__identity.expires_at = time.time() + expiration

    @staticmethod
    def get():
        if not IdentityManager.__identity:
            IdentityManager.load()
        return IdentityManager.__identity


text:
package com.google.android.enterprise.connectedapps.processor;

import static com.google.android.enterprise.connectedapps.processor.TestUtilities.NOTES_PACKAGE;
import static com.google.android.enterprise.connectedapps.processor.TestUtilities.annotatedNotesCrossProfileType;
import static com.google.android.enterprise.connectedapps.processor.TestUtilities.annotatedNotesProvider;
import static com.google.testing.compile.CompilationSubject.assertThat;
import static com.google.testing.compile.Compiler.javac;

import com.google.android.enterprise.connectedapps.processor.annotationdiscovery.AnnotationFinder;
import com.google.android.enterprise.connectedapps.processor.annotationdiscovery.AnnotationPrinter;
import com.google.android.enterprise.connectedapps.processor.annotationdiscovery.AnnotationStrings;
import com.google.testing.compile.Compilation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
public class CrossUserInterfaceTest {

  private final AnnotationPrinter annotationPrinter;

  public CrossUserInterfaceTest(AnnotationPrinter annotationPrinter) {
    this.annotationPrinter = annotationPrinter;
  }

  @Parameters(name = "{0}")
  public static Iterable<AnnotationStrings> getAnnotationPrinters() {
    return AnnotationFinder.annotationStrings();
  }

  @Test
  public void compile_generatesCurrentMethod() {
    Compilation compilation =
        javac()
            .withProcessors(new Processor())
            .compile(
                annotatedNotesProvider(annotationPrinter),
                annotatedNotesCrossProfileType(annotationPrinter));

    assertThat(compilation)
        .generatedSourceFile(NOTES_PACKAGE + ".UserNotesType")
        .contentsAsUtf8String()
        .contains("NotesType_SingleSender current()");
  }

  @Test
  public void compile_generatesUserMethod() {
    Compilation compilation =
        javac()
            .withProcessors(new Processor())
            .compile(
                annotatedNotesProvider(annotationPrinter),
                annotatedNotesCrossProfileType(annotationPrinter));

    assertThat(compilation)
        .generatedSourceFile(NOTES_PACKAGE + ".UserNotesType")
        .contentsAsUtf8String()
        .contains("NotesType_SingleSenderCanThrow user(UserHandle userHandle)");
  }

  @Test
  public void compile_generatesDefaultImplementation() {
    Compilation compilation =
        javac()
            .withProcessors(new Processor())
            .compile(
                annotatedNotesProvider(annotationPrinter),
                annotatedNotesCrossProfileType(annotationPrinter));

    assertThat(compilation)
        .generatedSourceFile(NOTES_PACKAGE + ".DefaultUserNotesType")
        .contentsAsUtf8String()
        .contains("class DefaultUserNotesType implements UserNotesType");
  }
}


text:
{-# LANGUAGE OverloadedStrings #-}
-- | This module provides styles for borders as used in terminal
-- applications. Your mileage may vary on some of the fancier styles
-- due to varying support for some border characters in the fonts your
-- users may be using. Because of this, we provide the 'ascii' style in
-- addition to the Unicode styles. The 'unicode' style is also a safe
-- bet.
--
-- To use these in your widgets, see
-- 'Brick.Widgets.Core.withBorderStyle'. By default, widgets rendered
-- without a specified border style use 'unicode' via the 'Default'
-- instance provided by 'BorderStyle'.
module Brick.Widgets.Border.Style
  ( BorderStyle(..)
  , borderStyleFromChar
  , ascii
  , unicode
  , unicodeBold
  , unicodeRounded
  )
where

import Data.Default

-- | A border style for use in any widget that needs to render borders
-- in a consistent style.
data BorderStyle =
    BorderStyle { bsCornerTL :: Char
                -- ^ Top-left corner character
                , bsCornerTR :: Char
                -- ^ Top-right corner character
                , bsCornerBR :: Char
                -- ^ Bottom-right corner character
                , bsCornerBL :: Char
                -- ^ Bottom-left corner character
                , bsIntersectFull :: Char
                -- ^ Full intersection (cross)
                , bsIntersectL :: Char
                -- ^ Left side of a horizontal border intersecting a vertical one
                , bsIntersectR :: Char
                -- ^ Right side of a horizontal border intersecting a vertical one
                , bsIntersectT :: Char
                -- ^ Top of a vertical border intersecting a horizontal one
                , bsIntersectB :: Char
                -- ^ Bottom of a vertical border intersecting a horizontal one
                , bsHorizontal :: Char
                -- ^ Horizontal border character
                , bsVertical :: Char
                -- ^ Vertical border character
                }
                deriving (Show, Read)

instance Default BorderStyle where
    def = unicode

-- | Make a border style using the specified character everywhere.
borderStyleFromChar :: Char -> BorderStyle
borderStyleFromChar c =
    BorderStyle c c c c c c c c c c c

-- |An ASCII border style which will work in any terminal.
ascii :: BorderStyle
ascii =
    BorderStyle { bsCornerTL = '+'
                , bsCornerTR = '+'
                , bsCornerBR = '+'
                , bsCornerBL = '+'
                , bsIntersectFull = '+'
                , bsIntersectL = '+'
                , bsIntersectR = '+'
                , bsIntersectT = '+'
                , bsIntersectB = '+'
                , bsHorizontal = '-'
                , bsVertical = '|'
                }

-- |A unicode border style with real corner and intersection characters.
unicode :: BorderStyle
unicode =
    BorderStyle { bsCornerTL = '┌'
                , bsCornerTR = '┐'
                , bsCornerBR = '┘'
                , bsCornerBL = '└'
                , bsIntersectFull = '┼'
                , bsIntersectL = '├'
                , bsIntersectR = '┤'
                , bsIntersectT = '┬'
                , bsIntersectB = '┴'
                , bsHorizontal = '─'
                , bsVertical = '│'
                }

-- |A unicode border style in a bold typeface.
unicodeBold :: BorderStyle
unicodeBold =
    BorderStyle { bsCornerTL = '┏'
                , bsCornerTR = '┓'
                , bsCornerBR = '┛'
                , bsCornerBL = '┗'
                , bsIntersectFull = '╋'
                , bsIntersectL = '┣'
                , bsIntersectR = '┫'
                , bsIntersectT = '┳'
                , bsIntersectB = '┻'
                , bsHorizontal = '━'
                , bsVertical = '┃'
                }

-- |A unicode border style with rounded corners.
unicodeRounded :: BorderStyle
unicodeRounded =
    BorderStyle { bsCornerTL = '╭'
                , bsCornerTR = '╮'
                , bsCornerBR = '╯'
                , bsCornerBL = '╰'
                , bsIntersectFull = '┼'
                , bsIntersectL = '├'
                , bsIntersectR = '┤'
                , bsIntersectT = '┬'
                , bsIntersectB = '┴'
                , bsHorizontal = '─'
                , bsVertical = '│'
                }


text:
require 'marks/engine'
require 'marks/marker'
require 'marks/markable'
require 'marks/relation_extension'

module Marks
end

# load Rails/Railtie
begin
  require 'rails'
rescue LoadError
  #do nothing
end

ActiveSupport.on_load(:active_record) do
  ActiveRecord::Relation.send(:include, Marks::RelationExtension)
end


text:
#include "exodusII.h"     // for ex_err, etc
#include "exodusII_int.h" // for EX_FATAL, etc
#include "netcdf.h"       // for NC_NOERR, nc_inq_dimid, etc
#include <stddef.h>       // for size_t
#include <stdio.h>

/*!

The function ex_put_coord_names() writes the names of the coordinate
arrays to the database. Memory must be allocated for the character
strings before this function is invoked.

In case of an error, ex_put_coord_names() returns a negative number; a
warning will return a positive number.  Possible causes of errors
include:
  -  data file not properly opened with call to ex_create() or ex_open()
  -  data file opened for read only.
  -  data file not initialized properly with call to ex_put_init().

\param[in] exoid          exodus file ID returned from a previous call to
ex_create() or ex_open().
\param[in] coord_names    Array containing num_dim names of length \p
...max_name_length...                         of the nodal coordinate arrays.

The following coding will write the coordinate names to an
open exodus file :

~~~{.c}
int error, exoid;

char *coord_names[3];
coord_names[0] = "xcoor";
coord_names[1] = "ycoor";
coord_names[2] = "zcoor";

error = ex_put_coord_names (exoid, coord_names);
~~~

 */

int ex_put_coord_names(int exoid, char *coord_names[])
{
  int    status;
  int    ndimdim, varid;
  size_t num_dim;
  char   errmsg[MAX_ERR_LENGTH];

  EX_FUNC_ENTER();
  ex_check_valid_file_id(exoid, __func__);

  if ((status = nc_inq_dimid(exoid, DIM_NUM_DIM, &ndimdim)) != NC_NOERR) {
    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate number of dimensions in file id %d",
             exoid);
    ex_err(__func__, errmsg, status);
    EX_FUNC_LEAVE(EX_FATAL);
  }

  if ((status = nc_inq_dimlen(exoid, ndimdim, &num_dim)) != NC_NOERR) {
    snprintf(errmsg, MAX_ERR_LENGTH,
             "ERROR: inquire failed to get number of dimensions in file id %d", exoid);
    ex_err(__func__, errmsg, status);
    EX_FUNC_LEAVE(EX_FATAL);
  }

  if ((status = nc_inq_varid(exoid, VAR_NAME_COOR, &varid)) == -1) {
    snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to locate coordinate names in file id %d",
             exoid);
    ex_err(__func__, errmsg, status);
    EX_FUNC_LEAVE(EX_FATAL);
  }

  /* write out coordinate names */
  status = ex_put_names_internal(exoid, varid, num_dim, coord_names, EX_COORDINATE, "", __func__);

  EX_FUNC_LEAVE(status);
}


text:
using Ini;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SideNote
{
    public partial class SettingsWindow
    {
        // Pathes & files
        public string SaveFolder, SaveFolderTmp, AppdataDir;
        public string[] SplittedSaveFolder;
        public string AppName = "Notes";
        public string SaveFile = "Settings.ini";
        //public string CompleteSavePath;

        // Settings
        List<string> ThemeChoices;// = { "Dark Orange", "Light" };

        // Objects
        FontConverter FontConverter = new FontConverter();

        // Events
        public static readonly RoutedEvent HideEvent = EventManager.RegisterRoutedEvent(
        "DoHide", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(SettingsWindow));
        public event RoutedEventHandler DoHide
        {
            add { AddHandler(HideEvent, value); }
            remove { RemoveHandler(HideEvent, value); }
        }

        public static readonly RoutedEvent ShowEvent = EventManager.RegisterRoutedEvent(
        "DoShow", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(SettingsWindow));
        public event RoutedEventHandler DoShow
        {
            add { AddHandler(ShowEvent, value); }
            remove { RemoveHandler(ShowEvent, value); }
        }

        public SettingsWindow()
        {
            InitializeComponent();
            this.AllowsTransparency = true;

            //this.WindowState = System.Windows.WindowState.Minimized;

            ThemeChoices = readThemeChoices();

            // Set up settings
            FontFamilyDrop.ItemsSource = Fonts.SystemFontFamilies;  // Dropdown Liste mit Werten füllen
            AppThemeDrop.ItemsSource = ThemeChoices;

            loadSettings();

            // Set up listeners
            SettingsCloseButton.Click += SettingsCloseButton_Click;
            FontSizeSlider.ValueChanged += FontSizeSlider_ValueChanged;
            FontFamilyDrop.SelectionChanged += FontFamilyDrop_SelectionChanged;
            AppThemeDrop.SelectionChanged += AppThemeDrop_SelectionChanged;
        }

        // Helper functions
        private List<string> readThemeChoices()
        {
            var input = MainWindow.GetResourcesUnder("Themes");
            var output = new List<string>();

            for (int i = 0; i < input.Length; i++)
            {
                var no_extension = System.IO.Path.GetFileNameWithoutExtension(input[i]);
                var escaped = Uri.UnescapeDataString(no_extension);
                var titlecase = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(escaped);
                output.Add(titlecase);
            }

            return output;
        }

        private void updateTextBox()
        {
            foreach (Window window in Application.Current.Windows)
            {
                if (window.GetType() == typeof(MainWindow))
                {
                    (window as MainWindow).myTextBox.FontFamily = new System.Windows.Media.FontFamily(StorageHolder.readSetting(MainWindow.Key_FontFamily));
                    (window as MainWindow).myTextBox.FontSize = Double.Parse(StorageHolder.readSetting(MainWindow.Key_FontSize));
                }
            }
        }

        private void loadSettings()
        {
            System.Windows.Media.FontFamily[] FontFamilyArray = Fonts.SystemFontFamilies.ToArray();
            for (int i = 0; i < FontFamilyArray.GetLength(0); i++)
            {
                if (FontFamilyArray[i].ToString() == StorageHolder.readSetting(MainWindow.Key_FontFamily))
                {
                    FontFamilyDrop.SelectedIndex = i;
                }
            }

            FontSizeSlider.Value = Double.Parse(StorageHolder.readSetting(MainWindow.Key_FontSize));

            for (int i = 0; i < ThemeChoices.Count; i++)
            {
                if (ThemeChoices[i].ToString() == StorageHolder.readSetting(MainWindow.Key_AppTheme))
                {
                    AppThemeDrop.SelectedIndex = i;
                }
            }
        }

        // Events
        private void FontFamilyDrop_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            StorageHolder.writeSetting(MainWindow.Key_FontFamily, FontFamilyDrop.SelectedValue.ToString());
            updateTextBox();
        }

        private void FontSizeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            StorageHolder.writeSetting(MainWindow.Key_FontSize, FontSizeSlider.Value.ToString());
            updateTextBox();
        }

        private void SettingsWindow_DragMove(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();
        }

        private void AppThemeDrop_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            StorageHolder.writeSetting(MainWindow.Key_AppTheme, AppThemeDrop.SelectedValue.ToString());
            ThemeEngine.applyTheme(AppThemeDrop.SelectedValue.ToString());
        }

        // Window events
        private void SettingsCloseButton_Click(object sender, RoutedEventArgs e)
        {
            RaiseHideEvent();
        }

        public void RaiseHideEvent()
        {
            RoutedEventArgs newEventArgs = new RoutedEventArgs(SettingsWindow.HideEvent);
            RaiseEvent(newEventArgs);
        }

        public void RaiseShowEvent()
        {
            RoutedEventArgs newEventArgs = new RoutedEventArgs(SettingsWindow.ShowEvent);
            RaiseEvent(newEventArgs);
        }

        public void changeVisibility(bool mode)
        {
            if (mode && this.Visibility == Visibility.Hidden)
            {
                RaiseShowEvent();
            }
            else
            {
                RaiseHideEvent();
            }
        }
    }
}


text:
//
//  NSString+CJUIKit.h
//  Pods
//
//  Created by fminor on 6/20/16.
//
//

#import <Foundation/Foundation.h>

@interface NSString (CJUIKit)

/*
 change url query to dictionary
 */
- (NSDictionary *)urlQueryParamDict;
+ (NSDictionary *)urlQueryParamDictFromString:(NSString *)aString;

@end

typedef NS_ENUM(NSInteger, CJFormat) {
    CJFormatDecimal         = 0,
    CJFormatHexadecimal,
    CJFormatOctal
};

@interface NSString (CJFormat)

- (int)intValueWithFormat:(CJFormat)format;
- (int)intValueWithHexadecimalFormat;
- (int)intValueWithDecimalFormat;
- (int)intValueWithOctalFormat;

@end

@interface NSString (Codec)

- (NSString *)MD5String;

@end

// 标记语言 CJML
// 没有嵌套关系的简单 HTML
@interface NSString (CJMarkedLanguage)

+ (void)registerAttributes:(NSDictionary *)attributes forAttributeName:(NSString *)attributeName;

- (NSAttributedString *)markedAttributedStringWithNormalAttributes:(NSDictionary *)attributes;
- (NSAttributedString *)markedAttributedStringWithNormalAttributes:(NSDictionary *)attributes baseFont:(UIFont *)baseFont;

@end


text:
Slack adapter for [Ruboty](https://github.com/r7kamura/ruboty).

## Usage
See https://my.slack.com/admin/settings to enable XMPP Gateway on Slack.

```ruby
# Gemfile
gem "ruboty-slack"
```

## ENV
```
SLACK_PASSWORD - Account's XMPP password
SLACK_ROOM     - Room name to join in at first (e.g. general,random)
SLACK_TEAM     - Account's team name (e.g. wonderland)
SLACK_USERNAME - Account's username (e.g. alice)
```


text:
<?php
function fin_create_menus() {
	$customMenus = array('Primary', 'Secondary');
	foreach ($customMenus as $customMenu) {
		$customMenuSlug = strtolower(str_replace('_', ' ', $customMenu));

		// Create New Menu
			if(!wp_get_nav_menu_object($customMenuSlug . ' Menu')) {
				$newMenuID = wp_create_nav_menu(ucwords($customMenu) . ' Menu', array('slug' => $customMenuSlug));

				// Check if this is the first in $customMenus array
				if(array_search($customMenu, $customMenus) == 0) {
					// Automatatically add new top-level pages
					// Currently causing errors
//					$options = get_option('nav_menu_options');
//					if(!isset($options['auto_add'])) {
//						$options['auto_add'] = array($newMenuID);
//					}
//					if(!in_array($newMenuID, $options['auto_add'])) {
//						$options['auto_add'][] = $newMenuID;
//						update_option('nav_menu_options', $options);
//					}
				}
			}
			// Add Menu to assigned location
			$menu = wp_get_nav_menu_object($customMenuSlug . ' Menu');

			$locations = get_theme_mod('nav_menu_locations');
			$locations[$customMenuSlug.'_menu'] = $menu->term_id;
			set_theme_mod('nav_menu_locations', $locations);
		}
}
add_action('after_switch_theme','fin_create_menus');

// Register Menu Locations
function fin_register_menus() {
	$customMenus = array('Primary', 'Secondary');
	foreach ($customMenus as $customMenu) {
		$customMenuSlug = strtolower(str_replace('_', ' ', $customMenu));
		// Create Theme Locations
		register_nav_menus(array($customMenuSlug.'_menu' => $customMenu . ' Area'));
	}
}
add_action('after_setup_theme','fin_register_menus');

/**
 * Cleaner walker for wp_nav_menu()
 *
 * Walker_Nav_Menu (WordPress default) example output:
 *
Home

 *
Sample Page</l
 *
 * Custom_Nav_Walker example output:
 *
Home

 *
Sample Page

 */
class Fin_Nav_Walker extends Walker_Nav_Menu {
	function check_current($classes) {
		return preg_match('/(current[-_])|active|dropdown/', $classes);
	}

	function start_lvl(&$output, $depth = 0, $args = array()) {
		$output .= "\n
\n";
	}

	function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
		$item_html = '';
		parent::start_el($item_html, $item, $depth, $args);

		if (stristr($item_html, 'li class="divider')) {
			$item_html = preg_replace('/]*>.*?<\/a>/iU', '', $item_html);
		}elseif (stristr($item_html, 'li class="nav-header')) {
			$item_html = preg_replace('/]*>(.*)<\/a>/iU', '$1', $item_html);
		}
		$output .= $item_html;
	}

	function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) {
		$element->is_dropdown = !empty($children_elements[$element->ID]);

		if ($element->is_dropdown) {
			if ($depth === 0) {
				$element->classes[] = 'has-dropdown';
			}elseif ($depth === 1) {
				$element->classes[] = 'has-dropdown';
			}
		}
		parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
	}
}

/**
 * Remove the id="" on nav menu items
 * Return 'menu-slug' for nav menu classes
 */
function fin_nav_menu_css_class($classes, $item) {
  $slug = sanitize_title($item->title);
  $classes = preg_replace('/(current(-menu-|[-_]page[-_])(item|parent|ancestor))/', 'active', $classes);
  $classes = preg_replace('/^((menu|page)[-_\w+]+)+/', '', $classes);

  $classes[] = 'menu-' . $slug;

  $classes = array_unique($classes);

  return array_filter($classes, 'is_element_empty');
}
add_filter('nav_menu_css_class', 'fin_nav_menu_css_class', 10, 2);
add_filter('nav_menu_item_id', '__return_null');

/**
 * Clean up wp_nav_menu_args
 *
 * Remove the container
 * Use fin_Nav_Walker() by default
 */
function fin_nav_menu_args($args = '') {
  $fin_nav_menu_args['container'] = false;

  if (!$args['items_wrap']) {
    $fin_nav_menu_args['items_wrap'] = '
%3$s
';
  }

  $fin_nav_menu_args['depth'] = 3;

  if (!$args['walker']) {
    $fin_nav_menu_args['walker'] = new fin_Nav_Walker();
  }

  return array_merge($args, $fin_nav_menu_args);
}

add_filter('wp_nav_menu_args', 'fin_nav_menu_args');

/**
 * Add search to nav menu
 *
 */
function fin_add_nav_search($items, $args) {
	$options = get_option('fin_theme_options');
	if($options['include_search']) {
		ob_start();
		get_template_part('templates/searchbar');
		$search = ob_get_contents();
		ob_end_clean();
		$items .= '
' . $search . '
';
	}
	return $items;
}
add_filter('wp_nav_menu_items', 'fin_add_nav_search', 10, 2);


text:
FOUNDATION_EXPORT double Pods_PWAlertController_ExampleVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_PWAlertController_ExampleVersionString[];


text:
@class DVTFilePath, IDEContainer;

@protocol IDEContainerDelegate <NSObject>

@optional
- (void)_container:(IDEContainer *)arg1 didChangeFromFilePath:(DVTFilePath *)arg2 toFilePath:(DVTFilePath *)arg3;
@end


text:
function [dlnZ_dmu, dlnZ_dvs] = probitNoiseGradVals(noise, mu, varsigma, y)

% PROBITNOISEGRADVALS Gradient of PROBIT noise log Z with respect to input mean and variance.
% FORMAT
% DESC computes the gradient of the probit based classification
% noise with respect to the input mean and the input variance.
% ARG noise : noise structure for which gradients are being
% computed.
% ARG mu : mean input locations with respect to which gradients are
% being computed.
% ARG varSigma : variance input locations with respect to which
% gradients are being computed.
% ARG y : noise model output observed values associated with the given points.
% RETURN dlnZ_dmu : the gradient of log Z with respect to the input mean.
% RETURN dlnZ_dvs : the gradient of log Z with respect to the input variance.
%
% SEEALSO probitNoiseParamInit, probitNoiseGradientParam, noiseGradVals,
%
% COPYRIGHT : Neil D. Lawrence, 2004, 2005

% GPMAT

D = size(mu, 2);
c = y./sqrt(noise.sigma2+varsigma);
u = zeros(size(c));
for i = 1:D
  u(:, i) = c(:, i).*(mu(:, i) + noise.bias(i));
end
dlnZ_dmu = c.*gradLogCumGaussian(u);
dlnZ_dvs = -.5*c.*u.*dlnZ_dmu;


text:
<?php

namespace Eva\Authentication\Form;

use Eva\Form\Form;
use Eva\Form\Input;

class Recovery extends Form
{
    public function init()
    {
        $element = new Input();
        $element->setAttributes(array(
            'name' => 'identifier',
            'type' => 'text',
            'placeholder' => 'Электронная почта',
            'required' => 'required',
        ));
        $element->setValidators(['email']);
        $element->getLabel()->setText('Электронная почта');
        $this->set('identifier', $element);

        $element = new Input();
        $element->setAttributes(array(
            'type' => 'submit',
            'value' => 'Восстановить пароль',
        ));
        $this->append($element);
    }
}


text:
<?php declare(strict_types=1);

namespace Packagist\WebBundle\Service;

use Packagist\WebBundle\Service\Scheduler;
use Psr\Log\LoggerInterface;
use Composer\Package\Loader\ArrayLoader;
use Composer\Package\Loader\ValidatingArrayLoader;
use Symfony\Bridge\Doctrine\RegistryInterface;
use Composer\Console\HtmlOutputFormatter;
use Composer\Repository\InvalidRepositoryException;
use Composer\Repository\VcsRepository;
use Composer\IO\ConsoleIO;
use Composer\IO\BufferIO;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\HelperSet;
use Monolog\Handler\StreamHandler;
use Packagist\WebBundle\Entity\Package;
use Packagist\WebBundle\Package\Updater;
use Packagist\WebBundle\Entity\Job;
use Packagist\WebBundle\Model\PackageManager;
use Packagist\WebBundle\Model\DownloadManager;
use Seld\Signal\SignalHandler;
use Composer\Factory;
use Composer\Downloader\TransportException;
use Composer\Util\RemoteFilesystem;

class UpdaterWorker
{
    private $logger;
    private $doctrine;
    private $updater;
    private $locker;
    /** @var Scheduler */
    private $scheduler;
    private $packageManager;
    private $downloadManager;

    public function __construct(
        LoggerInterface $logger,
        RegistryInterface $doctrine,
        Updater $updater,
        Locker $locker,
        Scheduler $scheduler,
        PackageManager $packageManager,
        DownloadManager $downloadManager
    ) {
        $this->logger = $logger;
        $this->doctrine = $doctrine;
        $this->updater = $updater;
        $this->locker = $locker;
        $this->scheduler = $scheduler;
        $this->packageManager = $packageManager;
        $this->downloadManager = $downloadManager;
    }

    public function process(Job $job, SignalHandler $signal): array
    {
        $em = $this->doctrine->getEntityManager();
        $id = $job->getPayload()['id'];
        $packageRepository = $em->getRepository(Package::class);
        /** @var Package $package */
        $package = $packageRepository->findOneById($id);
        if (!$package) {
            $this->logger->info('Package is gone, skipping', ['id' => $id]);

            return ['status' => Job::STATUS_PACKAGE_GONE, 'message' => 'Package was deleted, skipped'];
        }

        $packageName = $package->getName();

        $lockAcquired = $this->locker->lockPackageUpdate($id);
        if (!$lockAcquired) {
            return ['status' => Job::STATUS_RESCHEDULE, 'after' => new \DateTime('+5 seconds')];
        }

        $this->logger->info('Updating '.$packageName);

        $config = Factory::createConfig();
        $io = new BufferIO('', OutputInterface::VERBOSITY_VERY_VERBOSE, new HtmlOutputFormatter(Factory::createAdditionalStyles()));
        $io->loadConfiguration($config);

        try {
            $flags = 0;
            if ($job->getPayload()['update_equal_refs'] === true) {
                $flags = Updater::UPDATE_EQUAL_REFS;
            }
            if ($job->getPayload()['delete_before'] === true) {
                $flags = Updater::DELETE_BEFORE;
            }

            // prepare dependencies
            $loader = new ValidatingArrayLoader(new ArrayLoader());

            // prepare repository
            $repository = new VcsRepository(array('url' => $package->getRepository()), $io, $config);
            $repository->setLoader($loader);

            // perform the actual update (fetch and re-scan the repository's source)
            $package = $this->updater->update($io, $config, $package, $repository, $flags);

            // github update downgraded to a git clone, this should not happen, so check through API whether the package still exists
            if (preg_match('{[@/]github.com[:/]([^/]+/[^/]+?)(\.git)?$}i', $package->getRepository(), $match) && 0 === strpos($repository->getDriver()->getUrl(), 'git@')) {
                if ($result = $this->checkForDeadGitHubPackage($package, $match, $io, $io->getOutput())) {
                    return $result;
                }
            }
        } catch (\Throwable $e) {
            $output = $io->getOutput();

            if (!$this->doctrine->getEntityManager()->isOpen()) {
                $this->doctrine->resetManager();
                $package = $this->doctrine->getEntityManager()->getRepository(Package::class)->findOneById($package->getId());
            } else {
                // reload the package just in case as Updater tends to merge it to a new instance
                $package = $packageRepository->findOneById($id);
            }

            if (!$package) {
                return [
                    'status' => Job::STATUS_FAILED,
                    'message' => 'Update of '.$packageName.' failed, package appears to be gone',
                    'details' => '
'.$output.'
',
                    'exception' => $e,
                ];
            }

            // invalid composer data somehow, notify the owner and then mark the job failed
            if ($e instanceof InvalidRepositoryException) {
                $this->packageManager->notifyUpdateFailure($package, $e, $output);

                return [
                    'status' => Job::STATUS_FAILED,
                    'message' => 'Update of '.$packageName.' failed, invalid composer.json metadata',
                    'details' => '
'.$output.'
',
                    'exception' => $e,
                ];
            }

            $found404 = false;

            // attempt to detect a 404/dead repository
            // TODO check and delete those packages with crawledAt in the far future but updatedAt in the past in a second step/job if the repo is really unreachable
            // probably should check for download count and a few other metrics to avoid false positives and ask humans to check the others
            if ($e instanceof \RuntimeException && strpos($e->getMessage(), 'remote: Repository not found')) {
                // git clone was attempted and says the repo is not found, that's very conclusive
                $found404 = true;
            } elseif ($e instanceof \RuntimeException && strpos($e->getMessage(), 'git@gitlab.com') && strpos($e->getMessage(), 'Please make sure you have the correct access rights')) {
                // git clone says we have no right on gitlab for 404s
                $found404 = true;
            } elseif ($e instanceof \RuntimeException && strpos($e->getMessage(), 'git@bitbucket.org') && strpos($e->getMessage(), 'Please make sure you have the correct access rights')) {
                // git clone says we have no right on bitbucket for 404s
                $found404 = true;
            } elseif ($e instanceof \RuntimeException && strpos($e->getMessage(), '@github.com/') && strpos($e->getMessage(), ' Please ask the owner to check their account')) {
                // git clone says account is disabled on github for private repos(?) if cloning via https
                $found404 = true;
            } elseif ($e instanceof TransportException && preg_match('{https://api.bitbucket.org/2.0/repositories/[^/]+/.+?\?fields=-project}i', $e->getMessage()) && $e->getStatusCode() == 404) {
                // bitbucket api root returns a 404
                $found404 = true;
            }

            // github 404'ed, check through API whether the package still exists and delete if not
            if ($found404 && preg_match('{[@/]github.com[:/]([^/]+/[^/]+?)(\.git)?$}i', $package->getRepository(), $match)) {
                if ($result = $this->checkForDeadGitHubPackage($package, $match, $io, $output)) {
                    return $result;
                }
            }

            // detected a 404 so mark the package as gone and prevent updates for 1y
            if ($found404) {
                $package->setCrawledAt(new \DateTime('+1 year'));
                $this->doctrine->getEntityManager()->flush($package);

                return [
                    'status' => Job::STATUS_PACKAGE_GONE,
                    'message' => 'Update of '.$packageName.' failed, package appears to be 404/gone and has been marked as crawled for 1year',
                    'details' => '
'.$output.'
',
                    'exception' => $e,
                ];
            }

            // Catch request timeouts e.g. gitlab.com
            if ($e instanceof TransportException && strpos($e->getMessage(), 'file could not be downloaded: failed to open stream: HTTP request failed!')) {
                return [
                    'status' => Job::STATUS_FAILED,
                    'message' => 'Package data of '.$packageName.' could not be downloaded. Could not reach remote VCS server. Please try again later.',
                    'exception' => $e
                ];
            }

            // generic transport exception
            if ($e instanceof TransportException) {
                return [
                    'status' => Job::STATUS_FAILED,
                    'message' => 'Package data of '.$packageName.' could not be downloaded.',
                    'exception' => $e
                ];
            }

            $this->logger->error('Failed update of '.$packageName, ['exception' => $e]);

            // unexpected error so mark the job errored
            throw $e;
        } finally {
            $this->locker->unlockPackageUpdate($id);
        }

        return [
            'status' => Job::STATUS_COMPLETED,
            'message' => 'Update of '.$packageName.' complete',
            'details' => '
'.$io->getOutput().'
'
        ];
    }

    private function checkForDeadGitHubPackage(Package $package, $match, $io, $output)
    {
        $rfs = new RemoteFilesystem($io);
        try {
            $rfs->getContents('github.com', 'https://api.github.com/repos/'.$match[1], false, ['retry-auth-failure' => false]);
        } catch (\Throwable $e) {
            if ($e instanceof TransportException && $e->getStatusCode() === 404) {
                try {
                    if (
                        // check composer repo is visible to make sure it's not github or something else glitching
                        $rfs->getContents('github.com', 'https://api.github.com/repos/composer/composer', false, ['retry-auth-failure' => false])
                        // remove packages with very low downloads and that are 404
                        && $this->downloadManager->getTotalDownloads($package) <= 100
                    ) {
                        $name = $package->getName();
                        $this->packageManager->deletePackage($package);

                        return [
                            'status' => Job::STATUS_PACKAGE_DELETED,
                            'message' => 'Update of '.$package->getName().' failed, package appears to be 404/gone and has been deleted',
                            'details' => '
'.$output.'
',
                            'exception' => $e,
                        ];
                    }
                } catch (\Throwable $e) {
                    // ignore failures here, we/github must be offline
                }
            }
        }
    }
}


text:
<?xml version="1.0"?>

<!DOCTYPE MODE SYSTEM "xmode.dtd">

<MODE>
	<PROPS>
		<PROPERTY NAME="lineComment" VALUE="!" />
		<PROPERTY NAME="contextInsensitive" VALUE="true" />
	</PROPS>

	<RULES IGNORE_CASE="TRUE" HIGHLIGHT_DIGITS="TRUE">

		<EOL_SPAN TYPE="COMMENT1">!</EOL_SPAN>

			<BEGIN>'</BEGIN>
			<END>'</END>

			<BEGIN>[</BEGIN>
			<END>]</END>

		<SEQ TYPE="OPERATOR">^</SEQ>
		<SEQ TYPE="OPERATOR">@</SEQ>
		<SEQ TYPE="OPERATOR">:=</SEQ>
		<SEQ TYPE="OPERATOR">=</SEQ>
		<SEQ TYPE="OPERATOR"><></SEQ>
		<SEQ TYPE="OPERATOR">>=</SEQ>
		<SEQ TYPE="OPERATOR"><=</SEQ>
		<SEQ TYPE="OPERATOR">></SEQ>
		<SEQ TYPE="OPERATOR"><</SEQ>
		<SEQ TYPE="OPERATOR">+</SEQ>
		<SEQ TYPE="OPERATOR">/</SEQ>
		<SEQ TYPE="OPERATOR">*</SEQ>

		<MARK_FOLLOWING TYPE="LITERAL1">$</MARK_FOLLOWING>
		<MARK_FOLLOWING TYPE="LITERAL2">#</MARK_FOLLOWING>
		<MARK_FOLLOWING TYPE="MARKUP">&</MARK_FOLLOWING>

		<KEYWORDS>

			<FUNCTION>begin-procedure</FUNCTION>
			<FUNCTION>end-procedure</FUNCTION>
			<FUNCTION>begin-report</FUNCTION>
			<FUNCTION>end-report</FUNCTION>
			<FUNCTION>begin-heading</FUNCTION>
			<FUNCTION>end-heading</FUNCTION>
			<FUNCTION>begin-setup</FUNCTION>
			<FUNCTION>end-setup</FUNCTION>
			<FUNCTION>begin-footing</FUNCTION>
			<FUNCTION>end-footing</FUNCTION>
			<FUNCTION>begin-program</FUNCTION>
			<FUNCTION>end-program</FUNCTION>

			<KEYWORD1>begin-select</KEYWORD1>
			<KEYWORD1>end-select</KEYWORD1>
			<KEYWORD1>begin-sql</KEYWORD1>
			<KEYWORD1>end-sql</KEYWORD1>

			<KEYWORD2>add</KEYWORD2>
			<KEYWORD2>array-add</KEYWORD2>
			<KEYWORD2>array-divide</KEYWORD2>
			<KEYWORD2>array-multiply</KEYWORD2>
			<KEYWORD2>array-subtract</KEYWORD2>
			<KEYWORD2>ask</KEYWORD2>
			<KEYWORD2>break</KEYWORD2>
			<KEYWORD2>call</KEYWORD2>
			<KEYWORD2>clear-array</KEYWORD2>
			<KEYWORD2>close</KEYWORD2>
			<KEYWORD2>columns</KEYWORD2>
			<KEYWORD2>commit</KEYWORD2>
			<KEYWORD2>concat</KEYWORD2>
			<KEYWORD2>connect</KEYWORD2>
			<KEYWORD2>create-array</KEYWORD2>
			<KEYWORD2>date-time</KEYWORD2>
			<KEYWORD2>display</KEYWORD2>
			<KEYWORD2>divide</KEYWORD2>
			<KEYWORD2>do</KEYWORD2>
			<KEYWORD2>dollar-symbol</KEYWORD2>
			<KEYWORD2>else</KEYWORD2>
			<KEYWORD2>encode</KEYWORD2>
			<KEYWORD2>end-evaluate</KEYWORD2>
			<KEYWORD2>end-if</KEYWORD2>
			<KEYWORD2>end-while</KEYWORD2>
			<KEYWORD2>evaluate</KEYWORD2>
			<KEYWORD2>execute</KEYWORD2>
			<KEYWORD2>extract</KEYWORD2>
			<KEYWORD2>find</KEYWORD2>
			<KEYWORD2>font</KEYWORD2>
			<KEYWORD2>get</KEYWORD2>
			<KEYWORD2>goto</KEYWORD2>
			<KEYWORD2>graphic</KEYWORD2>
			<KEYWORD2>if</KEYWORD2>
			<KEYWORD2>last-page</KEYWORD2>
			<KEYWORD2>let</KEYWORD2>
			<KEYWORD2>lookup</KEYWORD2>
			<KEYWORD2>lowercase</KEYWORD2>
			<KEYWORD2>money-symbol</KEYWORD2>
			<KEYWORD2>move</KEYWORD2>
			<KEYWORD2>multiply</KEYWORD2>
			<KEYWORD2>new-page</KEYWORD2>
			<KEYWORD2>new-report</KEYWORD2>
			<KEYWORD2>next-column</KEYWORD2>
			<KEYWORD2>next-listing</KEYWORD2>
			<KEYWORD2>no-formfeed</KEYWORD2>
			<KEYWORD2>open</KEYWORD2>
			<KEYWORD2>page-number</KEYWORD2>
			<KEYWORD2>page-size</KEYWORD2>
			<KEYWORD2>position</KEYWORD2>
			<KEYWORD2>print</KEYWORD2>
			<KEYWORD2>print-bar-code</KEYWORD2>
			<KEYWORD2>print-chart</KEYWORD2>
			<KEYWORD2>print-direct</KEYWORD2>
			<KEYWORD2>print-image</KEYWORD2>
			<KEYWORD2>printer-deinit</KEYWORD2>
			<KEYWORD2>printer-init</KEYWORD2>
			<KEYWORD2>put</KEYWORD2>
			<KEYWORD2>read</KEYWORD2>
			<KEYWORD2>rollback</KEYWORD2>
			<KEYWORD2>show</KEYWORD2>
			<KEYWORD2>stop</KEYWORD2>
			<KEYWORD2>string</KEYWORD2>
			<KEYWORD2>subtract</KEYWORD2>
			<KEYWORD2>unstring</KEYWORD2>
			<KEYWORD2>uppercase</KEYWORD2>
			<KEYWORD2>use</KEYWORD2>
			<KEYWORD2>use-column</KEYWORD2>
			<KEYWORD2>use-printer-type</KEYWORD2>
			<KEYWORD2>use-procedure</KEYWORD2>
			<KEYWORD2>use-report</KEYWORD2>
			<KEYWORD2>use-report</KEYWORD2>
			<KEYWORD2>while</KEYWORD2>
			<KEYWORD2>write</KEYWORD2>
			<KEYWORD2>to</KEYWORD2>

 			<KEYWORD3>from</KEYWORD3>
			<KEYWORD3>where</KEYWORD3>
			<KEYWORD3>and</KEYWORD3>
			<KEYWORD3>between</KEYWORD3>
			<KEYWORD3>or</KEYWORD3>
			<KEYWORD3>in</KEYWORD3>

		</KEYWORDS>
	</RULES>
</MODE>


text:
namespace views {

// Left or right margin.
const int kPanelHorizMargin = 13;

// Top or bottom margin.
const int kPanelVertMargin = 13;

// If some UI has some sub UI. Indent horizontally by the following value.
const int kPanelHorizIndentation = 24;

// When several controls are aligned vertically, the baseline should be spaced
// by the following number of pixels.
const int kPanelVerticalSpacing = 32;

// Vertical spacing between sub UI.
const int kPanelSubVerticalSpacing = 24;

// Vertical spacing between a label and some control.
const int kLabelToControlVerticalSpacing = 8;

// Small horizontal spacing between controls that are logically related.
const int kRelatedControlSmallHorizontalSpacing = 8;

// Horizontal spacing between controls that are logically related.
const int kRelatedControlHorizontalSpacing = 8;

// Vertical spacing between controls that are logically related.
const int kRelatedControlVerticalSpacing = 8;

// Small vertical spacing between controls that are logically related.
const int kRelatedControlSmallVerticalSpacing = 4;

// Horizontal spacing between controls that are logically unrelated.
const int kUnrelatedControlHorizontalSpacing = 12;

// Larger horizontal spacing between unrelated controls.
const int kUnrelatedControlLargeHorizontalSpacing = 20;

// Vertical spacing between controls that are logically unrelated.
const int kUnrelatedControlVerticalSpacing = 20;

// Larger vertical spacing between unrelated controls.
const int kUnrelatedControlLargeVerticalSpacing = 30;

// Vertical spacing between the edge of the window and the
// top or bottom of a button.
const int kButtonVEdgeMargin = 9;

// Vertical spacing between the edge of the window and the
// left or right of a button.
const int kButtonHEdgeMargin = 13;

// Horizontal spacing between buttons that are logically related.
const int kRelatedButtonHSpacing = 6;

}  // namespace views

#endif  // UI_VIEWS_LAYOUT_LAYOUT_CONSTANTS_H_