text:
import xml.etree

import model

import view_tests_base

class FeedRepoViewTests(view_tests_base.ViewTestsBase):

    _NAMESPACES = {
        'atom': 'http://www.w3.org/2005/Atom',
    }

    _SINGLE_REPO_FEED_EXPECTED_CONTENT = (
        '<?xml version="1.0" encoding="UTF-8"?><feed '
        'xmlns:georss="http://www.georss.org/georss" '
        'xmlns:gpf="http://schemas.google.com/personfinder/2012" '
        'xmlns="http://www.w3.org/2005/Atom"><id>'
        'http://testserver/haiti/feeds/repo</id><title>Person Finder Repository'
        ' Feed</title><updated>2019-03-15T20:41:09Z</updated><entry><id>'
        'http://testserver/haiti/</id><title lang="en">Haiti Earthquake</title>'
        '<updated>2019-03-15T20:41:09Z</updated><content type="text/xml">'
        '<gpf:repo><gpf:title lang="fr">Séisme en Haïti</gpf:title>'
        '<gpf:title lang="en">Haiti Earthquake</gpf:title><gpf:title lang="es">'
        'Terremoto en Haití</gpf:title><gpf:title lang="ht">Tranbleman '
        'Tè an Ayiti</gpf:title><gpf:read_auth_key_required>false'
        '</gpf:read_auth_key_required><gpf:search_auth_key_required>false'
        '</gpf:search_auth_key_required><gpf:test_mode>false</gpf:test_mode>'
        '<gpf:location><georss:point>18.968637 -72.284546</georss:point>'
        '</gpf:location></gpf:repo></content></entry></feed>')

    def setUp(self):
        super(FeedRepoViewTests, self).setUp()
        self.haiti_updated_timestamp = 1552682469
        self.nepal_updated_timestamp = 1551682469
        self.pakistan_updated_timestamp = 1550682469
        self.data_generator.repo()
        self.data_generator.setup_repo_config(
            repo_id='haiti',
            updated_date=self.haiti_updated_timestamp,
            repo_titles={
                'en': 'Haiti Earthquake',
                'es': 'Terremoto en Haití',
                'fr': 'Séisme en Haïti',
                'ht': 'Tranbleman Tè an Ayiti',
            },
            map_default_center=[18.968637, -72.284546])
        self.data_generator.repo(repo_id='nepal')
        self.data_generator.setup_repo_config(
            repo_id='nepal',
            updated_date=self.nepal_updated_timestamp)
        self.data_generator.repo(
            repo_id='pakistan',
            activation_status=model.Repo.ActivationStatus.DEACTIVATED)
        self.data_generator.setup_repo_config(
            repo_id='pakistan',
            updated_date=self.pakistan_updated_timestamp)

    def test_nonexistent_repo_feed(self):
        resp = self.client.get('/nonexistent/feeds/repo')
        self.assertEqual(resp.status_code, 404)

    def test_deactivated_repo_feed(self):
        resp = self.client.get('/pakistan/feeds/repo')
        self.assertEqual(resp.status_code, 404)

    def test_single_repo_feed(self):
        resp = self.client.get('/haiti/feeds/repo')
        self.assertEqual(
            resp.content, FeedRepoViewTests._SINGLE_REPO_FEED_EXPECTED_CONTENT)

    def test_global_repo_feed(self):
        feed = self._get_parsed_feed('/global/feeds/repo')
        entry_els = feed.findall('{http://www.w3.org/2005/Atom}entry')
        self.assertEqual(len(entry_els), 2)
        haiti_el = entry_els[0]
        self.assertEqual(
            haiti_el.findall('{http://www.w3.org/2005/Atom}id')[0].text,
            'http://testserver/haiti/')
        nepal_el = entry_els[1]
        self.assertEqual(
            nepal_el.findall('{http://www.w3.org/2005/Atom}id')[0].text,
            'http://testserver/nepal/')

    def _get_parsed_feed(self, path):
        resp = self.client.get(path)
        return xml.etree.ElementTree.fromstring(resp.content)


text:
using System;
using System.Diagnostics.Contracts;
using EnvCrypt.Core.Key.Rsa;
using EnvCrypt.Core.Key.XmlPoco;
using EnvCrypt.Core.Utils.IO.StringWriter;
using EnvCrypt.Core.Verb.GenerateKey.Persister;
using EnvCrypt.Core.Verb.GenerateKey.Persister.Asymetric;

namespace EnvCrypt.Core.Verb.GenerateKey.Rsa
{
    public class GenerateRsaKeyBuilder : GenericBuilder
    {
        public const int DefaultRsaKeySize = 2048;
        public const bool DefaultUseOaepPadding = true;

