text:
import endpoints
import logging
from protorpc import messages
from protorpc import message_types
from protorpc import remote
from time import sleep

import ra_memcache
# Import api messages
from hitlist_api_messages import EateryNotes
from hitlist_api_messages import EateryLocation
from hitlist_api_messages import EateryLocationCollection

from models import Eatery
from models import Couple

WEB_CLIENT_ID = '356591658043-r06nli81msv1s280plb91a2kjn25c02b.apps.googleusercontent.com'
ANDROID_CLIENT_ID = 'replace this with your Android client ID'
IOS_CLIENT_ID = 'replace this with your iOS client ID'
ANDROID_AUDIENCE = WEB_CLIENT_ID
package = 'hitlist'

@endpoints.api(name='hitlist',version='v1'
                ,allowed_client_ids=[WEB_CLIENT_ID, endpoints.API_EXPLORER_CLIENT_ID]
                ,audiences=[ANDROID_AUDIENCE]
                ,scopes=[endpoints.EMAIL_SCOPE])
class HelloWorldApi(remote.Service):
    """ hitlist API"""
    # pass
    ID_RESOURCE = endpoints.ResourceContainer(message_types.VoidMessage,id=messages.IntegerField(1,variant=messages.Variant.INT64))

    @endpoints.method(ID_RESOURCE, EateryNotes,path='eatery_notes/{id}', http_method='GET',name='eateries.getEateryNotes')
    def eatery_notes_get(self, request):
        status_code,couple_key = self.auth_api_user()
        if status_code == -2:
            raise endpoints.UnauthorizedException("Please sign in.")
        elif status_code == -1:
            return EateryNotes(status_code=-1)
        # Retreive the eatery
        key = 'Eatery|' + str(request.id)
        e = ra_memcache.cache_entity(key,request.id,couple_key,Eatery.by_id)
        # e = Eatery.by_id(request.id,couple_key,None)
        if e:
            # Initialize the EateryMessage
            e_message = EateryNotes(restaurant_name=e.RestaurantName,notes_comments=e.NotesComments,status_code=0)
            return e_message
        else:
            raise endpoints.NotFoundException('Eatery %s not found.' % request.id)

    @endpoints.method(ID_RESOURCE, EateryLocation,path='eatery_location/{id}', http_method='GET',name='eateries.getEateryLocation')
    def eatery_location_get(self, request):
        status_code,couple_key = self.auth_api_user()
        if status_code == -2:
            raise endpoints.UnauthorizedException("Please sign in.")
        elif status_code == -1:
            return EateryLocation(status_code=-1)
        # Retreive the eatery
        key = 'Eatery|' + str(request.id)
        e = ra_memcache.cache_entity(key,request.id,couple_key,Eatery.by_id)
        if e:
            # Check if this eatery has been geocoded.
            if e.Latitude and e.Longitude:
                geocoded = True
            else:
                geocoded = False
            # Initialize the EateryMessage
            e_message = EateryLocation(restaurant_name=e.RestaurantName,latitude=e.Latitude
                ,longitude=e.Longitude,geocoded=geocoded,status_code=status_code)
            return e_message
        else:
            raise endpoints.NotFoundException('Eatery %s not found.' % request.id)

    @endpoints.method(message_types.VoidMessage, EateryLocationCollection, path='eaterieslocation', http_method='GET',
                        name='eateries.getLocations')
    def locations_eateries_get(self,unused_request):
        status_code,couple_key = self.auth_api_user()
        if status_code == -2:
            raise endpoints.UnauthorizedException("Please sign in.")
        elif status_code == -1:
            return EateryLocation(status_code=-1)
        geocoded_hitlist_key = "GeocodedHitlist|" + str(couple_key.key().id())
        # Get a list of Entity keys that are associated with this user and have been geocoded.
        geocoded_hitlist = ra_memcache.geocoded_hitlist_cache(geocoded_hitlist_key,couple_key)
        # List of response messages.
        items = []
        for e in geocoded_hitlist:
            # Initialize the EateryMessage
            e_message = EateryLocation(restaurant_name=e.RestaurantName,latitude=e.Latitude,longitude=e.Longitude,geocoded=True,status_code=status_code)
            items.append(e_message)
        return EateryLocationCollection(items=items)

    @endpoints.method(EateryLocation,EateryLocation,path='eatery_geocode',http_method='POST',name='eateries.geocode')
    def eatery_geocode_insert(self,request):
        status_code,couple_key = self.auth_api_user()
        if status_code == -2:
            raise endpoints.UnauthorizedException("Please sign in.")
        elif status_code == -1:
            return EateryLocation(status_code=-1)
        key = 'Eatery|' + str(request.eatery_id)
        eatery = ra_memcache.cache_entity(key,request.eatery_id,couple_key,Eatery.by_id)
        if eatery:
            eatery.Latitude = request.latitude
            eatery.Longitude = request.longitude
            eatery.put()
            # Refresh memcache
            eatery = ra_memcache.cache_entity(key,request.eatery_id,couple_key,Eatery.by_id,update=True)
            geocoded_hitlist_key = "GeocodedHitlist|" + str(couple_key.key().id())
            geocoded_hitlist = ra_memcache.geocoded_hitlist_cache(geocoded_hitlist_key,couple_key,update=True)
        else:
            return EateryLocation(status_code=-2)
        return EateryLocation(status_code=0)

    def auth_api_user(self):
        current_user = endpoints.get_current_user()
        if not current_user:
            logging.error("Yup not signed in!!!")
            return -2,None
        else:
            # Get couple key
            key = "Couple_Key|" + current_user.email()
            couple_key = ra_memcache.cache_entity(key,current_user.email(),None,Couple.by_email,keys_only=False)
            # couple_key = Couple.by_email(current_user.email(),keys_only=True)
            if not couple_key:
                return -1,None
            return 0,couple_key

