text:
package apiserver

import (
	"fmt"

	"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
)

// getSchemaForVersion returns the validation schema for given version in given CRD.
func getSchemaForVersion(crd *apiextensions.CustomResourceDefinition, version string) (*apiextensions.CustomResourceValidation, error) {
	if !hasPerVersionSchema(crd.Spec.Versions) {
		return crd.Spec.Validation, nil
	}
	if crd.Spec.Validation != nil {
		return nil, fmt.Errorf("malformed CustomResourceDefinition %s version %s: top-level and per-version schemas must be mutual exclusive", crd.Name, version)
	}
	for _, v := range crd.Spec.Versions {
		if version == v.Name {
			return v.Schema, nil
		}
	}
	return nil, fmt.Errorf("version %s not found in CustomResourceDefinition: %v", version, crd.Name)
}

// getSubresourcesForVersion returns the subresources for given version in given CRD.
func getSubresourcesForVersion(crd *apiextensions.CustomResourceDefinition, version string) (*apiextensions.CustomResourceSubresources, error) {
	if !hasPerVersionSubresources(crd.Spec.Versions) {
		return crd.Spec.Subresources, nil
	}
	if crd.Spec.Subresources != nil {
		return nil, fmt.Errorf("malformed CustomResourceDefinition %s version %s: top-level and per-version subresources must be mutual exclusive", crd.Name, version)
	}
	for _, v := range crd.Spec.Versions {
		if version == v.Name {
			return v.Subresources, nil
		}
	}
	return nil, fmt.Errorf("version %s not found in CustomResourceDefinition: %v", version, crd.Name)
}

// getColumnsForVersion returns the columns for given version in given CRD.
// NOTE: the newly logically-defaulted columns is not pointing to the original CRD object.
// One cannot mutate the original CRD columns using the logically-defaulted columns. Please iterate through
// the original CRD object instead.
func getColumnsForVersion(crd *apiextensions.CustomResourceDefinition, version string) ([]apiextensions.CustomResourceColumnDefinition, error) {
	if !hasPerVersionColumns(crd.Spec.Versions) {
		return serveDefaultColumnsIfEmpty(crd.Spec.AdditionalPrinterColumns), nil
	}
	if len(crd.Spec.AdditionalPrinterColumns) > 0 {
		return nil, fmt.Errorf("malformed CustomResourceDefinition %s version %s: top-level and per-version additionalPrinterColumns must be mutual exclusive", crd.Name, version)
	}
	for _, v := range crd.Spec.Versions {
		if version == v.Name {
			return serveDefaultColumnsIfEmpty(v.AdditionalPrinterColumns), nil
		}
	}
	return nil, fmt.Errorf("version %s not found in CustomResourceDefinition: %v", version, crd.Name)
}

// serveDefaultColumnsIfEmpty applies logically defaulting to columns, if the input columns is empty.
// NOTE: in this way, the newly logically-defaulted columns is not pointing to the original CRD object.
// One cannot mutate the original CRD columns using the logically-defaulted columns. Please iterate through
// the original CRD object instead.
func serveDefaultColumnsIfEmpty(columns []apiextensions.CustomResourceColumnDefinition) []apiextensions.CustomResourceColumnDefinition {
	if len(columns) > 0 {
		return columns
	}
	return []apiextensions.CustomResourceColumnDefinition{
		{Name: "Age", Type: "date", Description: swaggerMetadataDescriptions["creationTimestamp"], JSONPath: ".metadata.creationTimestamp"},
	}
}

// hasPerVersionSchema returns true if a CRD uses per-version schema.
func hasPerVersionSchema(versions []apiextensions.CustomResourceDefinitionVersion) bool {
	for _, v := range versions {
		if v.Schema != nil {
			return true
		}
	}
	return false
}

// hasPerVersionSubresources returns true if a CRD uses per-version subresources.
func hasPerVersionSubresources(versions []apiextensions.CustomResourceDefinitionVersion) bool {
	for _, v := range versions {
		if v.Subresources != nil {
			return true
		}
	}
	return false
}

// hasPerVersionColumns returns true if a CRD uses per-version columns.
func hasPerVersionColumns(versions []apiextensions.CustomResourceDefinitionVersion) bool {
	for _, v := range versions {
		if len(v.AdditionalPrinterColumns) > 0 {
			return true
		}
	}
	return false
}


text:
import unittest
import numpy.testing as testing
import numpy as np
import fitsio
from numpy import random

from redmapper import Cluster
from redmapper import Configuration
from redmapper import GalaxyCatalog
from redmapper import Background
from redmapper import RedSequenceColorPar
from redmapper import HPMask
from redmapper import DepthMap
from redmapper import Zlambda
from redmapper import ZlambdaCorrectionPar

class ZlambdaTestCase(unittest.TestCase):
    """
    Tests of redmapper.Zlambda z_lambda computation code.
    """
    def runTest(self):
        """
        Run tests on redmapper.Zlambda
        """
        random.seed(seed=12345)

        file_path = 'data_for_tests'

        conf_filename = 'testconfig.yaml'
        config = Configuration(file_path + '/' + conf_filename)

        filename = 'test_cluster_members.fit'
        neighbors = GalaxyCatalog.from_fits_file(file_path + '/' + filename)

        zred_filename = 'test_dr8_pars.fit'
        zredstr = RedSequenceColorPar(file_path + '/' + zred_filename,fine = True)

        bkg_filename = 'test_bkg.fit'
        bkg = Background('%s/%s' % (file_path, bkg_filename))

        cluster = Cluster(config=config, zredstr=zredstr, bkg=bkg, neighbors=neighbors)

        hdr=fitsio.read_header(file_path+'/'+filename,ext=1)
        cluster.redshift = hdr['Z']
        richness_compare = hdr['LAMBDA']
        richness_compare_err = hdr['LAMBDA_E']
        cluster.ra = hdr['RA']
        cluster.dec = hdr['DEC']

        #Set up the mask
        mask = HPMask(cluster.config) #Create the mask
        maskgal_index = mask.select_maskgals_sample(maskgal_index=0)
        mask.set_radmask(cluster)

        #depthstr
        depthstr = DepthMap(cluster.config)
        depthstr.calc_maskdepth(mask.maskgals, cluster.ra, cluster.dec, cluster.mpc_scale)

        cluster.neighbors.dist = np.degrees(cluster.neighbors.r/cluster.cosmo.Dl(0,cluster.redshift))

        # make a zlambda object
        zlam = Zlambda(cluster)

        z_lambda, z_lambda_e = zlam.calc_zlambda(cluster.redshift, mask, calc_err=True, calcpz=True)

        # I am not sure why this isn't repeatable better than this
        testing.assert_almost_equal(cluster.z_lambda, 0.22666427, 6)
        testing.assert_almost_equal(cluster.z_lambda_err, 0.00443601, 4)

        # zlambda_err test
        z_lambda_err = zlam._zlambda_calc_gaussian_err(cluster.z_lambda)

        testing.assert_almost_equal(z_lambda_err, 0.0063738347, 5)

        # and test the correction on its own
        corr_filename = 'test_dr8_zlambdacorr.fit'

        zlambda_corr = ZlambdaCorrectionPar(file_path + '/' + corr_filename, zlambda_pivot=30.0)

        zlam_in = 0.227865
        zlam_e_in = 0.00629995
        zlam_out = 0.228654
        zlam_e_out = 0.00840213

        zlam_new, zlam_e_new = zlambda_corr.apply_correction(24.5, zlam_in, zlam_e_in)

        testing.assert_almost_equal(zlam_new, zlam_out, 5)
        testing.assert_almost_equal(zlam_e_new, zlam_e_out, 5)

if __name__=='__main__':
    unittest.main()

redpajama_set_name: RedPajamaGithub


text:
package org.sisioh.aws4s.sqs.model

import com.amazonaws.services.sqs.model.CreateQueueRequest
import org.sisioh.aws4s.PimpedType

import scala.collection.JavaConverters._

object CreateQueueRequestFactory {

  def create(): CreateQueueRequest = new CreateQueueRequest()

  def create(queueName: String): CreateQueueRequest =
    new CreateQueueRequest(queueName)

}

class RichCreateQueueRequest(val underlying: CreateQueueRequest) extends AnyVal with PimpedType[CreateQueueRequest] {

  def queueNameOpt: Option[String] = Option(underlying.getQueueName)

  def queueNameOpt_=(value: Option[String]): Unit =
    underlying.setQueueName(value.orNull)

  def withQueueNameOpt(value: Option[String]): CreateQueueRequest =
    underlying.withQueueName(value.orNull)

  // ---

  def attributes: Map[String, String] = underlying.getAttributes.asScala.toMap

  def attributes_=(value: Map[String, String]): Unit =
    underlying.setAttributes(value.asJava)

  def withAttributes(value: Map[String, String]): CreateQueueRequest =
    underlying.withAttributes(value.asJava)
}


text:
@interface DemoSecondViewController ()

@property (nonatomic, strong) DemoModalViewController *firstStrongReference;

@end

@implementation DemoSecondViewController

- (void)dealloc {
    NSLog(@"SecondViewController Dealloc");
    //SecondViewController will never release...Because circular reference.
    //You see, self refer self.firstStrongReference & self.firstStrongReference.strongReference refer self
    //The best way to solve this problem is make self.firstStrongReference.strongReference weak.
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"Second";
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)handlePresentModalViewControllerButtonTapped:(id)sender {
    self.firstStrongReference = [[DemoModalViewController alloc] initWithNibName:nil bundle:nil];
    self.firstStrongReference.strongReference = self;
    [self presentViewController:self.firstStrongReference animated:YES completion:^{

    }];
}

@end


text:
package org.vasttrafik.wso2.carbon.identity.api;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.ServerErrorException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.vasttrafik.wso2.carbon.common.api.beans.AuthenticatedUser;
import org.vasttrafik.wso2.carbon.common.api.beans.Credentials;
import org.vasttrafik.wso2.carbon.common.api.utils.ResponseUtils;
import org.vasttrafik.wso2.carbon.identity.api.utils.UserAdminUtils;
import org.vasttrafik.wso2.carbon.identity.oauth.authcontext.JWTToken;
import org.vasttrafik.wso2.carbon.identity.oauth.authcontext.JWTTokenGenerator;

@Path("/authenticate")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public final class Authenticate {

	private static JWTTokenGenerator tokenGenerator = new JWTTokenGenerator();

	@POST
    public Response postAuthenticate(
    		@NotNull(message= "{credentials.notnull}") @Valid final Credentials credentials)
    	throws ServerErrorException
    {
		try {
			// Get username
			String userName = credentials.getUserName();

			if ("admin".equalsIgnoreCase(userName)) {
				return Response.status(Response.Status.FORBIDDEN).build();
			}

			// Authenticate the user
		    UserAdminUtils.authenticateCredentials(userName, credentials.getCredential());

			// Generate a token
			JWTToken jwtToken = tokenGenerator.generateToken(userName);
			// Create the response object
			AuthenticatedUser authenticatedUser = new AuthenticatedUser(jwtToken);

			// Create the response object
			return Response.status(201).entity(authenticatedUser).build();
		}
		catch(NotAuthorizedException | InternalServerErrorException ie) {
			return Response.status(Response.Status.UNAUTHORIZED)
				.entity(ie.getCause())
				.build();
		}
		catch (Exception e) {
			Response response = ResponseUtils.serverError(e);
			throw new ServerErrorException(response);
		}
    }

}


text:
/**
 * Definition for singly-linked list.
 * class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) {
 *         val = x;
 *         next = null;
 *     }
 * }
 */
public class LinkedListCycleII {
    public ListNode detectCycle(ListNode head) {
        if (head == null) return null;

        ListNode fast = head;
        ListNode slow = head;
        while (fast != null && fast.next != null) {
            fast = fast.next.next;
            slow = slow.next;
            if (fast == slow) {
                break;
            }
        }

        if (fast == null || fast.next == null) return null;

        slow = head;
        while (fast != slow) {
            fast = fast.next;
            slow = slow.next;
        }

        return fast;
    }
}


text:
package org.springframework.cloud.netflix.feign.encoding;

import org.springframework.cloud.netflix.feign.encoding.app.domain.Invoice;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/**
 * Utility class used for testing.
 *
 * @author Jakub Narloch
 */
final class Invoices {

    public static List<Invoice> createInvoiceList(int count) {
        final List<Invoice> invoices = new ArrayList<>();
        for (int ind = 0; ind < count; ind++) {
            final Invoice invoice = new Invoice();
            invoice.setTitle("Invoice " + (ind + 1));
            invoice.setAmount(new BigDecimal(String.format(Locale.US, "%.2f", Math.random() * 1000)));
            invoices.add(invoice);
        }
        return invoices;
    }
}