        private IKeyPersister<RsaKey, AsymmetricKeyFilePersisterOptions> _persister;
        private GenerateKeyWorkflow<RsaKey, RsaKeyGenerationOptions, AsymmetricKeyFilePersisterOptions> _workflow;

        public GenerateRsaKeyBuilder()
        {
            Contract.Ensures(!IsBuilt);
            //
            IsBuilt = false;
            _persister = AsymmetricKeyFilePersisterFactory.GetRsaKeyPersister();
        }

        public GenerateRsaKeyBuilder WithKeyPersister(AsymmetricKeyFilePersister<RsaKey, EnvCryptKey, StringToFileWriterOptions> persister)
        {
            _persister = persister;
            SetWorkflowToNull();
            return this;
        }

        /// <summary>
        /// Prepares the Builder ready for use. This must be called before your first call to the <see cref="Run"/> method.
        /// This method is idempotent.
        /// </summary>
        /// <returns>the same Builder instance</returns>
        public GenerateRsaKeyBuilder Build()
        {
            Contract.Ensures(Contract.Result<GenerateRsaKeyBuilder>() != null);
            Contract.Ensures(IsBuilt);
            //
            _workflow = new GenerateKeyWorkflow<RsaKey, RsaKeyGenerationOptions, AsymmetricKeyFilePersisterOptions>(
                new RsaKeyGenerator(),
                _persister);
            IsBuilt = true;
            return this;
        }

        public void Run(AsymmetricKeyFilePersisterOptions options)
        {
            Contract.Requires<ArgumentNullException>(options != null, "fileOptions");
            //
            ThrowIfNotBuilt();

            var keyGenerationOptions = new RsaKeyGenerationOptions()
            {
                KeySize = DefaultRsaKeySize,
                UseOaepPadding = DefaultUseOaepPadding,
                NewKeyName = options.NewKeyName
            };

            _workflow.Run(keyGenerationOptions, options);
        }

        protected override void SetWorkflowToNull()
        {
            _workflow = null;
        }