APPLICATION = endpoints.api_server([HelloWorldApi])


text:
package Paws::SMS::DeleteReplicationJob;
  use Moose;
  has ReplicationJobId => (is => 'ro', isa => 'Str', traits => ['NameInRequest'], request_name => 'replicationJobId' , required => 1);

  use MooseX::ClassAttribute;

  class_has _api_call => (isa => 'Str', is => 'ro', default => 'DeleteReplicationJob');
  class_has _returns => (isa => 'Str', is => 'ro', default => 'Paws::SMS::DeleteReplicationJobResponse');
  class_has _result_key => (isa => 'Str', is => 'ro');
1;

### main pod documentation begin ###

=head1 NAME

Paws::SMS::DeleteReplicationJob - Arguments for method DeleteReplicationJob on Paws::SMS

=head1 DESCRIPTION

This class represents the parameters used for calling the method DeleteReplicationJob on the
AWS Server Migration Service service. Use the attributes of this class
as arguments to method DeleteReplicationJob.

You shouldn't make instances of this class. Each attribute should be used as a named argument in the call to DeleteReplicationJob.

As an example:

  $service_obj->DeleteReplicationJob(Att1 => $value1, Att2 => $value2, ...);

Values for attributes that are native types (Int, String, Float, etc) can passed as-is (scalar values). Values for complex Types (objects) can be passed as a HashRef. The keys and values of the hashref will be used to instance the underlying object.

=head1 ATTRIBUTES

=head2 B<REQUIRED> ReplicationJobId => Str

=head1 SEE ALSO

This class forms part of L<Paws>, documenting arguments for method DeleteReplicationJob in L<Paws::SMS>

=head1 BUGS and CONTRIBUTIONS

The source code is located here: https://github.com/pplu/aws-sdk-perl

Please report bugs to: https://github.com/pplu/aws-sdk-perl/issues

=cut

redpajama_set_name: RedPajamaGithub


text:
package com.netflix.conductor.server;

import com.google.inject.AbstractModule;
import com.google.inject.name.Names;

import com.netflix.conductor.dyno.DynoShardSupplierProvider;
import com.netflix.conductor.dyno.DynomiteConfiguration;
import com.netflix.conductor.dyno.RedisQueuesProvider;
import com.netflix.conductor.dyno.SystemPropertiesDynomiteConfiguration;
import com.netflix.conductor.jedis.InMemoryJedisProvider;
import com.netflix.conductor.jedis.LocalHostSupplierProvider;
import com.netflix.dyno.connectionpool.HostSupplier;
import com.netflix.dyno.queues.ShardSupplier;

import redis.clients.jedis.JedisCommands;

public class LocalRedisModule extends AbstractModule {
    @Override
    protected void configure() {

        bind(DynomiteConfiguration.class).to(SystemPropertiesDynomiteConfiguration.class);
        bind(JedisCommands.class).toProvider(InMemoryJedisProvider.class);
        bind(JedisCommands.class)
                .annotatedWith(Names.named(RedisQueuesProvider.READ_CLIENT_INJECTION_NAME))
                .toProvider(InMemoryJedisProvider.class);
        bind(HostSupplier.class).toProvider(LocalHostSupplierProvider.class);
        bind(ShardSupplier.class).toProvider(DynoShardSupplierProvider.class);
    }
}