text:
package com.peacecraftec.bukkit.perms.vault;

import com.peacecraftec.bukkit.perms.core.PermissionGroup;
import com.peacecraftec.bukkit.perms.core.PermissionManager;
import com.peacecraftec.bukkit.perms.core.PermissionPlayer;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;

public class PeaceChatVault extends Chat {
    private PermissionManager manager;

    public PeaceChatVault(Object perms, PermissionManager manager) {
        super((Permission) perms);
        this.manager = manager;
    }

    @Override
    public String getName() {
        return "PeacecraftPerms";
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    @Override
    public boolean getGroupInfoBoolean(String world, String group, String node, boolean def) {
        PermissionGroup g = this.manager.getWorld(world).getGroup(group);
        if(g == null) {
            return false;
        }

        return g.getInfoBoolean(node, def);
    }

    @Override
    public double getGroupInfoDouble(String world, String group, String node, double def) {
        PermissionGroup g = this.manager.getWorld(world).getGroup(group);
        if(g == null) {
            return 0;
        }

        return g.getInfoDouble(node, def);
    }

    @Override
    public int getGroupInfoInteger(String world, String group, String node, int def) {
        PermissionGroup g = this.manager.getWorld(world).getGroup(group);
        if(g == null) {
            return 0;
        }

        return g.getInfoInt(node, def);
    }

    @Override
    public String getGroupInfoString(String world, String group, String node, String def) {
        PermissionGroup g = this.manager.getWorld(world).getGroup(group);
        if(g == null) {
            return null;
        }

        return g.getInfoString(node, def);
    }

    @Override
    public String getGroupPrefix(String world, String group) {
        PermissionGroup g = this.manager.getWorld(world).getGroup(group);
        if(g == null) {
            return null;
        }

        return g.getPrefix();
    }

    @Override
    public String getGroupSuffix(String world, String group) {
        PermissionGroup g = this.manager.getWorld(world).getGroup(group);
        if(g == null) {
            return null;
        }

        return g.getSuffix();
    }

    @Override
    public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
        PermissionGroup g = this.manager.getWorld(world).getGroup(group);
        if(g == null) {
            return;
        }

        g.setInfoBoolean(node, value);
    }

    @Override
    public void setGroupInfoDouble(String world, String group, String node, double value) {
        PermissionGroup g = this.manager.getWorld(world).getGroup(group);
        if(g == null) {
            return;
        }

        g.setInfoDouble(node, value);
    }

    @Override
    public void setGroupInfoInteger(String world, String group, String node, int value) {
        PermissionGroup g = this.manager.getWorld(world).getGroup(group);
        if(g == null) {
            return;
        }

        g.setInfoInteger(node, value);
    }

    @Override
    public void setGroupInfoString(String world, String group, String node, String value) {
        PermissionGroup g = this.manager.getWorld(world).getGroup(group);
        if(g == null) {
            return;
        }

        g.setInfoString(node, value);
    }

    @Override
    public void setGroupPrefix(String world, String group, String prefix) {
        PermissionGroup g = this.manager.getWorld(world).getGroup(group);
        if(g == null) {
            return;
        }

        g.setPrefix(prefix);
    }

    @Override
    public void setGroupSuffix(String world, String group, String suffix) {
        PermissionGroup g = this.manager.getWorld(world).getGroup(group);
        if(g == null) {
            return;
        }

        g.setSuffix(suffix);
    }

    @Override
    public boolean getPlayerInfoBoolean(String world, OfflinePlayer player, String node, boolean def) {
        PermissionPlayer p = this.manager.getWorld(world).getPlayer(player.getUniqueId());
        if(p == null) {
            return false;
        }

        return p.getInfoBoolean(node, def);
    }

    @Override
    public double getPlayerInfoDouble(String world, OfflinePlayer player, String node, double def) {
        PermissionPlayer p = this.manager.getWorld(world).getPlayer(player.getUniqueId());
        if(p == null) {
            return 0;
        }

        return p.getInfoDouble(node, def);
    }

    @Override
    public int getPlayerInfoInteger(String world, OfflinePlayer player, String node, int def) {
        PermissionPlayer p = this.manager.getWorld(world).getPlayer(player.getUniqueId());
        if(p == null) {
            return 0;
        }

        return p.getInfoInt(node, def);
    }

    @Override
    public String getPlayerInfoString(String world, OfflinePlayer player, String node, String def) {
        PermissionPlayer p = this.manager.getWorld(world).getPlayer(player.getUniqueId());
        if(p == null) {
            return null;
        }

        return p.getInfoString(node, def);
    }

    @Override
    public String getPlayerPrefix(String world, OfflinePlayer player) {
        PermissionPlayer p = this.manager.getWorld(world).getPlayer(player.getUniqueId());
        if(p == null) {
            return null;
        }

        return p.getPrefix();
    }

    @Override
    public String getPlayerSuffix(String world, OfflinePlayer player) {
        PermissionPlayer p = this.manager.getWorld(world).getPlayer(player.getUniqueId());
        if(p == null) {
            return null;
        }

        return p.getSuffix();
    }

    @Override
    public void setPlayerInfoBoolean(String world, OfflinePlayer player, String node, boolean value) {
        PermissionPlayer p = this.manager.getWorld(world).getPlayer(player.getUniqueId());
        if(p == null) {
            return;
        }

        p.setInfo(node, value);
    }

    @Override
    public void setPlayerInfoDouble(String world, OfflinePlayer player, String node, double value) {
        PermissionPlayer p = this.manager.getWorld(world).getPlayer(player.getUniqueId());
        if(p == null) {
            return;
        }

        p.setInfo(node, value);
    }

    @Override
    public void setPlayerInfoInteger(String world, OfflinePlayer player, String node, int value) {
        PermissionPlayer p = this.manager.getWorld(world).getPlayer(player.getUniqueId());
        if(p == null) {
            return;
        }

        p.setInfo(node, value);
    }

    @Override
    public void setPlayerInfoString(String world, OfflinePlayer player, String node, String value) {
        PermissionPlayer p = this.manager.getWorld(world).getPlayer(player.getUniqueId());
        if(p == null) {
            return;
        }

        p.setInfo(node, value);
    }

    @Override
    public void setPlayerPrefix(String world, OfflinePlayer player, String prefix) {
        PermissionPlayer p = this.manager.getWorld(world).getPlayer(player.getUniqueId());
        if(p == null) {
            return;
        }

        p.setPrefix(prefix);
    }

    @Override
    public void setPlayerSuffix(String world, OfflinePlayer player, String suffix) {
        PermissionPlayer p = this.manager.getWorld(world).getPlayer(player.getUniqueId());
        if(p == null) {
            return;
        }

        p.setSuffix(suffix);
    }

    @Override
    public String getPlayerPrefix(String world, String player) {
        return this.getPlayerPrefix(world, Bukkit.getOfflinePlayer(player));
    }

    @Override
    public void setPlayerPrefix(String world, String player, String prefix) {
        this.setPlayerPrefix(world, Bukkit.getOfflinePlayer(player), prefix);
    }

    @Override
    public String getPlayerSuffix(String world, String player) {
        return this.getPlayerSuffix(world, Bukkit.getOfflinePlayer(player));
    }

    @Override
    public void setPlayerSuffix(String world, String player, String suffix) {
        this.setPlayerSuffix(world, Bukkit.getOfflinePlayer(player), suffix);
    }

    @Override
    public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
        return this.getPlayerInfoInteger(world, Bukkit.getOfflinePlayer(player), node, defaultValue);
    }

    @Override
    public void setPlayerInfoInteger(String world, String player, String node, int value) {
        this.setPlayerInfoInteger(world, Bukkit.getOfflinePlayer(player), node, value);
    }

    @Override
    public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
        return this.getPlayerInfoDouble(world, Bukkit.getOfflinePlayer(player), node, defaultValue);
    }

    @Override
    public void setPlayerInfoDouble(String world, String player, String node, double value) {
        this.setPlayerInfoDouble(world, Bukkit.getOfflinePlayer(player), node, value);
    }

    @Override
    public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
        return this.getPlayerInfoBoolean(world, Bukkit.getOfflinePlayer(player), node, defaultValue);
    }

    @Override
    public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
        this.setPlayerInfoBoolean(world, Bukkit.getOfflinePlayer(player), node, value);
    }

    @Override
    public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
        return this.getPlayerInfoString(world, Bukkit.getOfflinePlayer(player), node, defaultValue);
    }

    @Override
    public void setPlayerInfoString(String world, String player, String node, String value) {
        this.setPlayerInfoString(world, Bukkit.getOfflinePlayer(player), node, value);
    }
}