        protected override bool IsWorkflowNull()
        {
            return _workflow == null;
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
var visibilityFilter = require('../../utils/visibility-filter');

function getKeywords(data) {
    if (data.post && data.post.tags && data.post.tags.length > 0) {
        return visibilityFilter(data.post.tags, ['public'], false, function processItem(item) {
            return item.name;
        });
    }
    return null;
}

module.exports = getKeywords;


text:
var Backbone = require('backbone');
var _ = require('underscore');

/**
 * @name Model~isNotImmutable
 * @private
 * @param {Object} options
 * @param {String} methodName
 * @return {Boolean}
 */
var isNotImmutable = function(options, methodName) {
  options = options || {};

  if (options.overrideImmutability !== true) {
    throw new Error(
      'Attempting to ' + methodName + ' a model that is immutable. ' +
      'Please clone this for a mutable version.'
    );
  } else {
    return true;
  }
};

/**
 * A read-only Backbone model.
 *
 * When a model is read-only, any number of components can read its attributes
 * and listen for change events. However, those components are not allowed to
 * mutate its attributes.
 *
 * Important! A read-only model is not fully immutable. The model can still
 * call fetch() on itself. Additionally, if you go against best practices and
 * mutate Model.attributes directly, this object will not prevent that.
 *
 * To achieve "read-only", I wanted to keep the logic as lightweight as
 * possible and not be too tricky; including not overriding every method.
 * Luckily, Backbone does a really good job of ensuring that "option" hashes
 * are passed down between function calls. That is ultimately how we achieve
 * read-only. Very backbone!
 *
 * @constructor
 * @augments {Backbone.Model}
 * @name Model
 */
module.exports = Backbone.Model.extend(
/** @lends Model.prototype */
{
  /**
   * Overridden to pass the override option to allow setting the passed
   * attributes (if any).
   *
   * @param {Object} attributes
   * @param {Object} options
   */
  constructor: function(attributes, options) {
    options = options || {};
    options.overrideImmutability = true;
    Backbone.Model.call(this, attributes, options);
  },

  /**
   * All Backbone.Model methods that mutate Model.attributes use set(), which
   * simplifies things. We really only need to override this method to prevent
   * mutation.
   *
   * @param {Object|String} key
   * @param {Object|String} val
   * @param {Object|undefined} options
   */
  set: function(key, val, options) {
    options = options || {};

    if (_.isEmpty(key)) {
      return this;
    }

    // Backbone allows for set({}) or set('', ''), so the following ensures
    // we grab the correct parameter representing "options".
    if (typeof key === 'object') {
      options = val || {};
    }

    if (isNotImmutable(options, 'set')) {
      return Backbone.Model.prototype.set.apply(this, arguments);
    }
  },

  /**
   * A read-only model is allowed to fetch.
   *
   * @param {Object} options
   * @return {jQuery.Promise|Boolean}
   */
  fetch: function(options) {
    options = options || {};
    options.overrideImmutability = true;
    return Backbone.Model.prototype.fetch.call(this, options);
  },

  /**
   * Prevent destroying the model.
   *
   * @param {Object} options
   * @return {jQuery.Promise}
   */
  destroy: function(options) {
    if (isNotImmutable(options, 'destroy')) {
      return Backbone.Model.prototype.clear.call(this, options);
    }
  },

  /**
   * Prevent clearing the model.
   *
   * @param {Object} options
   * @return {Backbone.Model}
   */
  clear: function(options) {
    if (isNotImmutable(options, 'clear')) {
      return Backbone.Model.prototype.clear.call(this, options);
    }
  },
});


text:
package com.datasplice.cordova.plugin.koamtac;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.util.Log;

import org.apache.cordova.*;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.lang.Override;

import koamtac.kdc.sdk.*;
import koamtac.kdc.sdk.KDCConstants;

/**
 * This class echoes a string called from JavaScript.
 */
public class KoamTacScanner extends CordovaPlugin implements
        KDCDataReceivedListener,
        KDCBarcodeDataReceivedListener,
        KDCGPSDataReceivedListener,
        KDCMSRDataReceivedListener,
        KDCNFCDataReceivedListener,
        KDCConnectionListener {

    KDCReader _kdcReader;
    CallbackContext _callbackContext;
    BluetoothAdapter mBluetoothAdapter;

    private static final String TAG = KoamTacScanner.class.getCanonicalName();

    private static enum CMD {
        enable, disable
    }

    @Override
    public void initialize(CordovaInterface cordova, CordovaWebView webView) {
        super.initialize(cordova, webView);
        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        // If the adapter is null, then Bluetooth is not supported
        if (mBluetoothAdapter == null) {
            return;
        }

    }

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        _callbackContext = callbackContext;
        switch (CMD.valueOf(action)) {
            case enable:
                enable();
                return true;
            case disable:
                disconnect();
                return true;
        }
        return false;
    }

    // Process and send Generic data events from KDC
    @Override
    public void DataReceived( KDCData pData ) {
        String data = pData.GetData();
        Log.d(TAG, "Sending Generic Data " + data);
        sendScanData(data);
    }

    // Process and send Barcode data events from KDC
    @Override
    public void BarcodeDataReceived(KDCData pData) {
        String data = pData.GetData();
        Log.d(TAG, "Sending Barcode Data " + data);
        sendScanData(data);
    }

    // Process and send GPS data events from KDC
    @Override
    public void GPSDataReceived(KDCData pData) {
        String data = pData.GetData();
        Log.d(TAG, "Sending GPS Data " + data);
        sendScanData(data);
    }

    // Process and send Magnetic-Stripe-Reader data events from KDC
    @Override
    public void MSRDataReceived(KDCData pData) {
        String data = pData.GetData();
        Log.d(TAG, "Sending MSR Data " + data);
        sendScanData(data);
    }

    // Process and send Near-Field-Communication data events from KDC
    // Only get UID.  NFC Data can have many records, and is difficult to parse.
    // see http://www.kdc100.com/documents/manuals/How_To_Use_Your_KDC_with_NFC_or_RFID.pdf
    // maybe one day use Android NFC classes?
    @Override
    public void NFCDataReceived(KDCData pData) {
        String uid = pData.GetNFCUID();
        Log.d(TAG, "Sending NFC Data " + uid);
        sendScanData(uid);
    }

    // Handle Connection States of KDC Devices
    @Override
    public void ConnectionChanged( BluetoothDevice device, int state ) {
        switch (state) {
            case KDCConstants.CONNECTION_STATE_CONNECTED :
                sendResult(PluginResult.Status.OK, buildStatusMessage("CONNECTED"));
                break;
            case KDCConstants.CONNECTION_STATE_CONNECTING:
                sendResult(PluginResult.Status.OK, buildStatusMessage("CONNECTING"));
                break;
            case KDCConstants.CONNECTION_STATE_LOST:
                // start listening for connections again
                checkAndConnect();
                sendResult(PluginResult.Status.OK, buildStatusMessage("LOST"));
                break;
            case KDCConstants.CONNECTION_STATE_FAILED:
                sendResult(PluginResult.Status.OK, buildStatusMessage("FAILED"));
                break;
            case KDCConstants.CONNECTION_STATE_LISTEN:
                sendResult(PluginResult.Status.OK, buildStatusMessage("LISTEN"));
                break;
        }
    }

    private String buildStatusMessage(String message) {
        return "{\"status\":\""+message+"\"}";
    }

    // Send result
    private void sendResult(PluginResult pluginResult) {
        pluginResult.setKeepCallback(true);
        _callbackContext.sendPluginResult(pluginResult);
    }

    // Build PluginResult and send result
    private void sendResult(PluginResult.Status status, String message) {
        PluginResult pluginResult = new PluginResult(status, message);
        Log.d(TAG, "Sending Result: "+message);
        sendResult(pluginResult);
    }

    // Builds scan message and pluginResult. Sends pluginResult
    private void sendScanData(String data) {
        String scanMessage = "{\"scan\":\""+data+"\"}";
        PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, scanMessage);
        sendResult(pluginResult);
    }