text:
../src/iffjoin/iffjoin -o join.IFF join.HELO join.BYE
./validiff join.IFF


text:
if [ -e "$JAVA_HOME"/bin/java ] ; then
    if [ -f ./properties.xml ] ; then
        # Set the MCF_HOME variable
        export MCF_HOME=$PWD
        processes/executecommand.sh org.apache.zookeeper.server.quorum.QuorumPeerMain zookeeper.cfg
        exit $?

    else
        echo "Working directory contains no properties.xml file." 1>&2
        exit 1
    fi

else
    echo "Environment variable JAVA_HOME is not properly set." 1>&2
    exit 1
fi


text:
package com.thoughtworks.frankenstein.events;

import java.awt.*;
import java.awt.event.FocusListener;
import java.awt.event.FocusEvent;

import javax.swing.*;

import org.jmock.MockObjectTestCase;
import org.jmock.Mock;

import com.thoughtworks.frankenstein.playback.ComponentFinder;
import com.thoughtworks.frankenstein.common.WaitForIdle;

/**
 *  Ensures the behaviour of the AppletActivated Event.
 *
 * @author Pavan
 */
public class ActivateAppletEventTest extends MockObjectTestCase {
    public static final Object FOCUS_LOCK = new Object();
    private ActivateAppletEvent activateAppletEvent;

    protected void setUp() throws Exception {
        activateAppletEvent = new ActivateAppletEvent("testApplet");
    }

     public void testEqualsAndHashCode() {
        ActivateAppletEvent one = new ActivateAppletEvent("title");
        ActivateAppletEvent two = new ActivateAppletEvent("title");
        assertEquals(one, two);
        assertEquals(one.hashCode(), two.hashCode());
    }

    public void testToString() {
        assertEquals("ActivateAppletEvent: title", new ActivateAppletEvent("title").toString());
    }

    public void testAction() {
        assertEquals("ActivateApplet", new ActivateAppletEvent("title").action());
    }

    public void testTarget() {
        assertEquals("title", new ActivateAppletEvent("title").target());
    }

    public void testParameters() {
        assertEquals("", new ActivateAppletEvent("title").parameters());
    }

    public void testScriptLine() {
        assertEquals("activate_applet \"title\"", new ActivateAppletEvent("title").scriptLine());
    }

    public void testPlay() throws InterruptedException {
        Frame frame = new Frame();
        JApplet applet = new JApplet();
        JButton button = new JButton();
        applet.setName("testApplet");
        frame.add(applet);
        frame.add(button);
        frame.setVisible(true);
        new WaitForIdle().waitForIdle();
        FocusListener listener = new FocusListener(){
            public void focusGained(FocusEvent e) {
                synchronized(FOCUS_LOCK){
                    FOCUS_LOCK.notifyAll();
                }
            }
            public void focusLost(FocusEvent e) {
            }
        };
        button.addFocusListener(listener);
        synchronized(FOCUS_LOCK){
            button.requestFocus();
            FOCUS_LOCK.wait(100);
        }
        assertTrue(button.hasFocus());
        assertFalse(applet.hasFocus());
        button.removeFocusListener(listener);
        applet.addFocusListener(listener);
        Mock mockComponentFinder = mock(ComponentFinder.class);
        mockComponentFinder.expects(once()).method("findApplet").with(eq("testApplet"))
                .will(returnValue(applet));
        activateAppletEvent.play(null, (ComponentFinder) mockComponentFinder.proxy(), null, null);
        synchronized(FOCUS_LOCK){
            FOCUS_LOCK.wait(100);
        }
        mockComponentFinder.verify();
        assertTrue(applet.hasFocus());
        assertFalse(button.hasFocus());
        frame.dispose();
    }
}


text:
Compiled example
----------------
![Example](triangle-exteriour-angle-theorem-1.png)


text:
/**
 * Class definition. I will use this class instead of Laya.class.
 */