text:
import { onUnexpectedError } from 'vs/base/common/errors';
import { OS } from 'vs/base/common/platform';
import { URI } from 'vs/base/common/uri';
import { TokenizationRegistry } from 'vs/editor/common/modes';
import { generateTokensCSSForColorMap } from 'vs/editor/common/modes/supports/tokenization';
import { IModeService } from 'vs/editor/common/services/modeService';
import * as nls from 'vs/nls';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IRequestService, asText } from 'vs/platform/request/common/request';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IProductService } from 'vs/platform/product/common/productService';
import { IWebviewWorkbenchService } from 'vs/workbench/contrib/webview/browser/webviewWorkbenchService';
import { IEditorService, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { WebviewInput } from 'vs/workbench/contrib/webview/browser/webviewEditorInput';
import { KeybindingParser } from 'vs/base/common/keybindingParser';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { generateUuid } from 'vs/base/common/uuid';
import { renderMarkdownDocument } from 'vs/workbench/contrib/markdown/common/markdownDocumentRenderer';

export class ReleaseNotesManager {

	private readonly _releaseNotesCache = new Map<string, Promise<string>>();

	private _currentReleaseNotes: WebviewInput | undefined = undefined;
	private _lastText: string | undefined;

	public constructor(
		@IEnvironmentService private readonly _environmentService: IEnvironmentService,
		@IKeybindingService private readonly _keybindingService: IKeybindingService,
		@IModeService private readonly _modeService: IModeService,
		@IOpenerService private readonly _openerService: IOpenerService,
		@IRequestService private readonly _requestService: IRequestService,
		@ITelemetryService private readonly _telemetryService: ITelemetryService,
		@IEditorService private readonly _editorService: IEditorService,
		@IEditorGroupsService private readonly _editorGroupService: IEditorGroupsService,
		@IWebviewWorkbenchService private readonly _webviewWorkbenchService: IWebviewWorkbenchService,
		@IExtensionService private readonly _extensionService: IExtensionService,
		@IProductService private readonly _productService: IProductService
	) {
		TokenizationRegistry.onDidChange(async () => {
			if (!this._currentReleaseNotes || !this._lastText) {
				return;
			}
			const html = await this.renderBody(this._lastText);
			if (this._currentReleaseNotes) {
				this._currentReleaseNotes.webview.html = html;
			}
		});
	}

	public async show(
		accessor: ServicesAccessor,
		version: string
	): Promise<boolean> {
		const releaseNoteText = await this.loadReleaseNotes(version);
		this._lastText = releaseNoteText;
		const html = await this.renderBody(releaseNoteText);
		const title = nls.localize('releaseNotesInputName', "Release Notes: {0}", version);

		const activeEditorPane = this._editorService.activeEditorPane;
		if (this._currentReleaseNotes) {
			this._currentReleaseNotes.setName(title);
			this._currentReleaseNotes.webview.html = html;
			this._webviewWorkbenchService.revealWebview(this._currentReleaseNotes, activeEditorPane ? activeEditorPane.group : this._editorGroupService.activeGroup, false);
		} else {
			this._currentReleaseNotes = this._webviewWorkbenchService.createWebview(
				generateUuid(),
				'releaseNotes',
				title,
				{ group: ACTIVE_GROUP, preserveFocus: false },
				{
					tryRestoreScrollPosition: true,
					enableFindWidget: true,
					localResourceRoots: []
				},
				undefined);

			this._currentReleaseNotes.webview.onDidClickLink(uri => this.onDidClickLink(URI.parse(uri)));
			this._currentReleaseNotes.onDispose(() => { this._currentReleaseNotes = undefined; });

			const iconPath = URI.parse(require.toUrl('./media/code-icon.svg'));
			this._currentReleaseNotes.iconPath = {
				light: iconPath,
				dark: iconPath
			};
			this._currentReleaseNotes.webview.html = html;
		}

		return true;
	}

	private loadReleaseNotes(version: string): Promise<string> {
		const match = /^(\d+\.\d+)\./.exec(version);
		if (!match) {
			return Promise.reject(new Error('not found'));
		}

		const versionLabel = match[1].replace(/\./g, '_');
		const baseUrl = 'https://code.visualstudio.com/raw';
		const url = `${baseUrl}/v${versionLabel}.md`;
		const unassigned = nls.localize('unassigned', "unassigned");

		const patchKeybindings = (text: string): string => {
			const kb = (match: string, kb: string) => {
				const keybinding = this._keybindingService.lookupKeybinding(kb);

				if (!keybinding) {
					return unassigned;
				}

				return keybinding.getLabel() || unassigned;
			};

			const kbstyle = (match: string, kb: string) => {
				const keybinding = KeybindingParser.parseKeybinding(kb, OS);

				if (!keybinding) {
					return unassigned;
				}

				const resolvedKeybindings = this._keybindingService.resolveKeybinding(keybinding);

				if (resolvedKeybindings.length === 0) {
					return unassigned;
				}

				return resolvedKeybindings[0].getLabel() || unassigned;
			};

			return text
				.replace(/kb\(([a-z.\d\-]+)\)/gi, kb)
				.replace(/kbstyle\(([^\)]+)\)/gi, kbstyle);
		};

		if (!this._releaseNotesCache.has(version)) {
			this._releaseNotesCache.set(version, this._requestService.request({ url }, CancellationToken.None)
				.then(asText)
				.then(text => {
					if (!text || !/^#\s/.test(text)) { // release notes always starts with `#` followed by whitespace
						return Promise.reject(new Error('Invalid release notes'));
					}

					return Promise.resolve(text);
				})
				.then(text => patchKeybindings(text)));
		}

		return this._releaseNotesCache.get(version)!;
	}

	private onDidClickLink(uri: URI) {
		this.addGAParameters(uri, 'ReleaseNotes')
			.then(updated => this._openerService.open(updated))
			.then(undefined, onUnexpectedError);
	}

	private async  addGAParameters(uri: URI, origin: string, experiment = '1'): Promise<URI> {
		if (this._environmentService.isBuilt && !this._environmentService.isExtensionDevelopment && !this._environmentService.args['disable-telemetry'] && !!this._productService.enableTelemetry) {
			if (uri.scheme === 'https' && uri.authority === 'code.visualstudio.com') {
				const info = await this._telemetryService.getTelemetryInfo();

				return uri.with({ query: `${uri.query ? uri.query + '&' : ''}utm_source=VsCode&utm_medium=${encodeURIComponent(origin)}&utm_campaign=${encodeURIComponent(info.instanceId)}&utm_content=${encodeURIComponent(experiment)}` });
			}
		}
		return uri;
	}

	private async renderBody(text: string) {
		const nonce = generateUuid();
		const content = await renderMarkdownDocument(text, this._extensionService, this._modeService);
		const colorMap = TokenizationRegistry.getColorMap();
		const css = colorMap ? generateTokensCSSForColorMap(colorMap) : '';
		return `<!DOCTYPE html>
		<html>
			<head>
				<base href="https://code.visualstudio.com/raw/">
				<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
				<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src https: data:; media-src https:; style-src 'nonce-${nonce}' https://code.visualstudio.com;">
				<style nonce="${nonce}">
					body {
						padding: 10px 20px;
						line-height: 22px;
						max-width: 882px;
						margin: 0 auto;
					}

					img {
						max-width: 100%;
						max-height: 100%;
					}

					a {
						text-decoration: none;
					}

					a:hover {
						text-decoration: underline;
					}

					a:focus,
					input:focus,
					select:focus,
					textarea:focus {
						outline: 1px solid -webkit-focus-ring-color;
						outline-offset: -1px;
					}

					hr {
						border: 0;
						height: 2px;
						border-bottom: 2px solid;
					}

					h1 {
						padding-bottom: 0.3em;
						line-height: 1.2;
						border-bottom-width: 1px;
						border-bottom-style: solid;
					}

					h1, h2, h3 {
						font-weight: normal;
					}

					table {
						border-collapse: collapse;
					}

					table > thead > tr > th {
						text-align: left;
						border-bottom: 1px solid;
					}

					table > thead > tr > th,
					table > thead > tr > td,
					table > tbody > tr > th,
					table > tbody > tr > td {
						padding: 5px 10px;
					}

					table > tbody > tr + tr > td {
						border-top-width: 1px;
						border-top-style: solid;
					}

					blockquote {
						margin: 0 7px 0 5px;
						padding: 0 16px 0 10px;
						border-left-width: 5px;
						border-left-style: solid;
					}

					code {
						font-family: Menlo, Monaco, Consolas, "Droid Sans Mono", "Courier New", monospace, "Droid Sans Fallback";
						font-size: 14px;
						line-height: 19px;
					}

					code > div {
						padding: 16px;
						border-radius: 3px;
						overflow: auto;
					}

					.monaco-tokenized-source {
						white-space: pre;
					}

					/** Theming */

					.vscode-light code > div {
						background-color: rgba(220, 220, 220, 0.4);
					}

					.vscode-dark code > div {
						background-color: rgba(10, 10, 10, 0.4);
					}

					.vscode-high-contrast code > div {
						background-color: rgb(0, 0, 0);
					}

					.vscode-high-contrast h1 {
						border-color: rgb(0, 0, 0);
					}

					.vscode-light table > thead > tr > th {
						border-color: rgba(0, 0, 0, 0.69);
					}

					.vscode-dark table > thead > tr > th {
						border-color: rgba(255, 255, 255, 0.69);
					}

					.vscode-light h1,
					.vscode-light hr,
					.vscode-light table > tbody > tr + tr > td {
						border-color: rgba(0, 0, 0, 0.18);
					}

					.vscode-dark h1,
					.vscode-dark hr,
					.vscode-dark table > tbody > tr + tr > td {
						border-color: rgba(255, 255, 255, 0.18);
					}

					${css}
				</style>
			</head>
			<body>${content}</body>
		</html>`;
	}
}


text:
using System;
using System.IO;
using DiscUtils.Streams;

namespace DiscUtils.LogicalDiskManager
{
    internal class DynamicVolume
    {
        private readonly DynamicDiskGroup _group;

        internal DynamicVolume(DynamicDiskGroup group, Guid volumeId)
        {
            _group = group;
            Identity = volumeId;
        }

        public byte BiosType
        {
            get { return Record.BiosType; }
        }

        public Guid Identity { get; }

        public long Length
        {
            get { return Record.Size * Sizes.Sector; }
        }

        private VolumeRecord Record
        {
            get { return _group.GetVolume(Identity); }
        }

        public LogicalVolumeStatus Status
        {
            get { return _group.GetVolumeStatus(Record.Id); }
        }

        public SparseStream Open()
        {
            if (Status == LogicalVolumeStatus.Failed)
            {
                throw new IOException("Attempt to open 'failed' volume");
            }
            return _group.OpenVolume(Record.Id);
        }
    }
}


text:
package org.apache.spark.sql.connector.expressions.aggregate;

import org.apache.spark.annotation.Evolving;
import org.apache.spark.sql.connector.expressions.Expression;
import org.apache.spark.sql.internal.connector.ExpressionWithToString;

/**
 * An aggregate function that returns the summation of all the values in a group.
 *
 * @since 3.2.0
 */
@Evolving
public final class Sum extends ExpressionWithToString implements AggregateFunc {
  private final Expression input;
  private final boolean isDistinct;

  public Sum(Expression column, boolean isDistinct) {
    this.input = column;
    this.isDistinct = isDistinct;
  }

  public Expression column() { return input; }
  public boolean isDistinct() { return isDistinct; }

  @Override
  public Expression[] children() { return new Expression[]{ input }; }
}


text:
    <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" />
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5" />
    <title>FieldsReader Class</title>
    <xml>
    </xml>
    <link rel="stylesheet" type="text/css" href="MSDN.css" />

            Apache Lucene.Net 2.4.0 Class Library API

FieldsReader Class

 Class responsible for access to stored document fields.

 It uses <segment>.fdt and <segment>.fdx; files.
For a list of all members of this type, see FieldsReader Members.

System.Object
   Lucene.Net.Index.FieldsReader

public sealed class FieldsReader

Thread Safety

Public static (Shared in Visual Basic) members of this type are
				safe for multithreaded operations. Instance members are not guaranteed to be
				thread-safe.

Requirements

Namespace: Lucene.Net.Index

Assembly: Lucene.Net (in Lucene.Net.dll)

See Also

FieldsReader Members | Lucene.Net.Index Namespace
<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e" viewastext="true" style="display: none;"><param name="Keyword" value="FieldsReader class, about FieldsReader class"></param></object>

Generated from assembly Lucene.Net [2.4.0.2]


text:
package org.bouncycastle.operator;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.bsi.BSIObjectIdentifiers;
import org.bouncycastle.asn1.cryptopro.CryptoProObjectIdentifiers;
import org.bouncycastle.asn1.eac.EACObjectIdentifiers;
import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.RSASSAPSSparams;
import org.bouncycastle.asn1.teletrust.TeleTrusTObjectIdentifiers;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
import org.bouncycastle.util.Strings;