    // Enable KDC
    private void enable() {
        checkAndConnect();
        // put NFC scanner available, put into UID only mode.
        if (_kdcReader.IsConnected() && _kdcReader.IsNFCSupported()) {
          _kdcReader.SetNFCDataFormat(KDCConstants.NFCDataFormat.PACKET_FORMAT);
          _kdcReader.EnableNFCUIDOnly(true);
        }
        if (_kdcReader.IsConnected() ) {
          _kdcReader.EnableBluetoothAutoConnect(true);
          _kdcReader.EnableAutoReconnect(true);
          sendResult(PluginResult.Status.OK, buildStatusMessage("success"));
        }
    }

    // Check Bluetooth and Connect to existing device or first available device
    private void checkAndConnect() {
        if(!mBluetoothAdapter.isEnabled()) {
            Log.d(TAG, "Bluetooth Adapter disabled.  Prompting to enable");
            // bluetooth not enabled.  prompt user to enable it
            Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            cordova.startActivityForResult(this, enableIntent, 1775); // 1775 = REQUEST_CODE_ENABLE_BT;
        } else if (_kdcReader == null) {
            Log.d(TAG, "Attempting to connect to first available KDC");
            // bluetooth OK, connect to first available device.
            _kdcReader = new KDCReader(null, this, this, this, this, this, this, false);
        } else if (!_kdcReader.IsConnected()) {
            Log.d(TAG, "Attempting to re-connect existing KDC");
            // reconnect to existing device
            _kdcReader = new KDCReader(this, this, this, this, this, this, false);
        } else {
            Log.d(TAG, "Using existing connected KDC");
        }
    }

    // Disconnect KDC device from application
    private void disconnect() {
        PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, buildStatusMessage("DISCONNECTED"));
        if (_kdcReader != null) {
          _kdcReader.Disconnect();
          // clean up the kdcReader, we'll create new if necessary
          _kdcReader = null;
          _callbackContext.sendPluginResult(pluginResult);
        }
    }

    @Override
    public void onResume(boolean multitasking) {
        super.onResume(multitasking);
        Log.d(TAG, "onResume");
        checkAndConnect();
        if (_kdcReader.IsConnected()) {
          _kdcReader.EnableBluetoothAutoConnect(true);
          _kdcReader.EnableAutoReconnect(true);
        }
    }

    @Override
    public void onPause(boolean multitasking) {
        super.onPause(multitasking);
        Log.d(TAG, "onPause");
        if (_kdcReader.IsConnected()) {
          // turn these off so the KDC doesn't lose its mind
          _kdcReader.EnableBluetoothAutoConnect(false);
          _kdcReader.EnableAutoReconnect(false);
        }
    }

    /**
     * Called when the WebView does a top-level navigation or refreshes.
     * Plugins should stop any long-running processes and clean up internal state.
     */
    @Override
    public void onReset() {
        super.onReset();
        Log.d(TAG, "onReset");
        disconnect();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.d(TAG, "onDestroy");
        disconnect();
    }
}


text:
package platform

import (
	"archive/tar"
	"os"
)

// We implement this call for Unix/Linux/Mac in nix.go.
// Windows does not implement the syscall.Stat_t type we
// need, and our partners may be using Windows. The partners
// won't be doing any tarring with the partner tools, so we
// make this a no-op.
func GetOwnerAndGroup(finfo os.FileInfo, header *tar.Header) {
	return
}

// A late addition. Allows us to build apt_validate on all platforms.
func FileOwnerAndGroup(finfo os.FileInfo) (uid int, gid int) {
	return uid, gid // will be 0,0
}

// Don't even try. This function is for use with the VolumeService,
// which we're not going to run on Windows.
func GetMountPointFromPath(path string) (string, error) {
	return path, nil
}


text:
die() {
    echo "$@"
    exit
}

echo "Bootstrapping autotools..."

echo "aclocal..."
aclocal -I project || die "aclocal failed"
echo "libtoolize..."
libtoolize --force || die "libtoolize failed"
echo "autoheader..."
autoheader || die "autoheader failed"
echo "automake..."
automake --foreign --add-missing --copy || die "automake failed"
echo "autoconf..."
autoconf || die "autoconf failed"

echo "Done."