(function () {
    var initializing = false, fnTest = /xyz/.test(function () { xyz; }) ? /\b_super\b/ : /. */;

    // The base class implementation (does nothing)
    mw.Class = function () {};
    var Class = mw.Class;

    // Create a new class that inherits from this class
    Class.extend = function (props) {
        var _super = this.prototype;

        // Instantiate a base class (but only create the distance, don't run the ctor constructor)
        initializing = true;
        var prototype = new this();
        initializing = false;

        // Copy the properties over onto the new prototype.
        for (var name in props) {
            // Check if we're overwriting an existing function
            prototype[name] = typeof props[name] == "function" &&
                typeof _super[name] == "function" && fnTest.test(props[name]) ?
                (function (name, fn) {
                    return function () {
                        var tmp = this._super;

                        // Add a new ._super() method that is the same method but on the super-class
                        this._super = _super[name];

                        // The method only need to be bound temporarily, so we remove it when we're done executing
                        var ret = fn.apply(this, arguments);
                        this._super = tmp;

                        return ret;
                    };
                })(name, props[name]) :
                props[name];
        }

        // The dummy class constructor
        function Class() {
            // All construction is actually done in the ctor method
            if (!initializing && this.ctor) {
                this.ctor.apply(this, arguments);
            }
        }

        // Populate our constructed prototype object
        Class.prototype = prototype;

        // Enforce the constructor to be what we expect
        Class.prototype.constructor = Class;

        // Make this class extendable
        Class.extend = arguments.callee;

        return Class;
    };
})();


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:background="@drawable/table_normal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/table_number_TextView"
        android:width="100dp"
        android:height="100dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="10"
        android:textSize="28sp"
        android:gravity="center"/>
</LinearLayout>


text:
            <input wd-focus-me="ctrl.isNewAnswer[answer.id]" type="text" ng-model="answer.value" ng-keypress="ctrl.keyPressedOnInput($event,answer)" required class="form-control offered-answer-value " ng-readonly="ctrl.readOnly">
            <button role="button" class="remove-item-button" ng-click="ctrl.removeOfferedAnswer(answer)" ng-if="!ctrl.readOnly"
                    ng-attr-title="{{'mwForm.buttons.remove' | translate}}" uib-popover="{{'mwForm.buttons.remove' | translate}}" popover-trigger="mouseenter" popover-placement="top">

            </button>

                 <select ng-options="pageFlow.label|translate:pageFlow for pageFlow in ctrl.possiblePageFlow" ng-model="answer.pageFlow"  class="form-control" ng-disabled="ctrl.readOnly"></select>

            <input type="text" class="form-control  offered-answer-value" value="{{'mwForm.question.buttons.addOption'|translate}}">

            lub
            <button role="button" ng-click="ctrl.addCustomAnswer()" translate="mwForm.question.buttons.addOther">Dodaj "Inne"</button>

        Inna:
        <input  type="text" value="{{'mwForm.question.userAnswer'|translate}}"  class="form-control offered-answer-value " readonly>
        <button type="button" role="button" class="remove-item-button" ng-click="ctrl.removeCustomAnswer()" ng-if="!ctrl.readOnly"
                ng-attr-title="{{'mwForm.buttons.remove' | translate}}" uib-popover="{{'mwForm.buttons.remove' | translate}}" popover-trigger="mouseenter" popover-placement="top">

        </button>


text:
#ifndef _SIV_H_
#define _SIV_H_

#include <openssl/aes.h>

#define AES_128_BYTES	16
#define AES_192_BYTES	24
#define AES_256_BYTES	32
#define SIV_256         256
#define SIV_384         384
#define SIV_512         512

typedef struct _siv_ctx {
    unsigned char K1[AES_BLOCK_SIZE];
    unsigned char K2[AES_BLOCK_SIZE];
    unsigned char T[AES_BLOCK_SIZE];
    unsigned char benchmark[AES_BLOCK_SIZE];
    AES_KEY ctr_sched;
    AES_KEY s2v_sched;
} siv_ctx;

/*
 * exported APIs
 */
void aes_cmac (siv_ctx *, const unsigned char *, int, unsigned char *);
int siv_init(siv_ctx *, const unsigned char *, int);
void siv_reset(siv_ctx *);
void s2v_benchmark(siv_ctx *);
void s2v_add(siv_ctx *, const unsigned char *);
void s2v_update(siv_ctx *, const unsigned char *, int);
int s2v_final(siv_ctx *, const unsigned char *, int, unsigned char *);
void siv_restart(siv_ctx *);
void siv_aes_ctr(siv_ctx *, const unsigned char *, const int, unsigned char *,
                 const unsigned char *);
int siv_encrypt (siv_ctx *ctx, const unsigned char *p, unsigned char *c,
             const int len, unsigned char *counter,
             const int nad, const int* adlens, const unsigned char** ads);
int siv_decrypt(siv_ctx *, const unsigned char *, unsigned char *,
                const int, unsigned char *, const int, ... );

#endif /* _SIV_H_ */


text:
package com.fourcasters.forec.reconciler.server.http;