public class DefaultSignatureAlgorithmIdentifierFinder
    implements SignatureAlgorithmIdentifierFinder
{
    private static Map algorithms = new HashMap();
    private static Set noParams = new HashSet();
    private static Map params = new HashMap();
    private static Set pkcs15RsaEncryption = new HashSet();
    private static Map digestOids = new HashMap();

    private static final ASN1ObjectIdentifier ENCRYPTION_RSA = PKCSObjectIdentifiers.rsaEncryption;
    private static final ASN1ObjectIdentifier ENCRYPTION_DSA = X9ObjectIdentifiers.id_dsa_with_sha1;
    private static final ASN1ObjectIdentifier ENCRYPTION_ECDSA = X9ObjectIdentifiers.ecdsa_with_SHA1;
    private static final ASN1ObjectIdentifier ENCRYPTION_RSA_PSS = PKCSObjectIdentifiers.id_RSASSA_PSS;
    private static final ASN1ObjectIdentifier ENCRYPTION_GOST3410 = CryptoProObjectIdentifiers.gostR3410_94;
    private static final ASN1ObjectIdentifier ENCRYPTION_ECGOST3410 = CryptoProObjectIdentifiers.gostR3410_2001;

    static
    {
        algorithms.put("MD2WITHRSAENCRYPTION", PKCSObjectIdentifiers.md2WithRSAEncryption);
        algorithms.put("MD2WITHRSA", PKCSObjectIdentifiers.md2WithRSAEncryption);
        algorithms.put("MD5WITHRSAENCRYPTION", PKCSObjectIdentifiers.md5WithRSAEncryption);
        algorithms.put("MD5WITHRSA", PKCSObjectIdentifiers.md5WithRSAEncryption);
        algorithms.put("SHA1WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha1WithRSAEncryption);
        algorithms.put("SHA1WITHRSA", PKCSObjectIdentifiers.sha1WithRSAEncryption);
        algorithms.put("SHA224WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha224WithRSAEncryption);
        algorithms.put("SHA224WITHRSA", PKCSObjectIdentifiers.sha224WithRSAEncryption);
        algorithms.put("SHA256WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha256WithRSAEncryption);
        algorithms.put("SHA256WITHRSA", PKCSObjectIdentifiers.sha256WithRSAEncryption);
        algorithms.put("SHA384WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha384WithRSAEncryption);
        algorithms.put("SHA384WITHRSA", PKCSObjectIdentifiers.sha384WithRSAEncryption);
        algorithms.put("SHA512WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha512WithRSAEncryption);
        algorithms.put("SHA512WITHRSA", PKCSObjectIdentifiers.sha512WithRSAEncryption);
        algorithms.put("SHA1WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
        algorithms.put("SHA224WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
        algorithms.put("SHA256WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
        algorithms.put("SHA384WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
        algorithms.put("SHA512WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
        algorithms.put("RIPEMD160WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd160);
        algorithms.put("RIPEMD160WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd160);
        algorithms.put("RIPEMD128WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd128);
        algorithms.put("RIPEMD128WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd128);
        algorithms.put("RIPEMD256WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd256);
        algorithms.put("RIPEMD256WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd256);
        algorithms.put("SHA1WITHDSA", X9ObjectIdentifiers.id_dsa_with_sha1);
        algorithms.put("DSAWITHSHA1", X9ObjectIdentifiers.id_dsa_with_sha1);
        algorithms.put("SHA224WITHDSA", NISTObjectIdentifiers.dsa_with_sha224);
        algorithms.put("SHA256WITHDSA", NISTObjectIdentifiers.dsa_with_sha256);
        algorithms.put("SHA384WITHDSA", NISTObjectIdentifiers.dsa_with_sha384);
        algorithms.put("SHA512WITHDSA", NISTObjectIdentifiers.dsa_with_sha512);
        algorithms.put("SHA1WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA1);
        algorithms.put("ECDSAWITHSHA1", X9ObjectIdentifiers.ecdsa_with_SHA1);
        algorithms.put("SHA224WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA224);
        algorithms.put("SHA256WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA256);
        algorithms.put("SHA384WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA384);
        algorithms.put("SHA512WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA512);
        algorithms.put("GOST3411WITHGOST3410", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
        algorithms.put("GOST3411WITHGOST3410-94", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
        algorithms.put("GOST3411WITHECGOST3410", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
        algorithms.put("GOST3411WITHECGOST3410-2001", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
        algorithms.put("GOST3411WITHGOST3410-2001", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
        algorithms.put("SHA1WITHPLAIN-ECDSA", BSIObjectIdentifiers.ecdsa_plain_SHA1);
        algorithms.put("SHA224WITHPLAIN-ECDSA", BSIObjectIdentifiers.ecdsa_plain_SHA224);
        algorithms.put("SHA256WITHPLAIN-ECDSA", BSIObjectIdentifiers.ecdsa_plain_SHA256);
        algorithms.put("SHA384WITHPLAIN-ECDSA", BSIObjectIdentifiers.ecdsa_plain_SHA384);
        algorithms.put("SHA512WITHPLAIN-ECDSA", BSIObjectIdentifiers.ecdsa_plain_SHA512);
        algorithms.put("RIPEMD160WITHPLAIN-ECDSA", BSIObjectIdentifiers.ecdsa_plain_RIPEMD160);
        algorithms.put("SHA1WITHCVC-ECDSA", EACObjectIdentifiers.id_TA_ECDSA_SHA_1);
        algorithms.put("SHA224WITHCVC-ECDSA", EACObjectIdentifiers.id_TA_ECDSA_SHA_224);
        algorithms.put("SHA256WITHCVC-ECDSA", EACObjectIdentifiers.id_TA_ECDSA_SHA_256);
        algorithms.put("SHA384WITHCVC-ECDSA", EACObjectIdentifiers.id_TA_ECDSA_SHA_384);
        algorithms.put("SHA512WITHCVC-ECDSA", EACObjectIdentifiers.id_TA_ECDSA_SHA_512);
        //
        // According to RFC 3279, the ASN.1 encoding SHALL (id-dsa-with-sha1) or MUST (ecdsa-with-SHA*) omit the parameters field.
        // The parameters field SHALL be NULL for RSA based signature algorithms.
        //
        noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA1);
        noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA224);
        noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA256);
        noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA384);
        noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA512);
        noParams.add(X9ObjectIdentifiers.id_dsa_with_sha1);
        noParams.add(NISTObjectIdentifiers.dsa_with_sha224);
        noParams.add(NISTObjectIdentifiers.dsa_with_sha256);
        noParams.add(NISTObjectIdentifiers.dsa_with_sha384);
        noParams.add(NISTObjectIdentifiers.dsa_with_sha512);

        //
        // RFC 4491
        //
        noParams.add(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
        noParams.add(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);

        //
        // PKCS 1.5 encrypted  algorithms
        //
        pkcs15RsaEncryption.add(PKCSObjectIdentifiers.sha1WithRSAEncryption);
        pkcs15RsaEncryption.add(PKCSObjectIdentifiers.sha224WithRSAEncryption);
        pkcs15RsaEncryption.add(PKCSObjectIdentifiers.sha256WithRSAEncryption);
        pkcs15RsaEncryption.add(PKCSObjectIdentifiers.sha384WithRSAEncryption);
        pkcs15RsaEncryption.add(PKCSObjectIdentifiers.sha512WithRSAEncryption);
        pkcs15RsaEncryption.add(TeleTrusTObjectIdentifiers.rsaSignatureWithripemd128);
        pkcs15RsaEncryption.add(TeleTrusTObjectIdentifiers.rsaSignatureWithripemd160);
        pkcs15RsaEncryption.add(TeleTrusTObjectIdentifiers.rsaSignatureWithripemd256);

        //
        // explicit params
        //
        AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE);
        params.put("SHA1WITHRSAANDMGF1", createPSSParams(sha1AlgId, 20));

        AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha224, DERNull.INSTANCE);
        params.put("SHA224WITHRSAANDMGF1", createPSSParams(sha224AlgId, 28));

        AlgorithmIdentifier sha256AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256, DERNull.INSTANCE);
        params.put("SHA256WITHRSAANDMGF1", createPSSParams(sha256AlgId, 32));

        AlgorithmIdentifier sha384AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha384, DERNull.INSTANCE);
        params.put("SHA384WITHRSAANDMGF1", createPSSParams(sha384AlgId, 48));

        AlgorithmIdentifier sha512AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512, DERNull.INSTANCE);
        params.put("SHA512WITHRSAANDMGF1", createPSSParams(sha512AlgId, 64));

        //
        // digests
        //
        digestOids.put(PKCSObjectIdentifiers.sha224WithRSAEncryption, NISTObjectIdentifiers.id_sha224);
        digestOids.put(PKCSObjectIdentifiers.sha256WithRSAEncryption, NISTObjectIdentifiers.id_sha256);
        digestOids.put(PKCSObjectIdentifiers.sha384WithRSAEncryption, NISTObjectIdentifiers.id_sha384);
        digestOids.put(PKCSObjectIdentifiers.sha512WithRSAEncryption, NISTObjectIdentifiers.id_sha512);
        digestOids.put(PKCSObjectIdentifiers.md2WithRSAEncryption, PKCSObjectIdentifiers.md2);
        digestOids.put(PKCSObjectIdentifiers.md4WithRSAEncryption, PKCSObjectIdentifiers.md4);
        digestOids.put(PKCSObjectIdentifiers.md5WithRSAEncryption, PKCSObjectIdentifiers.md5);
        digestOids.put(PKCSObjectIdentifiers.sha1WithRSAEncryption, OIWObjectIdentifiers.idSHA1);
        digestOids.put(TeleTrusTObjectIdentifiers.rsaSignatureWithripemd128, TeleTrusTObjectIdentifiers.ripemd128);
        digestOids.put(TeleTrusTObjectIdentifiers.rsaSignatureWithripemd160, TeleTrusTObjectIdentifiers.ripemd160);
        digestOids.put(TeleTrusTObjectIdentifiers.rsaSignatureWithripemd256, TeleTrusTObjectIdentifiers.ripemd256);
        digestOids.put(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94, CryptoProObjectIdentifiers.gostR3411);
        digestOids.put(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001, CryptoProObjectIdentifiers.gostR3411);
    }

    private static AlgorithmIdentifier generate(String signatureAlgorithm)
    {
        AlgorithmIdentifier sigAlgId;
        AlgorithmIdentifier encAlgId;
        AlgorithmIdentifier digAlgId;

        String algorithmName = Strings.toUpperCase(signatureAlgorithm);
        ASN1ObjectIdentifier sigOID = (ASN1ObjectIdentifier)algorithms.get(algorithmName);
        if (sigOID == null)
        {
            throw new IllegalArgumentException("Unknown signature type requested: " + algorithmName);
        }

        if (noParams.contains(sigOID))
        {
            sigAlgId = new AlgorithmIdentifier(sigOID);
        }
        else if (params.containsKey(algorithmName))
        {
            sigAlgId = new AlgorithmIdentifier(sigOID, (ASN1Encodable)params.get(algorithmName));
        }
        else
        {
            sigAlgId = new AlgorithmIdentifier(sigOID, DERNull.INSTANCE);
        }

        if (pkcs15RsaEncryption.contains(sigOID))
        {
            encAlgId = new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE);
        }
        else
        {
            encAlgId = sigAlgId;
        }

        if (sigAlgId.getAlgorithm().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
        {
            digAlgId = ((RSASSAPSSparams)sigAlgId.getParameters()).getHashAlgorithm();
        }
        else
        {
            digAlgId = new AlgorithmIdentifier((ASN1ObjectIdentifier)digestOids.get(sigOID), DERNull.INSTANCE);
        }

        return sigAlgId;
    }

    private static RSASSAPSSparams createPSSParams(AlgorithmIdentifier hashAlgId, int saltSize)
    {
        return new RSASSAPSSparams(
            hashAlgId,
            new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, hashAlgId),
            new ASN1Integer(saltSize),
            new ASN1Integer(1));
    }

    public AlgorithmIdentifier find(String sigAlgName)
    {
        return generate(sigAlgName);
    }
}


text:
import styles from './JobCard.less';

import React, { memo, useState } from 'react';
import classnames from 'classnames';

import Text from '../Text/Text';
import Hidden from '../Hidden/Hidden';
import Icon from '../Icon/Icon';
import Button from '../Button/Button';
import LocationGroup from './components/LocationGroup/LocationGroup';
import CompanyLink from './components/CompanyLink/CompanyLink';
import JobTitleLink from './components/JobTitleLink/JobTitleLink';
import IconList from './components/IconList/IconList';
import ShelfSection from './components/ShelfSection/ShelfSection';
import CompanyBanner from './components/CompanyBanner/CompanyBanner';
import JobMeta from './components/JobMeta/JobMeta';
import {
  JobCardPropTypes,
  JobType,
  CompanyPropTypes
} from './JobCardPropTypes';
import PropTypes from 'prop-types';
import _get from 'lodash/get';
import { StyleGuideContext } from '../StyleGuideProvider/StyleGuideProvider';
import JobLabel from '../JobLabel/JobLabel';

export const trackLinkType = {
  jobTitle: 'jobTitle',
  location: 'location',
  company: 'company'
};

const JobTitle = ({
  TitleLinkComponent,
  viewed,
  keyword,
  job,
  trackLinkClicked,
  showSavedStatus
}) => {
  return (

      <JobTitleLink
        LinkComponent={TitleLinkComponent}
        viewed={viewed}
        trackLinkClicked={trackLinkClicked}
        keyword={keyword}
        job={job}
      />

  );
};

JobTitle.propTypes = {
  TitleLinkComponent: PropTypes.func,
  viewed: JobCardPropTypes.viewed,
  keyword: JobCardPropTypes.keyword,
  job: JobCardPropTypes.job,
  trackLinkClicked: JobCardPropTypes.trackLinkClicked,
  showSavedStatus: JobCardPropTypes.showSavedStatus
};

const Company = ({ company, keyword, LinkComponent, trackLinkClicked }) => {
  return (
    <Text
      intimate
      baseline={false}
      className={classnames(styles.text, styles.section)}>
      {company.isPrivate ? (
        {company.name}
      ) : (
        <CompanyLink
          {...company}
          keyword={keyword}
          LinkComponent={LinkComponent}
          trackLinkClicked={trackLinkClicked}
        />
      )}
    </Text>
  );
};
Company.propTypes = {
  company: PropTypes.shape(CompanyPropTypes).isRequired,
  keyword: JobCardPropTypes.keyword,
  LinkComponent: JobCardPropTypes.LinkComponent,
  trackLinkClicked: JobCardPropTypes.trackLinkClicked
};

const MainPoint = ({
  job,
  LinkComponent,
  showShortenedLocation,
  hideSalary,
  trackLinkClicked
}) => {
  return (
    <IconList
      list={[
        {
          content: (
            <LocationGroup
              locations={job.locations}
              LinkComponent={LinkComponent}
              showShortenedLocation={showShortenedLocation}
              trackLinkClicked={trackLinkClicked}
            />
          ),
          iconType: 'location'
        },
        {
          content: job.salary,
          iconType: 'salary',
          show: Boolean(job.salary && !hideSalary)
        }
      ]}
    />
  );
};
MainPoint.propTypes = JobCardPropTypes;

const CompanyLogo = ({ companyLogoUrl, showCompanyLogo }) => {
  return companyLogoUrl && showCompanyLogo ? (

  ) : (

  );
};
CompanyLogo.propTypes = {
  companyLogoUrl: JobType.companyLogoUrl,
  showCompanyLogo: JobCardPropTypes.showCompanyLogo
};

const JobCard = memo(props => {
  const [shelfSectionOpen, setShelfSectionOpen] = useState(false);

  const handleShelfSectionToggle = e => {
    setShelfSectionOpen(!shelfSectionOpen);
    e.stopPropagation();
  };

  const {
    applied,
    borderlessRoot = false,
    enableBrandedAd,
    job = {},
    keyword,
    LinkComponent,
    onBookmarkClick,
    showSellingPoint,
    showCompanyLogo,
    showDescription,
    showSavedStatus,
    TitleLinkComponent,
    trackLinkClicked,
    viewed,
    viewedDate,
    isNewJob,
    tenant
  } = props;

  const {
    companyMeta = {},
    isSaved,
    bannerUrl,
    sellingPoints,
    description,
    isExpired
  } = job;

  const { logoUrl } = _get(job, 'companyMeta', {});

  const brandedStripeStyle = {
    jobsdb: styles.sideHighlightBorderJobsdb,
    jobstreet: styles.sideHighlightBorderJobstreet
  }[tenant.toLowerCase()];

  const JobMetaComponent = () => (
    <JobMeta
      sellingPoints={sellingPoints}
      showSellingPoint={showSellingPoint}
      description={description}
      showDescription={showDescription}
      job={job}
      shelfSectionOpen={shelfSectionOpen}
      onClick={handleShelfSectionToggle}
    />
  );

  return (

        {showSavedStatus && (
          <Button className={styles.bookmarkButton} onClick={onBookmarkClick}>
            <Icon
              size="normal"
              type="bookmark"
              className={isSaved ? styles.bookmarked : ''}
              animation={isSaved ? 'bounce' : ''}
            />
          </Button>
        )}
        <Hidden aboveMobile className={styles.alignCenter}>
          <CompanyBanner
            bannerUrl={bannerUrl}
            enableBrandedAd={enableBrandedAd}
            isMobile
          />
        </Hidden>
        <JobLabel
          applied={applied}
          expired={isExpired}
          viewed={viewed && viewedDate ? `Viewed ${viewedDate}` : ''}
          isNewJob={isNewJob}
        />
        <JobTitle
          {...{
            applied,
            TitleLinkComponent,
            viewed,
            keyword,
            job,
            trackLinkClicked,
            showSavedStatus
          }}
        />
        <Company
          company={companyMeta}
          keyword={keyword}
          LinkComponent={LinkComponent}
          trackLinkClicked={trackLinkClicked}
        />

            <MainPoint {...props} />
            <Hidden mobile>
              <JobMetaComponent />
            </Hidden>

            <CompanyLogo
              companyLogoUrl={logoUrl}
              showCompanyLogo={showCompanyLogo}
            />

        <Hidden aboveMobile>
          <JobMetaComponent />
        </Hidden>
        <ShelfSection
          shelf={job.shelf}
          LinkComponent={LinkComponent}
          showShelfSection={shelfSectionOpen}
          trackLinkClicked={trackLinkClicked}
        />

  );
});

export default props => (

);

JobCard.defaultProps = {
  trackLinkClicked: () => {},
  tenant: ''
};

JobCard.propTypes = JobCardPropTypes;

export { JobCard as JobCardForTest };


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MIMWebClient.Core.Events
{
    public class Camp
    {
        public static void SetUpCamp(PlayerSetup.Player player, Room.Room room)
        {

            if (room.containsCamp)
            {
                HubContext.Instance.SendToClient("A camp has already been set up here.", player.HubGuid);
                return;
            }

            if (room.items.FirstOrDefault(x => x.name.ToLower().Equals("camp fire")) == null)
            {
                HubContext.Instance.SendToClient("You need to have a camp fire before setting up camp.", player.HubGuid);
                return;
            }

            if (player.Inventory.FirstOrDefault(x => x.name.ToLower().Contains("pot")) == null)
            {
                HubContext.Instance.SendToClient("You need a cooking pot if you want to set up camp.", player.HubGuid);
                return;
            }

            if (player.MovePoints < 10)
            {
                HubContext.Instance.SendToClient("You are too tired to set up camp.", player.HubGuid);
                player.ActiveSkill = null;

                return;
            }

            player.MovePoints -= 10;

            if (player.MovePoints < 0)
            {
                player.MovePoints = 0;
            }

            if (player.Inventory.FirstOrDefault(x => x.name.ToLower().Contains("pot")) != null)
            {
                HubContext.Instance.SendToClient("You place the cooking pot upon the fire.", player.HubGuid);

                room.items.FirstOrDefault(x => x.name.ToLower().Equals("camp fire")).description.room =
                    "A cooking pot is suspended over a camp fire.";

                player.Inventory.Remove(player.Inventory.FirstOrDefault(x => x.name.Contains("pot")));

                foreach (var character in room.players)
                {
                    if (character != player)
                    {

                        var roomMessage =
                            $"{Helpers.ReturnName(player, character, string.Empty)} places a pot over the fire.";

                        HubContext.Instance.SendToClient(roomMessage, character.HubGuid);
                    }
                }
            }

            if (player.Inventory.FirstOrDefault(x => x.name.ToLower().Contains("bed")) != null)
            {
                HubContext.Instance.SendToClient("You place the bed roll by the fire.", player.HubGuid);

                var bed = player.Inventory.FirstOrDefault(x => x.name.ToLower().Contains("bed"));

               bed.description.room =
                    "A bed roll is layed out by the fire.";

                room.items.Add(bed);

                player.Inventory.Remove(player.Inventory.FirstOrDefault(x => x.name.ToLower().Contains("bed")));

                foreach (var character in room.players)
                {
                    if (character != player)
                    {

                        var roomMessage =
                            $"{Helpers.ReturnName(player, character, string.Empty)} places a bed roll by the fire.";

                        HubContext.Instance.SendToClient(roomMessage, character.HubGuid);
                    }
                }
            }

            Score.UpdateUiPrompt(player);

        }
    }
}


text:
FPP = FPP or {}

FPP.entOwners       = FPP.entOwners or {}
FPP.entTouchability = FPP.entTouchability or {}
FPP.entTouchReasons = FPP.entTouchReasons or {}

local touchTypes = {
	Physgun = 1,
	Gravgun = 2,
	Toolgun = 4,
	PlayerUse = 8,
	EntityDamage = 16
}

local reasonSize = 4 -- bits
local reasons = {
	[1] = "owner", -- you can't touch other people's props
	[2] = "world",
	[3] = "disconnected",
	[4] = "blocked",
	[5] = "constrained",
	[6] = "buddy",
	[7] = "shared",
	[8] = "player", -- you can't pick up players
}

local function receiveTouchData(len)
	repeat
		local entIndex = net.ReadUInt(32)
		local ownerIndex = net.ReadUInt(32)
		local touchability = net.ReadUInt(5)
		local reasons = net.ReadUInt(20)

		FPP.entOwners[entIndex] = ownerIndex
		FPP.entTouchability[entIndex] = touchability
		FPP.entTouchReasons[entIndex] = reasons
	until net.ReadBit() == 1
end
net.Receive("FPP_TouchabilityData", receiveTouchData)

function FPP.entGetOwner(ent)
	local idx = FPP.entOwners[ent:EntIndex()]
	ent.FPPOwner = idx and Entity(idx) or nil

	return ent.FPPOwner
end

function FPP.canTouchEnt(ent, touchType)
	ent.FPPCanTouch = FPP.entTouchability[ent:EntIndex()]
	if not touchType or not ent.FPPCanTouch then
		return ent.FPPCanTouch
	end

	return bit.bor(ent.FPPCanTouch, touchTypes[touchType]) == ent.FPPCanTouch
end

local touchTypeMultiplier = {
	["Physgun"] = 0,
	["Gravgun"] = 1,
	["Toolgun"] = 2,
	["PlayerUse"] = 3,
	["EntityDamage"] = 4
}

function FPP.entGetTouchReason(ent, touchType)
	local idx = FPP.entTouchReasons[ent:EntIndex()] or 0
	ent.FPPCanTouchWhy = idx

	if not touchType then
		return ent.FPPCanTouchWhy
	end

	local maxReasonValue = 15
	local reasonNr = bit.band(idx, bit.lshift(maxReasonValue, reasonSize * touchTypeMultiplier[touchType]))
	local reason = reasons[reasonNr]

	if reasonNr == 1 then -- convert owner to the actual player
		local owner = ent:CPPIGetOwner()
		reason = IsValid(owner) and owner:Nick() or "Unknown player"
	end

	return reason
end


text:
package com.navercorp.pinpoint.profiler.instrument.lambda;

import com.navercorp.pinpoint.bootstrap.instrument.lambda.LambdaBytecodeHandler;
import com.navercorp.pinpoint.bootstrap.module.ClassFileTransformModuleAdaptor;
import com.navercorp.pinpoint.bootstrap.module.JavaModuleFactory;
import com.navercorp.pinpoint.common.util.JvmUtils;
import com.navercorp.pinpoint.common.util.JvmVersion;
import com.navercorp.pinpoint.profiler.instrument.transformer.InnerClassLambdaMetafactoryTransformer;
import com.navercorp.pinpoint.profiler.util.JavaAssistUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.Instrumentation;
import java.lang.reflect.Method;

/**
 * @author Woonduk Kang(emeroad)
 */
public class LambdaTransformBootloader {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    public void transformLambdaFactory(Instrumentation instrumentation, final ClassFileTransformModuleAdaptor classFileTransformer, final JavaModuleFactory javaModuleFactory)  {
        logger.info("LambdaTransformBootloader.transformLambdaFactory");
        retransform(instrumentation);

        registerLambdaBytecodeHandler(classFileTransformer, javaModuleFactory);

    }

    private void retransform(Instrumentation instrumentation) {
        final String lambdaMetaFactoryName = "java.lang.invoke.InnerClassLambdaMetafactory";
        try {
            final Class<?> lamdbaFactoryClazz = Class.forName(lambdaMetaFactoryName, false, null);
            logger.info("retransformClasses:{}", lamdbaFactoryClazz);
            final ClassFileTransformer classFileTransfomrer = new InnerClassLambdaMetafactoryTransformer();
            instrumentation.addTransformer(classFileTransfomrer, true);
            try {
                instrumentation.retransformClasses(lamdbaFactoryClazz);
            } finally {
                instrumentation.removeTransformer(classFileTransfomrer);
            }
        } catch (Exception e) {
            logger.warn("retransform fail class:{}", lambdaMetaFactoryName, e);
        }
    }

    private void registerLambdaBytecodeHandler(final ClassFileTransformModuleAdaptor classFileTransformer, final JavaModuleFactory javaModuleFactory)  {
        try {
            logger.info("register LambdaBytecodeHandler");
            // for java9 handler
            final LambdaBytecodeHandler lambdaBytecodeHandler = newLambdaBytecodeHandler(classFileTransformer, javaModuleFactory);

            final Class<?> unsafeDelegator = getUnsafeDelegator();
            final Method register = unsafeDelegator.getMethod("register", LambdaBytecodeHandler.class);
            final boolean success = (Boolean) register.invoke(unsafeDelegator, lambdaBytecodeHandler);
            if (success) {
                logger.info("LambdaBytecodeHandler registration success");
            } else {
                logger.warn("LambdaBytecodeHandler registration fail");
            }
        } catch (Exception e) {
            logger.error("LambdaBytecodeHandler registration fail Caused by:" + e.getMessage(), e);
        }
    }

    private LambdaBytecodeHandler newLambdaBytecodeHandler(ClassFileTransformModuleAdaptor classFileTransformer, JavaModuleFactory javaModuleFactory) {
        final LambdaBytecodeHandler lambdaBytecodeHandler = new DefaultLambdaBytecodeHandler(classFileTransformer, javaModuleFactory);
        if (LoggerFactory.getLogger(lambdaBytecodeHandler.getClass()).isDebugEnabled()) {
            return new LambdaBytecodeLogger(lambdaBytecodeHandler);
        }
        return lambdaBytecodeHandler;
    }

    private Class<?> getUnsafeDelegator() throws ClassNotFoundException {
        String delegatorName = getDelegatorName();
        return Class.forName(delegatorName, false, null);
    }

    private String getDelegatorName() {
        if (JvmUtils.getVersion().onOrAfter(JvmVersion.JAVA_9)) {
            return JavaAssistUtils.jvmNameToJavaName(LambdaClassJava9.DELEGATE_CLASS);
        } else {
            return JavaAssistUtils.jvmNameToJavaName(LambdaClassJava8.DELEGATE_CLASS);
        }
    }
}


text:
def atf_article_uri(url, post_id):
    return get_url_hash(url)+"/"+post_id

def atf_thread_uri(url):
    return get_url_hash(url)

test_date = "Wed Feb 11, 2015 10:31 am"

def atf_date_created(date, format="%a %b %d, %Y %I:%M %p"):
    """Put the date in ISO format"""
    return iso8601date(date, format)

def atf_joined_date(date, format="%a %b %d, %Y %I:%M %p"):
    """Put the date in ISO format"""
    return iso8601date(date, format)

test_date2 = "Wednesday, March 18, 2015 10:33 AM"
test_format2 = "%A, %B %d, %Y %I:%M %p"

test_date3 = "2014-01-14 02:52:44"

from HTMLParser import HTMLParser

class HTMLStripper(HTMLParser):
    def __init__(self):
        self.reset()
        self.fed = []
    def handle_data(self, d):
        self.fed.append(d)
    def handle_starttag(self, tag, attrs):
        self.fed.append(" ")
    def handle_endtag(self, tag):
        self.fed.append(" ")
    def handle_startendtag(self, tag, attrs):
        self.fed.append(" ")
    def get_data(self):
        return ''.join(self.fed)

def strip_tags(html):
    s = HTMLStripper()
    s.feed(html)
    return s.get_data()

test_signature = "Precision Combat Arms
1710 E Trent, Unit 1
Spokane, WA 99202
509-535-0655
M-F 9-5
"

def signature_clean(text):
    """Strip HTML"""
    return strip_tags(text).strip()

def atf_fc_uri(article_uri):
    """URI of feature collection"""
    return article_uri+"/featurecollection"

def atf_get_city(city_state):
    if "," in city_state:
        return city_state.split(",")[0]
    else:
        return city_state

def atf_get_state(city_state):
    if "," in city_state:
        return city_state.split(",")[1]
    else:
        return ""

def atf_address_uri(city, state, country):
    return address_uri(city, state, country)

def atf_clean_post_count(post_count):
    return numericOnly(post_count)

def atf_clean_from_user(user):
    user = user.strip()
    if user == "-" or user == "N/A":
        user = ''
    return user

import re

WEAPONS_PHRASES = ['gun',
                   'rifle',
                   'missile',
                   'mark',
                   'tank',
                   'mk',
                   'torpedo',
                   'naval',
                   'vehicle',
                   'remington',
                   'smith',
                   'pistol',
                   'wesson',
                   'grenade',
                   'howitzer',
                   'mine',
                   'mortar',
                   'colt',
                   'submachine',
                   'canon',
                   'cannon',
                   'mod\xe8le',
                   'ruger',
                   'koch',
                   'heckler',
                   'weapon',
                   'bomb',
                   'armoured',
                   'carbine',
                   'beretta',
                   'missile',
                   'armored',
                   'winchester',
                   'springfield',
                   'revolver',
                   'launcher',
                   'caliber',
                   'assault',
                   'sig',
                   '45',
                   'ordnance',
                   'zastava',
                   'rocket',
                   'anti-tank',
                   'walther',
                   'combat',
                   'benelli',
                   'sniper',
                   'series',
                   'mle',
                   'browning',
                   'schneider',
                   'm1',
                   'carrier',
                   'kanone',
                   'defense',
                   'artillery',
                   'tank',
                   'steyr',
                   'rml',
                   'mowag',
                   'wz.',
                   'mauser',
                   'm3',
                   'vehicle',
                   'vickers',
                   'taurus',
                   'tactical',
                   'sword',
                   'infantry',
                   'panzer',
                   'marlin',
                   'hotchkiss',
                   'fk',
                   'barrett',
                   'weapon',
                   'sauer',
                   'modello',
                   'explosive',
                   'aircraft',
                   'tractor',
                   'skoda',
                   'self-propelled',
                   'rheinmetall',
                   'reconnaissance',
                   'minenwerfer',
                   'm4',
                   'kel-tec',
                   'fighting',
                   'daewoo',
                   'bofors',
                   'rocket',
                   'sd.kfz.',
                   'scout',
                   'pindad',
                   'knife',
                   'carriage',
                   'bliss-leavitt',
                   'arms',
                   'advanced',
                   'storm',
                   'sdkfz',
                   'savage',
                   'saurer',
                   'renault',
                   'nuclear',
                   'missile',
                   'bayonet',
                   'arsenal',
                   'sword',
                   'armoured',
                   'weapons',
                   'weapon-stub',
                   'war',
                   'strike',
                   'spartan',
                   'oerlikon',
                   'obusier',
                   'nebelwerfer',
                   'm\xF6rser',
                   'munition',
                   'military',
                   'marksman',
                   'krupp',
                   'flamethrower',
                   'feldhaubitze',
                   'eagle',
                   'crosman',
                   'cobra',
                   'carrier',
                   'bushmaster',
                   'breda',
                   'army',
                   'amphibious',
                   'afv',
                   'wolf',
                   'vektor',
                   'vehicle',
                   'turret',
                   'tanks',
                   'stridsvagn',
                   'soltam',
                   'siege',
                   'shotgun',
                   'sg',
                   'schwerer',
                   'schwere',
                   'pdw',
                   'panhard',
                   'nambu',
                   'mortier',
                   'magnum',
                   'm8',
                   'm60',
                   'm1918',
                   'm1895',
                   'luftminenwerfer',
                   'leopard',
                   'kbk',
                   'kanon',
                   'imbel',
                   'humber',
                   'hi-point',
                   'guns',
                   'gryazev-shipunov',
                   'explosives',
                   'denel',
                   'battle',
                   'axe',
                   'automag',
                   'attack',
                   'armory',
                   'armalite',
                   'alfa',
                   'pistol',
                   'bomb',
                   'artillery']

def isInt(s):
    try:
        int(s)
        return True
    except:
        pass
    return False

WEAPONS_PHRASES = [w for w in WEAPONS_PHRASES if not isInt(w)]
# restore a few numbers
WEAPONS_PHRASES = WEAPONS_PHRASES + ["45", ".45", "38", "50", "3006", ".22", "22", "357"]
# add a few missing popular items
WEAPONS_PHRASES = WEAPONS_PHRASES + ['uzi', 'ammo', 'ammunition', 'stoner', 'scar17', 'taser', 'tazer',
                                     'Tokarev', 'glock', 'AK-47', 'AK 47', 'luger', 'P38', 'spdmstr',
                                     'AR15', 'AR-15', 'AMT', 'Trejo', 'Armatix', 'Astra', 'Bechowiec',
                                     'Bauer', 'Benelli', 'Versa', 'Browning', 'BUL', 'Caracal', 'Zamorana',
                                     'Wesson', 'Danuvia', 'Musgrave', 'Vektor', 'Enfield',
                                     'FEG', 'FN', 'Herstal', 'Gabilondo', 'Urresti', 'Makarov', 'Izhevsk',
                                     'Sauer', 'KBP', 'Kimber', 'MAB', 'Mauser', 'MAC-10', 'MAC-11',
                                     'MAC10', 'MAC11', 'Pindad',
                                     'RPC', 'Bonifacio', 'Steyr',
                                     'Tanfoglio', 'Tula', "CZ",
                                     "\x010CZ", 'RSAF', 'Webley',
                                     'Norinco', 'Akdal', 'Famars',
                                     'Marlin']

# FROM SPREADSHEET 28 May 2015

WMD_RELATED = [
"Abrin",
"Agent 15",
"Antrax",
"Arsines",
"Backpack nuke",
"Balancing Machines",
"Bambi",
"Beryllium",
"biohazard",
"biological",
"biological weapon",
"Bioreactors",
"bonus damage",
"bush",
"Capacitors",
"Chemical",
"chemical weapon",
"cheney",
"chlorine",
"Crucibles",
"cyanide",
"Cyanogen chloride",
"cyclosarin",
"Devices",
"Dirty Bomb",
"dirty bomber",
"Discharge",
"Electrical",
"face-shot",
"FAE",
"Fermenters",
"Filament",
"Flow Form Machines",
"Focal Plane Sensors",
"Frequency Changers",
"Generators",
"Gravity Gradiometers",
"Gravity Meters",
"Hafnium",
"Hafnium",
"Heat Exchanges",
"hydrogen chloride",
"hydrogen cyanide",
"IED",
"IID",
"incendiary",
"Inspection",
"Isostatic Presses",
"Lasers",
"Lathes",
"lewisite",
"Magnetic gradiometers",
"Maraging Steel",
"nerve gas",
"Niobium",
"nitrogen mustard",
"nitrogen oxide",
"Novichok",
"nuclear",
"nuclear weapon",
"Outlet pipes",
"phosgene",
"phosgene oxime",
"Pressure Transducers",
"Radioactive fallout device",
"radiological",
"radiological weapon",
"ricin",
"Sarin",
"soman",
"Spectrometers",
"spud gun",
"sulfur mustard",
"Switching Devices",
"tabun",
"Tantalum",
"tear gas",
"TOW",
"toxin",
"VR",
"VX",
"Weapons of Mass Destruction",
"weapons-grade",
"Winding",
"WMD",
"Wooden",
"Woompher",
"Zirconium"
]

EXPLOSIVES_RELATED = [
"Acetylides of heavy metals",
"aerial shell",
"aluminum",
"Aluminum containing polymeric propellant",
"Aluminum ophorite explosive",
"Amatex",
"Amatol",
"Ammonal",
"ammonia",
"ammonium nitrate",
# "Ammonium nitrate explosive mixtures (cap sensitive).",
"Ammonium nitrate explosive mixtures",
"cap sensitive",
# "Ammonium nitrate explosive mixtures (non-cap sensitive)",
"Ammonium nitrate explosive mixtures",
"non-cap sensitive",
#"Ammonium perchlorate explosive mixtures (excluding ammonium perchlorate composite propellant (APCP))",
"Ammonium perchlorate",
"explosive mixtures",
"APCP",
# "Ammonium perchlorate having particle size less than 15 microns",
"Ammonium perchlorate",
# "Ammonium picrate [picrate of ammonia, Explosive D].",
"Ammonium picrate",
"picrate of ammonia",
"Explosive D",
# "Ammonium salt lattice with isomorphously substituted inorganic salts",
"Ammonium salt lattice",
"isomorphously substituted inorganic salts",
# "ANFO [ammonium nitrate-fuel oil]",
"ANFO",
"ammonium nitrate-fuel oil",
"fuel oil",
"Aromatic nitro-compound explosive mixtures",
"articles pyrotechnic",
"ATF",
"ATFE",
"Azide explosives",
"bang",
"Baranol",
"Baratol",
"BATFE",
# "BEAF [1, 2-bis (2, 2-difluoro-2-nitroacetoxyethane)]",
"BEAF",
"1, 2-bis (2, 2-difluoro-2-nitroacetoxyethane)",
"binary",
"Black powder",
"black powder",
"Black powder based explosive mixtures",
"black powder bomb",
# "Blasting agents, nitro-carbo-nitrates, including non-cap sensitive slurry and water gel explosives",
"Blasting agents",
"nitro-carbo-nitrates",
"non-cap sensitive slurry",
"water gel explosives",
"Blasting caps",
"Blasting gelatin",
"Blasting powder",
"blow up",
"bomb",
"boom",
"booster",
# "BTNEC [bis (trinitroethyl) carbonate]",
"BTNEC",
"bis (trinitroethyl) carbonate",
# "BTNEN [bis (trinitroethyl) nitramine]",
"BTNEN",
"bis (trinitroethyl) nitramine",
# "BTTN [1,2,4 butanetriol trinitrate]",
"BTTN",
"1,2,4 butanetriol trinitrate",
"Bulk salutes",
"Bureau of ATF",
"butane bomb",
"Butyl tetryl",
"c-4",
"cake",
# "Calcium nitrate explosive mixture",
"Calcium nitrate explosive mixture",
"Calcium nitrate",
"cap sensitive",
# "Cellulose hexanitrate explosive mixture",
"Cellulose hexanitrate explosive mixture",
"Cellulose hexanitrate",
"charge",
"Chlorate explosive mixtures",
"Class B",
"Class C",
# "Composition A and variations",
"Composition A and variations",
"Composition A",
# "Composition B and variations",
"Composition B and variations",
"Composition B",
# "Composition C and variations",
"Composition C and variations",
"Composition C",
"Copper acetylide",
"cord",
"Cyanuric triazide",
# "Cyclonite [RDX]",
"Cyclonite",
"RDX",
# "Cyclotetramethylenetetranitramine [HMX]",
"Cyclotetramethylenetetranitramine",
"HMX",
"Cyclotol",
# "Cyclotrimethylenetrinitramine",
"Cyclotrimethylenetrinitramine",
"RDX",
# "DATB [diaminotrinitrobenzene]",
"DATB",
"diaminotrinitrobenzene",
# "DATB [diaminotrinitrobenzene]",
"DATB",
"diaminotrinitrobenzene",
# "DDNP [diazodinitrophenol]",
"DDNP",
"diazodinitrophenol",
# "DEGDN [diethyleneglycol dinitrate]",
"DEGDN",
"diethyleneglycol dinitrate",
"depth charge",
"det cord",
"Detonating cord",
"detonator",
"detonator",
"Detonators",
"dets",
"diesel",
"diesel fuel",
"Dimethylol dimethyl methane dinitrate composition",
"Dinitroethyleneurea",
# "Dinitroglycerine [glycerol dinitrate]",
"Dinitroglycerine",
"glycerol dinitrate",
"Dinitrophenol",
"Dinitrophenolates",
"Dinitrophenyl hydrazine",
"Dinitroresorcinol",
"Dinitrotoluene-sodium nitrate explosive mixtures",
# "DIPAM [dipicramide; diaminohexanitrobiphenyl]",
"DIPAM",
"dipicramide; diaminohexanitrobiphenyl",
"Dipicryl sulfone",
"Dipicrylamine",
"Display fireworks",
# "DNPA [2,2-dinitropropyl acrylate]",
"DNPA",
"2,2-dinitropropyl acrylate",
# "DNPD [dinitropentano nitrile]",
"DNPD",
"dinitropentano nitrile",
"Dynamite",
# "EDDN [ethylene diamine dinitrate]",
"EDDN",
"ethylene diamine dinitrate",
# "EDNA [ethylenedinitramine]",
"EDNA",
"ethylenedinitramine",
"Ednatol",
# "EDNP [ethyl 4,4-dinitropentanoate]",
"EDNP",
"ethyl 4,4-dinitropentanoate",
# "EGDN [ethylene glycol dinitrate]",
"EGDN",
"ethylene glycol dinitrate",
"Emulsion",
"Erythritol tetranitrate explosives",
"Esters of nitro-substituted alcohols",
"Ethyl-tetryl",
"EX Number",
"explosive",
"Explosive conitrates",
"Explosive gelatins",
"Explosive liquids",
"Explosive mixtures containing oxygenreleasing inorganic salts and hydrocarbons",
"Explosive mixtures containing oxygenreleasing inorganic salts and nitro bodies",
"Explosive mixtures containing oxygenreleasing inorganic salts and water insoluble fuels",
"Explosive mixtures containing oxygenreleasing inorganic salts and water soluble fuels",
"Explosive mixtures containing sensitized nitromethane",
"Explosive mixtures containing tetranitromethane (nitroform)",
"Explosive nitro compounds of aromatic hydrocarbons",
"Explosive organic nitrate mixtures",
"Explosive powders",
"Federal Explosives Licensee",
"Federal Explosives Permit",
"FEL",
"FEP",
"fertilizer",
"firework",
"Flash powder",
"flash powder bomb",
"fuel",
"fuel air mixture bomb",
"Fulminate of mercury",
"Fulminate of silver",
"Fulminating gold",
"Fulminating mercury",
"Fulminating platinum",
"Fulminating silver",
"fuse",
"Gelatinized nitrocellulose",
"Gem-dinitro aliphatic explosive mixtures",
"grenade",
"Guanyl nitrosamino guanyl tetrazene",
"Guanyl nitrosamino guanylidene hydrazine",
"Guncotton",
"Heavy metal azides",
"helix",
"Hexanite",
"Hexanitrodiphenylamine",
"Hexanitrostilbene",
# "Hexogen [RDX]",
"Hexogen",
"RDX",
"Hexogene or octogene and a nitrated Nmethylaniline",
"Hexolites",
"high explosive",
"HME",
# "HMTD [hexamethylenetriperoxidediamine]",
"HMTD",
"hexamethylenetriperoxidediamine",
# "HMX [cyclo-1,3,5,7-tetramethylene 2,4,6,8-tetranitramine; Octogen]",
"HMX",
"cyclo-1,3,5,7-tetramethylene 2,4,6,8-tetranitramine",
"Octogen",
"homemade bomb",
"homemade explosive",
# "Hydrazinium nitrate/hydrazine/aluminum explosive system",
"Hydrazinium nitrate",
"hydrazine",
"aluminum explosive system",
"Hydrazoic acid",
"Hydrogen peroxide",
"igniter",
"Igniter cord",
"Igniters",
"incendiary",
"Initiating tube systems",
"instant mix",
# "KDNBF [potassium dinitrobenzo-furoxane]",
"KDNBF",
"potassium dinitrobenzo-furoxane",
"land mine",
"Lead azide",
"Lead mannite",
"Lead mononitroresorcinate",
"Lead picrate",
"Lead salts, explosive",
# "Lead styphnate [styphnate of lead, lead trinitroresorcinate]",
"Lead styphnate",
"styphnate of lead",
"lead trinitroresorcinate",
"Liquid nitrated polyol and trimethylolethane",
"Liquid oxygen explosives",
"low explosive",
"M/S",
"M-80",
"Magnesium ophorite explosives",
"Mannitol hexanitrate",
"mass destruction",
"mass detonate",
"mass detonation",
"mass explosion",
"mass explosive",
# "MDNP [methyl 4,4-dinitropentanoate]",
"MDNP",
"methyl 4,4-dinitropentanoate",
# "MEAN [monoethanolamine nitrate]",
"MEAN",
"monoethanolamine nitrate",
"Mercuric fulminate",
"Mercury oxalate",
"Mercury tartrate",
"methane",
"Metriol trinitrate",
"millisecond",
# "Minol-2 [40% TNT, 40% ammonium nitrate, 20% aluminum]",
"Minol-2",
"40% TNT, 40% ammonium nitrate, 20% aluminum",
# "MMAN [monomethylamine nitrate]; methylamine nitrate",
"MMAN",
"monomethylamine nitrate",
"methylamine nitrate",
"molotov",
"molotov cocktail",
"Mononitrotoluene-nitroglycerin mixture",
"Monopropellants",
# "NIBTN [nitroisobutametriol trinitrate]",
"NIBTN",
"nitroisobutametriol trinitrate",
"Nitrate explosive mixtures",
"Nitrate sensitized with gelled nitroparaffin",
"Nitrated carbohydrate explosive",
"Nitrated glucoside explosive",
"Nitrated polyhydric alcohol explosives",
"Nitric acid and a nitro aromatic compound explosive",
"Nitric acid and carboxylic fuel explosive",
"Nitric acid explosive mixtures",
"nitro",
"Nitro aromatic explosive mixtures",
"Nitro compounds of furane explosive mixtures",
"Nitrocellulose explosive",
"Nitroderivative of urea explosive mixture",
"Nitrogelatin explosive",
"Nitrogen trichloride",
"Nitrogen tri-iodide",
# "Nitroglycerine [NG, RNG, nitro, glyceryl trinitrate, trinitroglycerine",
"Nitroglycerine",
"NG",
"RNG",
"nitro",
"glyceryl trinitrate",
"trinitroglycerine",
"Nitroglycide",
# "Nitroglycol [ethylene glycol dinitrate, EGDN",
"Nitroglycol",
"ethylene glycol dinitrate",
"EGDN",
"Nitroguanidine explosives",
"Nitronium perchlorate propellant mixtures",
# "Nitroparaffins Explosive Grade and ammonium nitrate mixtures",
"Nitroparaffins",
"Nitrostarch",
"Nitro-substituted carboxylic acids",
"Nitrourea",
# "Octogen [HMX",
"Octogen",
"HMX",
# "Octol [75 percent HMX, 25 percent TNT]",
"Octol",
"75 percent HMX, 25 percent TNT",
"oil perforator",
"Organic amine nitrates",
"Organic nitramines",
"oxidizer",
# "PBX [plastic bonded explosives]",
"PBX",
"plastic bonded explosives",
"Pellet powder",
"Penthrinite composition",
"Pentolite",
"Perchlorate explosive mixtures",
"Peroxide based explosive mixtures",
# "PETN [nitropentaerythrite, pentaerythrite tetranitrate, pentaerythritol tetranitrate]",
"PETN",
"nitropentaerythrite",
"pentaerythrite tetranitrate",
"pentaerythritol tetranitrate",
"Picramic acid and its salts",
"Picramide",
"Picrate explosives",
"Picrate of potassium explosive mixtures",
"Picratol",
# "Picric acid (manufactured as an explosive)",
"Picric acid",
"Picryl chloride",
"Picryl fluoride",
"pipe bomb",
"plastic explosive",
# "PLX [95% nitromethane, 5% ethylenediamine]",
"PLX",
"95% nitromethane, 5% ethylenediamine",
"Polynitro aliphatic compounds",
"Polyolpolynitrate-nitrocellulose explosive gels",
# "Potassium chlorate and lead sulfocyanate explosive",
"Potassium chlorate",
"lead sulfocyanate",
# "Potassium nitrate explosive mixtures",
"Potassium nitrate",
"Potassium nitroaminotetrazole",
"pounds",
"propane bomb",
"pyrotechnic",
"Pyrotechnic compositions",
# "PYX [2,6-bis(picrylamino)] 3,5-dinitropyridine",
"PYX",
"2,6-bis(picrylamino) 3,5-dinitropyridine",
"Quarter stick",
# "RDX [cyclonite, hexogen, T4, cyclo-1,3,5,-trimethylene-2,4,6,-trinitramine; hexahydro-1,3,5-trinitro-S-triazine]",
"RDX",
"cyclonite",
"hexogen",
"T4",
"cyclo-1,3,5,-trimethylene-2,4,6,-trinitramine",
"hexahydro-1,3,5-trinitro-S-triazine",
"Safety fuse",
"Salts of organic amino sulfonic acid explosive mixture",
"salute",
"Salutes (bulk)",
"bulk salutes",
"shape charge",
"shell",
"Silver acetylide",
"Silver azide",
"Silver fulminate",
# "Silver oxalate explosive mixtures",
"Silver oxalate explosive mixtures",
"Silver oxalate",
"Silver styphnate",
# "Silver tartrate explosive mixtures",
"Silver tartrate explosive mixtures",
"Silver tartrate",
"Silver tetrazene",
"Slurried explosive mixtures of water, inorganic oxidizing salt, gelling agent, fuel, and sensitizer (cap sensitive)",
"Smokeless powder",
"Sodatol",
"Sodium amatol",
"Sodium azide explosive mixture",
"Sodium dinitro-ortho-cresolate",
"Sodium nitrate explosive mixtures",
"Sodium nitrate-potassium nitrate explosive mixture",
"Sodium picramate",
"Special fireworks",
"Squibs",
"Styphnic acid explosives",
# "Tacot [tetranitro-2,3,5,6-dibenzo-1,3a,4,6a tetrazapentalene]",
"Tacot",
"tetranitro-2,3,5,6-dibenzo-1,3a,4,6a tetrazapentalene",
"tannerite",
# "TATB [triaminotrinitrobenzene]",
"TATB",
"triaminotrinitrobenzene",
# "TATP [triacetonetriperoxide]",
"TATP",
"triacetonetriperoxide",
# "TEGDN [triethylene glycol dinitrate]",
"TEGDN",
"triethylene glycol dinitrate",
"Tetranitrocarbazole",
# "Tetrazene [tetracene, tetrazine, 1(5-tetrazolyl)-4-guanyl tetrazene hydrate]",
"Tetrazene",
"tetracene",
"tetrazine",
"1(5-tetrazolyl)-4-guanyl tetrazene hydrate",
# "Tetrazole explosives",
"Tetrazole explosives",
"Tetrazole",
# "Tetryl [2,4,6 tetranitro-N-methylaniline]",
"Tetrytol",
"thermobaric bomb",
"Thickened inorganic oxidizer salt slurried explosive mixture",
# "TMETN [trimethylolethane trinitrate]",
# "TNEF [trinitroethyl formal]",
# "TNEOC [trinitroethylorthocarbonate]",
# "TNEOF [trinitroethylorthoformate]",
# "TNT [trinitrotoluene, trotyl, trilite, triton]",
"Torpex",
"Tridite",
"Trimethylol ethyl methane trinitrate composition",
"Trimethylolthane trinitrate-nitrocellulose",
"Trimonite",
"Trinitroanisole",
"Trinitrobenzene",
"Trinitrobenzoic acid",
"Trinitrocresol",
"Trinitro-meta-cresol",
"Trinitronaphthalene",
"Trinitrophenetol",
"Trinitrophloroglucinol",
"Trinitroresorcinol",
"Tritonal",
"UN Number",
"Urea nitrate",
# "Water-bearing explosives having salts of oxidizing acids and nitrogen bases, sulfates, or sulfamates (cap sensitive)",
"Water-in-oil emulsion explosive compositions",
# "Xanthamonas hydrophilic colloid explosive mixture",
"Xanthamonas",
"hydrophilic colloid",
"Quarterstick",
"Halfstick"
]

NFA_RELATED = [
"11.5 inch",
'11.5"',
"14 inch",
'14"',
"any other weapon",
"AOW",
"ATF",
"ATFE",
"auto sear",
"automatic",
"autosear",
"AW-SIM",
"BATFE",
"Bureau of ATF",
"can",
"cane gun",
"class 3",
"class III",
"conversion",
"conversion kit",
"destructive device",
"DIAS",
"drop in auto sear",
"drop in autosear",
"FA",
"flash bang",
"flashbang",
"forward grip",
"full auto",
"grenade",
"homemade silencer",
"homemade suppressor",
"incendiary",
"land mine",
"Lightning Link",
"machine gun",
"machinegun",
"missile",
"molotov",
"molotov cocktail",
"muffler",
"nfa",
"pen gun",
"pistol grip",
"poison gas",
"RLL",
"rocket",
"rocket launcher",
"sawed off",
"sbr",
"sbs",
"sear",
"short barrel rifle",
"short barrel shotgun",
"short barreled rifle",
"short barreled shotgun",
"silencer",
"smooth bore",
"SOT",
"Special Occupational Tax",
"street sweeper",
"suppressor",
"umbrella gun",
"wallet gun",
"weapon made from",
"Zip gun",
"Zipgun"
]

GANG_RELATED = [
"boom stick",
"burner",
"cash",
"money",
"heroin",
"chopper",
"clap-clap",
"dat fire",
"dat thang",
"davy crocket",
"deuce",
"deuce deuce",
"duece",
"fofo",
"four nickle",
"gat",
"gatt",
"gauge",
"ghost load",
"hammer",
"heater",
"hog leg",
"jammy",
"lead spitta",
"lil buddy",
"long pumps",
"mac",
"mack",
"mr. 9mm",
"narco",
"nina",
"nine",
"ol'betsy",
"ol' betsy",
"ooh wop",
"piece",
"pocket rocket",
"rod",
"roscoe",
"sawdy",
"shotty",
"smoke wagon",
"strap",
"throw down",
"thunder stick",
"toaster",
"tres",
"widow maker",
"yeezy"
]

NON_ENGLISH_RELATED = [
"arma larga",
"armas de fuego",
"bala",
"cahuetas",
"Cartucho",
"Cebolla",
"Cebollas",
"cortas",
"cuerno de chivo",
"cuerno de chivo",
"Cuerno de Chivo",
"Cuerno",
"cuete",
"El Subfusil ametralladora",
"escopete",
"escuadra",
"escuadra",
"explosivo",
"fusca",
"gat",
"la ametralladora",
"la escopeta",
"Lanza papas",
"largas",
"municion",
"Municiones",
"Papa",
"Papas",
"penas",
"Pertrechos",
"pistola",
"Polvora",
"proyectil",
"r quinze",
"Tolba",
"trick or treat",
"tricki-tricki",
"Vaina"
]

FIREARMS_RELATED = [
"5.56",
"7.62",
"1911",
".45 caliber",
".50 caliber",
"37 mm",
"37mm",
"3-D firearm",
"3-D print",
"3-D printed",
"80 percent receiver",
"80% receiver",
"9mm",
"AK",
"AK-47",
"AK-74",
"ammo",
"ammunition",
"APA",
"AR",
"AR-15",
"Armor piercing",
"Armor piercing ammuntion",
"assault rifle",
"ATF",
"ATFE",
"Barrett",
"BATFE",
"Build party",
"bullet proof vest",
"bump fire",
"bump stock",
"Bureau of ATF",
"caliber",
"carbine",
"cash only",
"centerfire",
"Chopper",
"clip",
"CNC",
"concealable",
"derringer",
"F2F",
"face to face",
"Federal Firearms License",
"FFL",
"fixed stock",
"flare gun",
"FMJ",
"folding stock",
"frame",
"full metal jacket",
"gas mask",
"ghost gun",
"glock",
"handgun",
"hi point",
"high capacity",
"homemade gun",
"jimenez",
"keltec",
"kevlar",
"long gun",
"lower",
"mag",
"magazine",
"MP4",
"MP5",
"no 4473",
"no background",
"no check",
"no paper work",
"no paperwork",
"no questions asked",
"oblit",
"obliterated",
"off book",
"pistol",
"receiver",
"revolver",
"rifle",
"rimfire",
"RPG",
"S&W",
"SA",
"scratched",
"semi-auto",
"semi-automatic",
"shotgun",
"shotty",
"shoty",
"sig brace",
"stripped lower",
"stun gun",
"Taurus",
"untraceable",
"uzi",
"vest"
]

FIREARMS_TECHNOLOGY_BRANCH = [
"Glock Switch",
"Glock Chip",
# "Chip (since this is so inclusive - I would only search in conjunction with other firearm words)",
"Chip",
"Baffle",
"Baffle Stack",
"Monocore",
"Anarchist",
"Solvent Trap",
"LDC",
"Belt Fed",
"Crew served",
"Hip Whip",
"Polymer",
"CNC machine",
"Green tip",
"Black tip",
"FAL",
"Outer tube",
"trigger"
]

WEAPONS_PHRASES.extend(FIREARMS_RELATED)
WEAPONS_PHRASES.extend(FIREARMS_TECHNOLOGY_BRANCH)
WEAPONS_PHRASES = list(set([w.lower() for w in WEAPONS_PHRASES]))

test_text = """New In Box Walther UZI .22LR RIFLE 20+1 $349.99"""

WEAPONS_PATTERNS = [re.compile(r"""\b%s\b""" % ph, re.IGNORECASE) for ph in WEAPONS_PHRASES]

def weapons_words(text, patterns=WEAPONS_PATTERNS, phrases=WEAPONS_PHRASES):
    matches = set()
    for (pattern, phrase) in zip(patterns, phrases):
        for match in re.finditer(pattern, text):
            matches.add(phrase)
    matches = list(matches)
    matches.sort()
    return matches

# print weapons_words(test_text)

def get_atf_weapons(*texts):
    all_text = " ".join([strip_tags(t) for t in texts])
    return "|".join(weapons_words(all_text))

##################################################################
KEYWORDS_PHRASES = WMD_RELATED + EXPLOSIVES_RELATED + NFA_RELATED + GANG_RELATED + NON_ENGLISH_RELATED
KEYWORDS_PHRASES = list(set([k.lower() for k in KEYWORDS_PHRASES]))

KEYWORDS_PATTERNS = [re.compile(r"""\b%s\b""" % ph, re.IGNORECASE) for ph in KEYWORDS_PHRASES]

def keywords_words(text, patterns=KEYWORDS_PATTERNS, phrases=KEYWORDS_PHRASES):
    matches = set()
    for (pattern, phrase) in zip(patterns, phrases):
        for match in re.finditer(pattern, text):
            matches.add(phrase)
    matches = list(matches)
    matches.sort()
    return matches

# print keywords_words(test_text)

def get_keywords(*texts):
    all_text = " ".join([strip_tags(t) for t in texts])
    return "|".join(keywords_words(all_text))

##################################################################

test_prices = ["I like to spend $50 for a sword, $75.00 for ammo, $ 100.00 for rifle, $ 1,000 for lunch, and BTC 2.468 to donate to Edward Snowden.",
               "I make $60K a year on Herbalife.  Ask me how!",
               "JPY 500000 is more than CHF 200.5",
               "2.5 BTC or BTC 4.5"]

DOLLAR_PRICE_REGEXPS = [re.compile(r'''\$\s*(?:\d{1,3},\s?)*\d{1,3}(?:(?:\.\d+)|[KkMm])?''', re.IGNORECASE),
                        re.compile(r'''USD\s*\d{1,7}(?:\.\d+)?''', re.IGNORECASE),
                        re.compile(r'''\d{1,7}(?:\.\d+)?\s*USD''', re.IGNORECASE)
                        ]

BITCOIN_PRICE_REGEXPS = [re.compile(r'''(?:BTC|XBT|XBC)\s*\d{1,7}(?:\.\d+)?''', re.IGNORECASE),
                         re.compile(r'''\d{1,7}(?:\.\d+)?\s*(?:BTC|XBT|XBC)''', re.IGNORECASE)
                         ]

def get_dollar_prices(*texts):
    matches = []
    for t in texts:
        for r in DOLLAR_PRICE_REGEXPS:
            for m in r.findall(t):
                matches.append(m.replace('$ ','$').replace(',','').replace('$','').replace('K',"000").replace('k',"000").replace("M","000").replace('m',"000"))
    return "|".join(matches)

def get_prices(*texts):
    return get_dollar_prices(*texts)

def get_bitcoin_prices(*texts):
    matches = []
    for t in texts:
        for r in BITCOIN_PRICE_REGEXPS:
            for m in r.findall(t):
                matches.append(m.replace('BTC','').replace('XBT','').replace('XBC','').replace(' ',''))
    return "|".join(matches)

# print get_prices(*test_prices)

def atf_body_clean(text):
    """Strip HTML"""
    return strip_tags(text).strip()

def onion_name_to_provider_name(onion):
    if onion   in ["k5zq47j6wd3wdvjq.onion"]:
        return "evolution"
    elif onion in ["i25c62nvu4cgeqyz.onion"]:
        return "evolution-forums"
    else:
        return onion

def atf_provider_name(uri):
    domain = getWebsiteDomain(uri)
    if domain.endswith('backpage.com'):
        return "backpage.com"
    elif domain.endswith('.onion'):
        return onion_name_to_provider_name(domain)
    else:
        return domain

def person_userid_uri(cleaned):
    if cleaned:
        cleaned = cleaned.strip().replace(" ", "_").lower()
        return "person_userid/%s" % cleaned
    return ''

def person_postcount_uri(cleaned):
    if cleaned:
        cleaned = cleaned.strip().replace(" ", "_").lower()
        return "person_postcount/%s" % cleaned
    return ''

def enrollment_date_uri(cleaned):
    if cleaned:
        cleaned = cleaned.strip().replace(" ", "_").replace(":", "-").lower()
        return "enrollment_date/%s" % cleaned
    return ''

def fromUser_uri(cleaned):
    if cleaned:
        cleaned = cleaned.strip().replace(" ", "_").lower()
        return "fromUser/%s" % cleaned
    return ''

def weaponsMentioned_uri(cleaned):
    if cleaned:
        cleaned = cleaned.strip().replace(" ", "_").lower()
        return "weaponsMentioned/%s" % cleaned
    return ''

def keywordsMentioned_uri(cleaned):
    if cleaned:
        cleaned = cleaned.strip().replace(" ", "_").lower()
        return "keywordsMentioned/%s" % cleaned
    return ''

def place_postalAddress_uri(cleaned):
    if cleaned:
        cleaned = cleaned.strip().replace(" ", "_").lower()
        return "place_postalAddress/%s" % cleaned
    return ''

# print test_prices, get_dollar_prices(*test_prices)
# print test_prices, get_bitcoin_prices(*test_prices)

##################################################################

def get_weapons(*texts):
    atf_weapons = get_atf_weapons(*texts)
    keywords = get_keywords(*texts)
    return ("%s|%s" % (atf_weapons, keywords)).strip("|")


text:
var url = require('url')
  , fs = require('fs')
  , childProcess = require('child_process')
  , phantomScript = __dirname + '/webshot.phantom.js'
  , extensions = ['jpeg', 'jpg', 'png', 'pdf'];

// Default options
var defaults = {
  screenSize: {
    width: 1024
  , height: 768
  }
, shotSize: {
    width: 'window'
  , height: 'window'
  }
, script: function() {}
, phantomPath: 'phantomjs'
, userAgent: ''
};

module.exports = function() {

  // Process arguments
  var args = Array.prototype.slice.call(arguments, 0);
  var cb = args.pop();
  var site = args.shift();
  var path = args.shift();
  var options = args.pop() || {};

  // Add protocol to the site url if not present
  site = url.parse(site).protocol ? site : 'http://' + site;

  // Check that a valid filetype was given for the output image
  var extension = path.substring(~(~path.lastIndexOf('.') || ~path.length) + 1);

  if (!~extensions.indexOf(extension.toLowerCase())) {
    cb(new Error('All files must end with one of the following extensions: '
      + extensions.join(', ')));
  }

  // Fill in defaults for undefined options
  Object.keys(defaults).forEach(function(key) {
    options[key] = options[key] || defaults[key];
  });

  // Remove the given file if it already exists, then call phantom
  var spawn = spawnPhantom.bind(null, site, path, options, function(err) {
    cb(err || null);
  });

  fs.exists(path, function(exists) {
    if (exists) {
      fs.unlink(path, function(err) {
        if (err) return cb(err);
        spawn();
      });
    } else {
      spawn();
    }
  });
};

/*
 * Spawn a phantom instance to take the screenshot
 *
 * @param (String) site
 * @param (String) path
 * @param (Object) options
 * @param (Function) cb
 */
function spawnPhantom(site, path, options, cb) {
  var phantomArgs = [
    phantomScript
  , site
  , path
  , options.screenSize.width
  , options.screenSize.height
  , options.shotSize.width
  , options.shotSize.height
  , options.userAgent
  , options.script
  , options.session
  ].map(function(arg) {
    return arg ? arg.toString() : null;
  });

  childProcess
    .spawn(options.phantomPath, phantomArgs)
    .on('exit', function(code) {
      // console.log('phantom exited');
      cb(code
        ? new Error('PhantomJS exited with return value ' + code)
        : null);
    });
}