import static com.fourcasters.forec.reconciler.server.ProtocolConstants.CHARSET;
import static com.fourcasters.forec.reconciler.server.ProtocolConstants.CLOSED_TRADES_FILE_NAME;
import static com.fourcasters.forec.reconciler.server.ProtocolConstants.NOT_FOUND_FILE_NAME;
import static com.fourcasters.forec.reconciler.server.ProtocolConstants.NOT_FOUND_HEADER;
import static com.fourcasters.forec.reconciler.server.ProtocolConstants.OPEN_TRADES_FILE_NAME;
import static com.fourcasters.forec.reconciler.server.ProtocolConstants.PERFORMANCE_FILE_NAME;
import static com.fourcasters.forec.reconciler.server.ProtocolConstants.RESPONSE_OK_HEADER;
import static com.fourcasters.forec.reconciler.server.ProtocolConstants.WRONG_METHOD_FILE_NAME;
import static com.fourcasters.forec.reconciler.server.ProtocolConstants.WRONG_METHOD_HEADER;
import static com.fourcasters.forec.reconciler.server.http.AbstractServlet.sendFile;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;

import com.fourcasters.forec.reconciler.server.ApplicationInterface;
import com.fourcasters.forec.reconciler.server.InitialStrategiesLoader;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.fourcasters.forec.reconciler.query.marketdata.HistoryDAO;
import com.fourcasters.forec.reconciler.server.ReconcilerConfig;
import com.fourcasters.forec.reconciler.server.StrategiesTracker;

public class HttpRequestHandler {

	private static final Logger LOG = LogManager.getLogger(HttpRequestHandler.class);
	private final StrategiesTracker strategiesTracker;
	private final HistoryDAO historyDao;

	public HttpRequestHandler(HistoryDAO historyDao) {
		this.strategiesTracker = new StrategiesTracker(new InitialStrategiesLoader());
		LOG.debug(ReconcilerConfig.MD_DATA_PATH);
		this.historyDao = historyDao;
	}

	public int respond(final SocketChannel clientChannel, final HttpParser httpParser) throws IOException {
		int response = httpParser.parseRequest();
		if (response == 200){
			final String reqUrl = httpParser.getRequestURL();
			if (reqUrl.equals("/strategies")) {
				LOG.info("Set of strategies requested");
				sendString(clientChannel, Arrays.toString(strategiesTracker.getStrategies()));
			}
			else if (reqUrl.equals("/history/csv")) {
				LOG.info("Trades history requested in csv format");
				sendFile(clientChannel, RESPONSE_OK_HEADER, CLOSED_TRADES_FILE_NAME);
			}
			else if(reqUrl.equals("/open/csv")){
				LOG.info("Open trades requested in csv format");
				sendFile(clientChannel, RESPONSE_OK_HEADER, OPEN_TRADES_FILE_NAME);
			}
			else if (reqUrl.equals("/performance")) {
				LOG.info("Performance file requested");
				if(!httpParser.getMethod().equals("GET")) {
					LOG.error("Method must be GET");
					sendFile(clientChannel, WRONG_METHOD_HEADER, WRONG_METHOD_FILE_NAME);
				}
				else {
					final String magicAsString = httpParser.getParam("magic");
					if (magicAsString == null) {
						LOG.error("Magic must be a paremeter");
						sendFile(clientChannel, NOT_FOUND_HEADER, NOT_FOUND_FILE_NAME);
					}
					else {
						final String fileName = magicAsString + PERFORMANCE_FILE_NAME;
						if (!Files.exists(Paths.get(fileName))) {
							LOG.error("Magic " + magicAsString +" is not a number");
							sendFile(clientChannel, NOT_FOUND_HEADER, NOT_FOUND_FILE_NAME);
						}
						else {
							sendFile(clientChannel, RESPONSE_OK_HEADER, fileName);
						}
					}
				}
			}
			else if (reqUrl.equals("/csvdata")) {
				new MarketDataServlet(httpParser, historyDao).respond(clientChannel);
			}
			else if (reqUrl.equals("/algolog")) {
				new AlgoLogSenderServlet(httpParser).respond(clientChannel);
			}
			else { // requested page not found
				sendFile(clientChannel, NOT_FOUND_HEADER, NOT_FOUND_FILE_NAME);
			}
		}
		return response;
	}

	private static void sendString(SocketChannel clientChannel, String response) throws IOException {
		clientChannel.write(ByteBuffer.wrap(response.getBytes(CHARSET)));
		clientChannel.write(ByteBuffer.wrap("\r\n".getBytes(CHARSET)));
	}

}