text:
RSpec.describe MiqWidgetSet do
  let(:group) { user.current_group }
  let(:user)  { FactoryBot.create(:user_with_group) }
  before do
    @ws_group = FactoryBot.create(:miq_widget_set, :name => 'Home', :owner => group)
  end

  it "when a group dashboard is deleted" do
    expect(MiqWidgetSet.count).to eq(1)
    @ws_group.destroy
    expect(MiqWidgetSet.count).to eq(0)
  end

  context "with a group" do
    it "being deleted" do
      expect(MiqWidgetSet.count).to eq(1)
      user.destroy
      group.destroy
      expect(MiqWidgetSet.count).to eq(0)
    end
  end

  context "with a user" do
    before do
      FactoryBot.create(:miq_widget_set, :name => 'Home', :userid => user.userid, :group_id => group.id)
    end

    it "initial state" do
      expect(MiqWidgetSet.count).to eq(2)
    end

    it "the belong to group is being deleted" do
      expect { expect { group.destroy! }.to raise_error(ActiveRecord::RecordNotDestroyed) }.to_not(change { MiqWidgetSet.count })
      expect(group.errors[:base][0]).to eq("The group has users assigned that do not belong to any other group")
    end

    it "being deleted" do
      user.destroy
      expect(MiqWidgetSet.count).to eq(1)
    end
  end

  describe ".destroy_user_versions" do
    before do
      FactoryBot.create(:miq_widget_set, :name => 'User_Home', :userid => user.userid)
    end

    it "destroys all user's versions of dashboards (dashboards been customized by user)" do
      expect(MiqWidgetSet.count).to eq(2)
      MiqWidgetSet.destroy_user_versions
      expect(MiqWidgetSet.count).to eq(1)
      expect(MiqWidgetSet.first).to eq(@ws_group)
    end
  end

  describe "#where_unique_on" do
    let(:group2) { FactoryBot.create(:miq_group, :description => 'dev group2') }
    let(:ws_1)   { FactoryBot.create(:miq_widget_set, :name => 'Home', :userid => user.userid, :group_id => group.id) }

    before do
      user.miq_groups << group2
      ws_1
      FactoryBot.create(:miq_widget_set, :name => 'Home', :userid => user.userid, :group_id => group2.id)
    end

    it "initial state" do
      expect(MiqWidgetSet.count).to eq(3)
    end

    it "brings back all group records" do
      expect(MiqWidgetSet.where_unique_on('Home')).to eq([@ws_group])
    end

    it "brings back records for a user with a group" do
      expect(MiqWidgetSet.where_unique_on('Home', user)).to eq([ws_1])
    end
  end

  describe "#with_users" do
    it "brings back records with users" do
      ws_1 = FactoryBot.create(:miq_widget_set, :name => 'Home', :userid => user.userid, :group_id => group.id)
      expect(described_class.with_users).to eq([ws_1])
    end
  end

  context ".find_with_same_order" do
    it "returns in index order" do
      g1 = FactoryBot.create(:miq_widget_set)
      g2 = FactoryBot.create(:miq_widget_set)
      expect(MiqWidgetSet.find_with_same_order([g1.id.to_s, g2.id.to_s])).to eq([g1, g2])
    end

    it "returns in non index order" do
      g1 = FactoryBot.create(:miq_widget_set)
      g2 = FactoryBot.create(:miq_widget_set)
      expect(MiqWidgetSet.find_with_same_order([g2.id.to_s, g1.id.to_s])).to eq([g2, g1])
    end
  end

  context "loading group specific defaul dashboard" do
    describe ".sync_from_file" do
      let(:dashboard_name) { "Dashboard for Group" }
      before do
        @yml_file = Tempfile.new('default_dashboard_for_group.yaml')
        yml_data = YAML.safe_load(<<~DOC, [Symbol])
          ---
          name: #{dashboard_name}
          read_only: t
          set_type: MiqWidgetSet
          description: Test Dashboard for Group
          owner_type: MiqGroup
          owner_description: #{group.description}
          set_data_by_description:
            :col1:
            - chart_vendor_and_guest_os
        DOC
        File.write(@yml_file.path, yml_data.to_yaml)
      end

      after do
        @yml_file.close(true)
      end

      it "loads dashboard for specific group" do
        described_class.sync_from_file(@yml_file.path)
        dashboard = MiqWidgetSet.find_by(:name => dashboard_name)
        expect(dashboard.owner_id).to eq(group.id)
      end
    end
  end

  describe ".copy_dashboard" do
    let(:name) { "New Dashboard Name" }
    let(:tab) { "Dashboard Tab" }

    it "does not raises error if the same dashboard name used for different groups" do
      expect { MiqWidgetSet.copy_dashboard(@ws_group, @ws_group.name, tab) }.not_to raise_error
    end

    it "raises error if passed tab name is empty" do
      expect { MiqWidgetSet.copy_dashboard(@ws_group, name, "") }.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: MiqWidgetSet: Description can't be blank")
    end

    it "raises error if group with passed id does not exist" do
      expect { MiqWidgetSet.copy_dashboard(@ws_group, name, tab, "9999") }.to raise_error(ActiveRecord::RecordNotFound, "Couldn't find MiqGroup with 'id'=9999")
    end

    it "copy dashboard and set its owner to the group with passed group_id" do
      another_group = FactoryBot.create(:miq_group, :description => 'some_group')
      MiqWidgetSet.copy_dashboard(@ws_group, name, tab, another_group.id)
      dashboard = MiqWidgetSet.find_by(:owner_id => another_group.id)
      expect(dashboard.name).to eq(name)
    end

    it "copy dashboard and set its owner to the same group if no group_id parameter passed" do
      expect(MiqWidgetSet.where(:owner_id => group.id).count).to eq(1)
      dashboard = MiqWidgetSet.copy_dashboard(@ws_group, name, tab)
      expect(MiqWidgetSet.find_by(:owner_id => group.id, :name => name)).to eq dashboard
    end

    it "keeps the same set of widgets and dashboard's settings" do
      set_data = {:col1 => [1], :col2 => [2], :col3 => [], :locked => false, :reset_upon_login => false, :last_group_db_updated => Time.now.utc}
      @ws_group.update(:set_data => set_data)
      new_dashboard = MiqWidgetSet.copy_dashboard(@ws_group, name, tab)
      expect(new_dashboard.set_data).to eq set_data
    end
  end
end


text:
var fs = require('fs'),
    path = require('path'),
    settings = require('pelias-config').generate();

settings.imports.openstreetmap.datapath = path.resolve(__dirname);
settings.imports.openstreetmap.import = [{
  type: { node: 'osmnode', way: 'osmway' },
  filename: 'vancouver_canada.osm.pbf'
}];

var configPath = process.env.HOME + '/pelias.json';
fs.writeFileSync( configPath, JSON.stringify( settings ) );

redpajama_set_name: RedPajamaGithub


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

#if !NETFX_CORE
using Microsoft.VisualStudio.TestTools.UnitTesting;
#else
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
#endif

namespace TinyIoC.Tests.TypeExtensions
{
    public interface ITestInterface
    {
    }

    public class ClassImplementingITestInterface : ITestInterface
    {
    }

    public class AnotherClassImplementingITestInterface : ITestInterface
    {

    }

    public class ClassNotImplementingITestInterface
    {
    }

    [TestClass]
    public class TypeExtensionsTests
    {
        [TestMethod]
        public void GetGenericMethod_RegisterOneGenericParameterNoParameters_ReturnsCorrectMethod()
        {
            var firstGenericParameter = typeof(ClassNotImplementingITestInterface);

            var method = typeof(TinyIoCContainer).GetGenericMethod(
                BindingFlags.Public | BindingFlags.Instance,
                "Register",
                new Type[] {firstGenericParameter},
                new Type[] { }
                );

            Assert.IsInstanceOfType(method, typeof(MethodInfo));
            Assert.IsTrue(method.IsGenericMethod);
            Assert.AreEqual(0, method.GetParameters().Length);
            Assert.AreEqual(1, method.GetGenericArguments().Length);
            Assert.AreEqual(firstGenericParameter, method.GetGenericArguments()[0]);
        }

        [TestMethod]
        public void GetGenericMethod_RegisterTwoAcceptableGenericParameterNoParameters_ReturnsCorrectMethod()
        {
            var firstGenericParameter = typeof(ITestInterface);
            var secondGenericParameter = typeof(ClassImplementingITestInterface);

            var method = typeof(TinyIoCContainer).GetGenericMethod(
                BindingFlags.Public | BindingFlags.Instance,
                "Register",
                new Type[] { firstGenericParameter, secondGenericParameter },
                new Type[] { }
                );

            Assert.IsInstanceOfType(method, typeof(MethodInfo));
            Assert.IsTrue(method.IsGenericMethod);
            Assert.AreEqual(0, method.GetParameters().Length);
            Assert.AreEqual(2, method.GetGenericArguments().Length);
            Assert.AreEqual(firstGenericParameter, method.GetGenericArguments()[0]);
            Assert.AreEqual(secondGenericParameter, method.GetGenericArguments()[1]);
        }

        [TestMethod]
        public void GetGenericMethod_TwiceWithDifferentGenericParamters_ReturnsCorrectMethods()
        {
            var methodOneFirstGenericParameter = typeof(ITestInterface);
            var methodOneSecondGenericParameter = typeof(ClassImplementingITestInterface);
            var methodTwoFirstGenericParameter = typeof(ITestInterface);
            var methodTwoSecondGenericParameter = typeof(AnotherClassImplementingITestInterface);

            var methodOne = typeof(TinyIoCContainer).GetGenericMethod(
                BindingFlags.Public | BindingFlags.Instance,
                "Register",
                new Type[] { methodOneFirstGenericParameter, methodOneSecondGenericParameter },
                new Type[] { });
            var methodTwo = typeof(TinyIoCContainer).GetGenericMethod(
                BindingFlags.Public | BindingFlags.Instance,
                "Register",
                new Type[] { methodTwoFirstGenericParameter, methodTwoSecondGenericParameter },
                new Type[] { });

            Assert.IsInstanceOfType(methodOne, typeof(MethodInfo));
            Assert.IsTrue(methodOne.IsGenericMethod);
            Assert.AreEqual(0, methodOne.GetParameters().Length);
            Assert.AreEqual(2, methodOne.GetGenericArguments().Length);
            Assert.AreEqual(methodOneFirstGenericParameter, methodOne.GetGenericArguments()[0]);
            Assert.AreEqual(methodOneSecondGenericParameter, methodOne.GetGenericArguments()[1]);
            Assert.IsInstanceOfType(methodTwo, typeof(MethodInfo));
            Assert.IsTrue(methodTwo.IsGenericMethod);
            Assert.AreEqual(0, methodTwo.GetParameters().Length);
            Assert.AreEqual(2, methodTwo.GetGenericArguments().Length);
            Assert.AreEqual(methodTwoFirstGenericParameter, methodTwo.GetGenericArguments()[0]);
            Assert.AreEqual(methodTwoSecondGenericParameter, methodTwo.GetGenericArguments()[1]);
        }

        [TestMethod]
        public void GetGenericMethod_RegisterTwoUnacceptableGenericParameterNoParameters_Throws()
        {
            try
            {
                var method = typeof(TinyIoCContainer).GetGenericMethod(
                    BindingFlags.Public | BindingFlags.Instance,
                    "Register",
                    new Type[] { typeof(ITestInterface), typeof(ClassNotImplementingITestInterface) },
                    new Type[] { }
                    );

                Assert.Fail();
            }
            catch (System.ArgumentException)
            {
            }
        }

        [TestMethod]
        public void GetGenericMethod_RegisterTwoAcceptableGenericParameterMethodParameters_ReturnsCorrectMethod()
        {
            var firstGenericParameter = typeof(ITestInterface);
            var secondGenericParameter = typeof(ClassImplementingITestInterface);
            var firstParameter = typeof(string);

            var method = typeof(TinyIoCContainer).GetGenericMethod(
                BindingFlags.Public | BindingFlags.Instance,
                "Register",
                new Type[] { firstGenericParameter, secondGenericParameter },
                new Type[] { firstParameter }
                );

            Assert.IsInstanceOfType(method, typeof(MethodInfo));
            Assert.IsTrue(method.IsGenericMethod);
            Assert.AreEqual(1, method.GetParameters().Length);
            Assert.AreEqual(firstParameter, method.GetParameters()[0].ParameterType);
            Assert.AreEqual(2, method.GetGenericArguments().Length);
            Assert.AreEqual(firstGenericParameter, method.GetGenericArguments()[0]);
            Assert.AreEqual(secondGenericParameter, method.GetGenericArguments()[1]);
        }

        [TestMethod]
        public void GetGenericMethod_RegisterWithGenericTypeAsAMethodParameter_ReturnsCorrectMethod()
        {
            var firstGenericParameter = typeof(ITestInterface);
            var secondGenericParameter = typeof(ClassImplementingITestInterface);
            var firstParameter = typeof(ClassImplementingITestInterface);

            var method = typeof(TinyIoCContainer).GetGenericMethod(
                BindingFlags.Public | BindingFlags.Instance,
                "Register",
                new Type[] { firstGenericParameter, secondGenericParameter },
                new Type[] { firstParameter }
                );

            Assert.IsInstanceOfType(method, typeof(MethodInfo));
            Assert.IsTrue(method.IsGenericMethod);
            Assert.AreEqual(1, method.GetParameters().Length);
            Assert.AreEqual(firstParameter, method.GetParameters()[0].ParameterType);
            Assert.AreEqual(2, method.GetGenericArguments().Length);
            Assert.AreEqual(firstGenericParameter, method.GetGenericArguments()[0]);
            Assert.AreEqual(secondGenericParameter, method.GetGenericArguments()[1]);
        }
    }
}


text:
@interface WebViewController ()

@end

@implementation WebViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.

	self.webview.delegate = self;

	//NSURL *url = [NSURL URLWithString:[self.urlSite stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
	//NSMutableURLRequest *requestObj = [NSMutableURLRequest requestWithURL:url];
	//[requestObj setHTTPShouldHandleCookies:YES];

	//[self.webview loadRequest:requestObj];

	self.title = self.tituloSite;

}

- (void)viewWillAppear:(BOOL)animated
{
	NSArray                 *cookies;
    NSDictionary            *cookieHeaders;
    NSMutableURLRequest     *request;

	NSURL *url = [NSURL URLWithString:[self.urlSite stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

    cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage ] cookiesForURL: url];
    if (!cookies) {
        return;
    }

    cookieHeaders = [NSHTTPCookie requestHeaderFieldsWithCookies: cookies];
    request = [[NSMutableURLRequest alloc] initWithURL: url];
    [request setValue: [cookieHeaders objectForKey: @"Cookie"] forHTTPHeaderField: @"Cookie"];
    [self.webview loadRequest: request];
}

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

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    return YES;
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
	[self.indicator startAnimating];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{

	NSString *jsCommand = [NSString stringWithFormat:
						   @"var elBarra = document.getElementById('%@'); elBarra.parentElement.removeChild(elBarra); $('header').remove();", @"barraGoverno"];
	[self.webview stringByEvaluatingJavaScriptFromString:jsCommand];

    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
	[self.indicator stopAnimating];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}

@end


text:
=head1 NAME

SWISH-RUN - Running Swish-e and Command Line Switches

=head1 OVERVIEW

The Swish-e program is controlled by command line arguments (called
I<switches>).  Often, it is run manually from a shell (command
prompt), or from a program such as a CGI script that passes the command
line arguments to swish.

Note: A number of the command line switches may be specified in the
Swish-e configuration file specified with the C<-c> command line argument.
Please see L<SWISH-CONFIG|SWISH-CONFIG> for a complete description of
available configuration file directives.

There are two basic operating modes of Swish-e: indexing and searching.
There are command line arguments that are unique to each mode, and
others that apply to both (yet may have different meaning depending on
the operating mode).  These command line arguments are listed below,
grouped by:

L<INDEXING|/"INDEXING"> -- describes the command line arguments used
while indexing.

L<SEARCHING|/"SEARCHING"> -- lists the command line arguments used while
searching.

L<OTHER SWITCHES|/"OTHER SWITCHES"> -- lists switches that don't apply
to searching or indexing.

Beginning with Swish-e version 2.1, you may embed its search engine into
your applications.  Please see L<SWISH-LIBRARY|SWISH-LIBRARY>.

=head1 INDEXING

Swish-e indexing is initiated by passing I<command line arguments> to
swish.  The command line arguments used for I<searching> are described
in L<SEARCHING|/"SEARCHING">.  Also, see L<SWISH-SEARCH|SWISH-SEARCH>
for examples of searching with Swish-e.

Swish-e usage:

    swish-e [-i dir file ... ] [-c file] [-f file] [-l] \
            [-v (num)] [-S method(fs|http|prog)] [-N path]

The C<-h> switch (help) will list the available Swish-e command line
arguments:

    swish-e -h

Typically, most if not all indexing settings are placed in a configuration
file (specified with the C<-c> switch).  Once the configuration file is
setup indexing is initiated as:

    swish-e -c /path/to/config/file

See L<SWISH-CONFIG|SWISH-CONFIG> for information on the configuration
file.

Security Note: If the swish binary is named F<swish-search> then swish
will not allow any operation that would cause swish to write to the
index file.

When indexing it may be advisable to index to a temporary file, and
then after indexing has successfully completed rename the file to the
final location.  This is especially important when replacing an index
that is currently in use.

    swish-e -c swish.config -f index.tmp
    [check return code from swish or look for err: output]
    mv index.tmp index.swish-e

=head2 Indexing Command Line Arguments

=over 4

=item -i *directories and/or files* (input file)

This specifies the directories and/or files to index. Directories will be
indexed recursively.  This is typically specified in the L<configuration
file|SWISH-CONFIG> with the B<IndexDir> directive instead of on the
command line.  Use of this switch overrides the configuration file
settings.

=item -S [fs|http|prog] (document source/access mode)

This specifies the method to use for accessing documents to index.
Can be either C<fs> for local indexing via the file system (the default),
C<http> for spidering, or C<prog> for reading documents from an external program.

Located in the C<conf> directory are example configuration files that demonstrate
indexing with the different document source methods.

See the L<SWISH-FAQ|SWISH-FAQ> for a discussion on the different indexing methods, and the difference
between spidering with the http method vs. using the file system method.

=over 4

=item fs - file system

The C<fs> method simply reads files from a local (or networked) drive.  This is the default
method if the C<-S> switch is not specified.
See L<SWISH-CONFIG|SWISH-CONFIG> for configuration
directives specific to the C<fs> method.

=item http - spider a web server

The C<http> method is used to spider web servers.  It uses an included helper
program called F<swishspider>.  See L<SWISH-CONFIG|SWISH-CONFIG> for configuration
directives specific to the C<http> method.

Security Note: Under Windows swish passes the URLs fetched from remote documents through the shell (swish
uses the system() command for running F<swishspider> under Windows), and this may be considered
an additional security risk.

The C<http> method is deprecated (or at least not very well appreciated).  Consider using
the C<prog> method described below for spidering.  There's a spider program available in the
F<prog-bin> directory for use with the C<prog> method.  Here's a number of limitation with
this method that are solved with the C<prog> method:

=over 4

=item *

swishspider only spiders standard E<lt>a href="..."E<gt> links.  Frames and other links are
not followed.

=item *

By default, this method of spidering only indexes files that have a content type of "text/*"
(e.g. text/plain, text/html, text/xml).  You should use C<DefaultContents> and C<IndexContents> to
map file extensions to parsers used by swish (e.g.  C<IndexContents HTML* .html .htm>), but
this will fail where a document does not have a file extension.

=item *

Swish-e's C<FileFilter> directive can be used with the C<http> access method, although it
requires a separate process (in addition to the swsihspider process) for each document
filtered.

=item *

The SWISH::Filter modules can be used with the swishspider program.  SWISH::Filter provides
a general purpose filtering system (see SWISH::Filter documentation).  To use SWISH::Filter
set PERL5LIB to point to the location of the SWISH module name space (typically
/usr/local/lib/swish-e under Unix).  For example:

   export PERL5LIB=/usr/local/lib/swish-e  # bash, bourne shells
   setenv PERL5LIB /usr/local/lib/swish-e  # csh, tcsh

or under Windows

   set PERL5LIB=c:\program files\swish-e2.4\lib\swish-e

SWISH::Filter is not enabled by default due to the overhead of loading the modules for every
document fetched.

The Swish-e distribution includes perl modules in the SWISH::Filters::* namespace to make
converting non-text documents into a format that Swish-e can parse easy.  As mentioned
above, the helper script
F<swishspider> will use these modules if can be found via PERL5LIB.  These modules only
provide an interface
to programs that do the conversion.  For example, you will need to download and install the
"catdoc" program to convert MSWord documents into text for indexing. Please see
F<filters/README> to see how to use this filter system.

=back

=item prog - general purpose access method

The C<prog> method is new to Swish-e version 2.2.  It's designed as a general
purpose method to feed documents to swish from an external program.

For example, the external program can read a database (e.g. MySQL), spider a web
server, or convert documents from one format to another (e.g. pdf to html).  Or,
you can simply use it to read the files of the file system (like C<-S fs>), yet provide
you with full control of what files are indexed.

The external program name to run is passed to swish either by the
L<IndexDir|SWISH-CONFIG/"item_IndexDir"> directive, or via the C<-i> option.

The program specified should be an absolute path as swish-e will attempt to stat() the
program to make sure it exists.  Swish does this to help in error reporting.

If the program specified with -i or IndexDir is not an absolute path (i.e.
does not include "/" ) then swish-e will append the "libexecdir" directory
defined during configuration.  Typically, libexecdir is set to
"$prefix/lib/swish-e" (/usr/local/lib/swish-e), but is platform and
installation dependent.  Running swish-e -h will report the directory.

For example, the -S prog program "spider.pl" is a Perl helper program for use with -S prog
and is installed in libexecdir.

    IndexDir spider.pl
    SwishProgParameters default http://localhost/index.html

and swish-e will find spider.pl in libexecdir.

Additional parameters may be passed to the external program via the
L<SwishProgParameters|SWISH-CONFIG/"item_SwishProgParameters"> directive.
In the example above swish-e will pass two parameters to spider.pl, "default" and
"http://localhost/index.html".

A special name "stdin" may be used with C<-i> or L<IndexDir|SWISH-CONFIG/"item_IndexDir">
which tells swish to read from standard input instead of from an external program.  See
example below.

The external program prints to standard output (which swish captures)
a set of headers followed by the content of the file to index.  The output looks similar to
an email message or a HTTP document returned by a web server in that it includes name/value pairs
of headers, a blank line, and the content.

The content length is determined by a content-length header supplied to swish by the
program; there is no "end of record" character or flag sent between documents. Therefore, it
is critical that the content-length header is correct.  This is a common source of errors.

One advantage of this method (over using filters, for example) is that the external program
is run only once for the entire indexing job, instead of once for every document.  This
avoids forking and creating a new process for every document, and makes a huge difference
when your external program is something like perl that has a large startup cost.

Here's a simple example written in Perl:

    #!/usr/local/bin/perl -w
    use strict;

    # Build a document
    my $doc = <<EOF;
    <html>
    <head>
        <title>Document Title</title>
    </head>
        <body>
            This is the text.
        </body>
    </html>
    EOF

    # Prepare the headers for swish
    my $path = 'Example.file';
    my $size = length $doc;
    my $mtime = time;

    # Output the document (to swish)
    print <<EOF;
    Path-Name: $path
    Content-Length: $size
    Last-Mtime: $mtime
    Document-Type: HTML*

    EOF

        print $doc;

The external program passes to swish a header.  The header is separated from
the body of the document with a blank line.  The available headers are:

=over 4

=item Path-Name:

This is the name of the file you are indexing. This can be any string, so for example it could
be an ID of a record in a database, a URL or a simple file name.

This header is required.

=item Content-Length:

This header specifies the length in bytes of the document that follows the header.
This length must be exactly the length of the document -- do not make the mistake of adding
an extra line feed at the end of the document.

This header is required.

=item Last-Mtime:

Thi parameter is the last modification time of the file, and must
be a time stamp (seconds since the Epoch on your platform).

This header is not required.

=item Document-Type:

You may override swish's determination of document type (C<Indexcontents>)
by using the C<Document-Type:> header.  The document type is used to select which
parser Swish-e uses to parse the document's contents.

For example, a spider program might map the content-type returned from a web server to
one of the types Swish-e understands.  For example,

    my $doc_type = 'HTML*' if $response->content_type =~ m!text/html!'

This header is not required.

=item Update-Mode:

When updating an incremental index this header can be used to select the mode
for updating the index.  There are three possible values:

    Update
    Remove
    Index

"Update" will update the index with the given file if the date of the given file is
newer than the date of the file already in the index.  Setting to "Update"
is the same as using -u on the command line.

"Remove" mode will remove the file specified by the Path-Name header.
Setting "Remove" is the same as using -r on the command line.

"Index" will add the file to the index. NOTE: swish-e will not check to see if the file
already exists.

If this header is not specified, the default is the mode specified on
the command line (-u, -r, or none).

This option is still experimental and is subject to change in the future.
Ask on the Swish-e list before using.

=back

The above example program only returns one document and exits, which is not very useful.  Normally,
your program would read data from some source, such as files or a database, format as
XML, HTML, or text, and pass them to swish, one after another.  The C<Content-Length:> header
tells swish where each document ends -- there is not any special "end of record" character or
marker.

To index with the above example you need to make sure that the program is executable
(and that the path to perl is correct), and then call swish telling to run in C<prog>
mode, and the name of the program to use for input.

    % chmod 755 example.pl
    % ./swish-e -S prog -i ./example.pl

Programs can and should be tested prior to running swish. For example:

    % ./example.pl > test.out

A few more useful example programs are provided in the swish-e distribution
located in the F<prog-bin> directory.  Some include documentation:

    % cd prog-bin
    % perldoc spider.pl

Others are small examples that include comments:

    % cd prog-bin
    % less DirTree.pl

The F<spider.pl> program can be used as a replacement for the F<-S http> method.  It is
far more feature-rich and offers much more control over indexing.

If you use the special program name "stdin" with C<-i> or L<IndexDir|SWISH-CONFIG/"item_IndexDir">
then swish-e will read from standard input instead of from a program.  For example:

    % ./example.pl --count=1000 /path/to/data | ./swish-e -S prog -i stdin

This is basically the same as using a swish-e configuration file of:

    SwishProgParameters --count=1000 /path/to/data
    IndexDir ./example.pl

in a config file and running

    % ./swish-e -S prog -c swish.conf

This gives an easy way to run swish without a configuration file with a C<-S prog> program
that requires parameters.  It also means you can capture data to a file and then index
more once with the same data:

    % ./example.pl /path/to/data --count=1000 > docs.txt
    % cat docs.txt | ./swish-e -S prog -i stdin -c normal_index
    % cat docs.txt | ./swish-e -S prog -i stdin -c fuzzy_index

Using "stdin" might also be useful for programs that call swish (instead of swish calling the
program).

(The reason "stdin" is used instead of the more common "-" dash is due to the rotten way
swish parses the command line.  This should be fixed in the future.)

The C<prog> method bypasses some of the configuration parameters available
to the file system method -- settings such as
C<IndexOnly>, C<FileRules>, C<FileMatch> and C<FollowSymLinks>
are ignored when using the C<prog> method.  It's expected that these operations
are better accomplished in the external program before passing the document onto swish.  In
other words, when using the C<prog> method, only send the documents to swish
that you want indexed.

You may use swish's filter feature with the C<prog> method, but performance will be better if you
run filtering programs from within your external program.  See also F<filters/README> for an example
how to easily add document converstion and filtering into your Perl-based programs.

B<Notes when using -S prog on MS Windows>

Windows does not use the shebang (#!) line of a program to determine the
program to run.  So, when running, for example, a perl program you may need
to specify the perl.exe binary as the program, and use the
C<SwishProgParameters> to name the file.

    IndexDir e:/perl/bin/perl.exe
    SwishProgParameters read_database.pl

Swish will replace the forward slashes with backslashes before running the command specified with
C<IndexDir>.  Swish uses the popen(3) command which passes the command through the shell.

=back

=item -f *indexfile* (index file)

If you are indexing, this specifies the file to save the generated index in,
and you can only specify one file.  See also B<IndexFile> in the L<configuration file|SWISH-CONFIG>.

If you are searching, this specifies the index
files (one or more) to search from. The default index file is index.swish-e in the current directory.

=item -c *file ...* (configuration files)

Specify the configuration file(s) to use for indexing.  This file contains many directives that
control how Swish-e proceeds.
See L<SWISH-CONFIG|SWISH-CONFIG> for a complete listing of configuration file directives.

Example:

    swish-e -c docs.conf

If you specify a directory to index, an index file, or the verbose option on the command-line,
these values will override any specified in the configuration file.

You can specify multiple configuration files.  For example, you may have one configuration file
that has common site-wide settings, and another for a specific index.

Examples:

    1) swish-e -c swish-e.conf
    2) swish-e -i /usr/local/www -f index.swish-e -v -c swish-e.conf
    3) swish-e -c swish-e.conf stopwords.conf

=over 3

=item 1

The settings in the configuration file will be used to index a site.

=item 2

These command-line options will override anything in the configuration file.

=item 3

The variables in swish-e.conf will be read, then the variable in stopwords.conf will be read.
Note that if the same variables occur in both files, older values may be written over.

=back

=item -e (economy mode)

For large sites indexing may require more RAM than is available.  The C<-e> switch tells swish to use
disk space to store data structures while indexing, saving memory.  This option is recommended if
swish uses so much RAM that the computer begins to swap excessively, and you cannot increase available
memory.  The trade-off is slightly longer indexing times, and a busy disk drive.

=item -l (symbolic links)

Specifying this option tells swish to follow symbolic links when indexing.
The configuration file value B<FollowSymLinks> will override the command-line value.

The default is not to follow symlinks.  A small improvement in indexing time my result
from enabling FollowSymLinks since swish does not need to stat every directory and file
processed to determine if it is a symbolic link.

=item -N path (index only newer files)

The C<-N> option takes a path to a file, and only files I<newer> than the specified
file will be indexed.  This is helpful for creating incremental indexes -- that is,
indexes that contain just files added since the last full index was created of all files.

Example (bad example)

    swish-e -c config.file -N index.swish-e -f index.new

This will index as normal, but only files with a modified date newer
than F<index.swish-e> will be indexed.

This is a bad example because it uses F<index.swish-e> which one might assume
was the date of last indexing.  The problem is that files might have been added
between the time indexing read the directory and when the F<index.swish-e> file
was created -- which can be quite a bit of time for very large indexing jobs.

The only solution is to prevent any new file additions while full indexing is running.
If this is impossible then it will be slightly better to do this:

Full indexing:

    touch indexing_time.file
    swish-e -c config.file -f index.tmp
    mv index.tmp index.full

Incremental indexing:

    swish-e -c config.file -N indexing_time.file -f index.tmp
    mv index.tmp index.incremental

Then search with

    swish-e -w foo -f index.full index.incremental

or merge the indexes

    swish-e -M index.full index.incremental index.tmp
    mv index.tmp index.swish-e
    swish-e -w foo

=item -r

B<**incremental index format only**>
The C<-r> option puts swish-e into "removal" mode. Any input files (given with C<-i>
or the C<IndexDir> parameter) are removed from an existing index.

Example:

  swish-e -r -i file.html

would remove F<file.html> from the existing index.

=item -u

B<**incremental index format only**>
The C<-u> option puts swish-e into "update" mode. The timestamp of each input
file is compared against the corresponding file in the existing index.
If swish-e encounters an input file that either
does not exist yet in the index or exists with a timestamp older than the input file,
the input file is updated in the index. Any words in the input file
that have been added or removed are reflected as such in the index.

Example:

  swish-e -i file.html -u

would update the index.swish-e index with the contents of file.html. If file.html
was new, it would be added. If file.html already existed in the index, its contents
would be updated in the index.

=item -v [0|1|2|3] (verbosity level)

The C<-v> option can take a numerical value from 0 to 3.
Specify 0 for completely silent operation and 3 for detailed reports.

If no value is given then 1 is assumed.
See also B<IndexReport> in the L<configuration file|SWISH-CONFIG>.

Warnings and errors are reported regardless of the verbosity level.  In addition,
all error and warnings are written to standard out.  This is for historical reasons (many
scripts exist that parse standard out for error messages).

=item -W (0|1|2|3) (parser warning level)

If using the libxml2 parser, the default parser warning level is set at C<2>. Use the C<-W>
option to override that default. Most often, you might want to turn it off altogether:

  swish-e -W0 -i path/to/files

would fail silently if the parser encountered any errors.

=back

=head1 SEARCHING

The following command line arguments are available when searching with Swish-e.  These switches are used
to select the index to search, what fields to search, and how and what to print as results.

This section just lists the available command line arguments and their usage.
Please see L<SWISH-SEARCH|SWISH-SEARCH> for detailed searching instructions.

B<Warning>: If using Swish-e via a CGI interface, please see L<CGI Danger!|SWISH-SEARCH/"CGI Danger!">

Security Note: If the swish binary is named F<swish-search> then swish will not allow any operation that
would cause swish to write to the index file.

=head2 Searching Command Line Arguments

=over 4

=item -w *word1 word2 ...*  (query words)

This performs a case-insensitive search using a number of keywords.
If no index file to search is specified (via the C<-f> switch), swish-e will try to search a file called
index.swish-e in the current directory.

    swish-e -w word

Phrase searching is accomplished by placing the quote delimiter (a double-quote by default) around
the search phrase.

    swish-e -w 'word or "this phrase"'

Search would should be protected from the shell by quotes.  Typically, this is single quotes when
running under Unix.

Under Windows F<command.com> you may not need to use quotes, but you will need to
backslash the quotes used to delimit phrases:

    swish-e -w \"a phrase\"

The phrase delimiter can be set with the C<-P> switch.

The search may be limited to a I<MetaName>.
For example:

    swish-e -w meta1=(foo or baz)

will only search within the B<meta1> tag.

Please see L<SWISH-SEARCH|SWISH-SEARCH> for a description of MetaNames

=item -f *file1 file2 ...* (index files)

Specifies the index file(s) used while searching.  More than one file may be listed, and each
file will be searched.  If no C<-f> switch is specified then the file F<index.swish-e> in the current
directory will be used as the index file.

=item -m *number* (max results)

While searching, this specifies the maximum number of results to return.
The default is to return all results.

This switch is often used in conjunction with the C<-b> switch to return results one
page at a time (strongly recommended for large indexes).

=item -b *number* (beginning result)

Sets the I<begining> search result to return (records are numbered from 1).  This switch can be used
with the C<-m> switch to return results in groups or pages.

Example:

    swish-e -w 'word' -b 1 -m 20    # first 'page'
    swish-e -w 'word' -b 21 -m 20   # second 'page'

=item -t HBthec (context searching)

The C<-t> option allows you to search for words that exist only
in specific HTML tags. Each character in the string you
specify in the argument to this option represents a
different tag in which to search for the word. H means all HEAD
tags, B stands for BODY tags, t is all TITLE tags, h is H1
to H6 (header) tags, e is emphasized tags (this may be B, I,
EM, or STRONG), and c is HTML comment tags

search only in header (E<lt>H*E<gt>) tags

    swish-e -w word -t h

=item -d *string* (delimiter)

Set the delimiter used when printing results.  By default, Swish-e separates
the output fields by a space, and places double-quotes around the document
title.  This output may be hard to parse, so it is recommended to use C<-d> to
specify a character or string used as a separator between fields.

The string C<dq> means "double-quotes".

    swish-e -w word -d ,    # single char
    swish-e -w word -d ::   # string
    swish-e -w word -d '"'  # double quotes under Unix
    swish-e -w word -d \"   # double quotes under Windows
    swish-e -w word -d dq   # double quotes

The following control characters may also be specified: C<\t \r \n \f>.

Warning: This string is passed directly to sprintf() and therefore exposes a securty
hole.  Do not allow user data to set -d format strings directly.

=item -P *character*

Sets the delimiter used for phrase searches.  The default is double quotes C<">.

Some examples under bash: (be careful about you shell metacharacters)

    swish-e -P ^ -w 'title=^words in a phrase^'
    swish-e -P \' -w "title='words in a pharse"'

=item -p *property1 property2 ...*  (display properties)

This causes swish to print the listed property in the search results.  The properties
are returned in the order they are listed in the C<-p> argument.

Properties are defined by the B<ProperNames> directive in the configuration file (see L<SWISH-CONFIG|SWISH-CONFIG>)
and properties must also be defined in B<MetaNames>.  Swish stores the text of the meta name as a I<property>, and
then will return this text while searching if this option is used.

Properties are very useful for returning data included in a source documnet without having to re-read
the source document while searching.  For example, this could be used to return a short document description.
See also see B<Document Summeries> and L<PropertyNames|SWISH-CONFIG/"item_PropertyNames"> in L<SWISH-CONFIG|SWISH-CONFIG>.

To return the subject and category properties while indexing.

    swish-e -w word -p subject category

Properties are returned in double quotes.   If a property contains a double quote it is HTML escaped (").
See the C<-x> switch for a more advanced method of returning a list of properties.

NOTE: it is necessary to have indexed with the proper
PropertyNames directive in the user config file in order to
use this option.

=item -s *property [asc|desc] ...*  (sort)

Normally, search results are printed out in order of relevancy, with the most relevant listed first.
The C<-s> sort switch allows you to sort results in order of a specified I<property>, where a I<property>
was defined using the B<MetaNames> and B<PropertyNames> directives during indexing
(see L<SWISH-CONFIG|SWISH-CONFIG>).

The string passed can include the strings C<asc> and C<desc> to specify the sort order, and more than
one property may be specified to sort on more than one key.

Examples:

sort by title property ascending order

    -s title

sort descending by title, ascending by name

    -s title desc name asc

Note: Swish limits sort keys to 100 characters.  This limit can be changed
by changing MAX_SORT_STRING_LEN in src/config.h and rebuilding swish-e.

=item -L limit to a range of property values (Limit)

B<This is an experimental feature!>

The C<-L> switch can be used to limit search results to a range of property values

Example:

    swish-e -w foo -L swishtitle a m

finds all documents that contain the word C<foo>, and where the
document's title is in the range of C<a> to C<m>, inclusive.
By default, the case of the property is ignored, but this can be
changed by using L<PropertyNamesCompareCase|SWISH-CONFIG/"item_PropertyNamesCompareCase">
configuation directive.

Limiting may be done with user-defined properties, as well.

For example, if you indexed documents that contain a created timestamp in a meta tag:

    <meta name="created_on" content="982648324">

Then you tell Swish that you have a property called C<created_on>, and that
it's a timestamp.

    PropertyNamesDate created_on

After indexing you will be able to limit documents to a range of timestamps:

    -w foo -L created_on  946684800 949363199

will find documents containing the word foo and that have a created_on
date from the start of Jan 1, 2000 to the end of Jan 31, 2000.

Note: swish currently does not parse dates; Unix timestamps must be used.

Two special formats can be used:

    -L swishtitle <= m
    -L swishtitle >= m

Finds titles less than or equal, or grater than or equal to the letter C<m>.

This feature will not work with C<swishrank> or C<swishdbfile> properties.

This feature takes advantages of the pre-sorted tables built by swish during indexing to
make this feature fast while searching.
You should see in the indexing output a line such as:

   6 properties sorted.

That indicates that six pre-sorted tables were built during indexing.
By default, all properties are presorted while indexing.
What properties are pre-sorted can be controlled by the configuration parameter C<PreSortedIndex>.

Using the C<-L> switch on a property that was not pre-sorted will still work, but may be I<much>
slower during searching.

Note that the PropertyNamesSortKeyLength setting is used for sorting properties.
Using too small a PropertyNamesSortKeyLength could result in -L selecting
the wrong properties due to incomplete sorting.

This is an experimental feature, and its use and interface are subject to change.

=item -x formatstring (extended output format)

The C<-x> switch defines the output format string.  The format string can
contain plain text and property names (including swish-defined internal
property names) and is used to generate the output for every result.  In
addition, the output format of the property name can be controlled with C-like
printf format strings.  This feature overrides the cmdline switches C<-d> and
C<-p>, and a warning will be generated if C<-d> or C<-p> are used with C<-x>.

Warning: The format string (fmt) is passed directly to sprintf() and therefore exposes a securty
hole.  Do not allow user data to set -x format strings directly.

For example, to return just the title, one per line, in the search results:

    swish-e  -w ...   -x '<swishtitle>\n' ...

Note: the C<\n> may need to be protected from your shell.

See also L<ResultExtFormatName|SWISH-CONFIG/"item_ResultExtFormatName"> for a way to define I<named>
format strings in the swish configuration file.

B<Format of "formatstring":>

    "text<propertyname>text<propertyname fmt=propfmtstr>text..."

Where B<propertyname> is:

=over 4

=item *

the name of a user property as specified with the config file
directive "PropertyNames"

=item *

the name of a swish Auto property (see below).  These properties are
defined automatically by swish -- you do not need to specify them
with PropertyNames directive.  (This may change in the future.)

=back

propertynames must be placed within "E<lt>" and "E<gt>".

B<User properties:>

Swish-e allows you to specify certain META tags within your documents that can be used as B<document properties>.
The contents of any META tag that has been identified as a document property can be returned as
part of the search results.  Doucment properties must be defined while indexing using the B<PropertyNames>
configuration directive (see L<SWISH-CONFIG|SWISH-CONFIG/"item_PropertyNames">).

Examples of user-defined PropertyNames:

    <keywords>
    <author>
    <deliveredby>
    <reference>
    <id>

B<Auto properties:>

Swish defines a number of "Auto" properties for each document indexed.
These are available for output when using the C<-x> format.

    Name               Type     Contents
    --------------     -------  ----------------------------------------------
    swishreccount      Integer  Result record counter
    swishtitle         String   Document title
    swishrank          Integer  Result rank for this hit
    swishdocpath       String   URL or filepath to document
    swishdocsize       Integer  Document size in bytes
    swishlastmodified  Date     Last modified date of document
    swishdescription   String   Description of document (see:StoreDescription)
    swishdbfile        String   Path of swish database indexfile

The Auto properties can also be specified using shortcuts:

    Shortcut    Property Name
    --------    --------------
      %c        swishreccount
      %d        swishdescription
      %D        swishlastmodified
      %I        swishdbfile
      %p        swishdocpath
      %r        swishrank
      %l        swishdocsize
      %t        swishtitle

For example, these are equivalent:

   -x '<swishrank>:<swishdocpath>:<swishtitle>\n'
   -x '%r:%p:%t\n'

Use a double percent sign "%%" to enter a literal percent sign in the output.

B<Formatstrings of properties:>

Properties listed in an C<-x> format string can include format control strings.
These "propertyformats" are used to control how the contents of the associated property are printed.
Property formats are used like C-language printf formats.
The property format is specified by including the attribute "fmt" within the property tag.

Format strings cannot be used with the "%" shortcuts described above.

General syntax:

    -x '<propertyname fmt="propfmtstr">'

where C<subfmt> controls the output format of C<propertyname>.

Examples of property format strings:

        date type:    <swishlastmodified fmt="%d.%m.%Y">
        string type:  <swishtitle fmt="%-40.35s">
        integer type: <swishreccount fmt=/%8.8d/>

Please see the manual pages for strftime(3) and sprintf(3) for an explanation of
format strings.  Note: some versions of strftime do not offer the %s format string
(number of seconds since the Epoch), so swish provides a special format string "%ld"
to display the number of seconds since the Epoch.

The first character of a property format string defines the delimiter for the format string.
For example,

    -x  "<author  fmt=[%20s]> ...\n"
    -x  "<author  fmt='%20s'> ...\n"
    -x  "<author  fmt=/%20s/> ...\n"

B<Standard predefined formats:>

If you ommit the sub-format, the following formats are used:

    String type:       "%s"  (like printf char *)
    Integer type:      "%d"  (like printf int)
    Float type:        "%f"  (like printf double)
    Date type:         "%Y-%m-%d %H:%M:%S" (like strftime)

B<Text in "formatstring" or "propfmtstr":>

Text will be output as-is in format strings (and property format strings).
Special characters can be escaped with a backslash.
To get a new line for each result hit, you have to include
the Newline-Character "\n" at the end of "fmtstr".

    -x "<swishreccount>|<swishrank>|<swishdocpath>\n"
    -x "Count=<swishreccount>, Rank=<swishrank>\n"
    -x "Title=\<b\><swishtitle>\</b\>"
    -x 'Date: <swishlastmodified fmt="%m/%d/%Y">\n'
    -x 'Date in seconds: <swishlastmodified fmt=/%ld/>\n'

B<Control/Escape charcters:>

you can use C-like control escapes in the format string:

   known controls:      \a, \b, \f, \n, \r, \t, \v,
   digit escapes:       \xhexdigits   \0octaldigits
   character escapes:   \anychar

Example,

    swish -x "%c\t%r\t%p\t\"<swishtitle fmt=/%40s/>\"\n"

B<Examples of -x format strings:>

    -x "%c|%r|%p|%t|%D|%d\n"
    -x "%c|%r|%p|%t|<swishdate fmt=/%A, %d. %B %Y/>|%d\n"
    -x "<swishrank>\t<swishdocpath>\t<swishtitle>\t<keywords>\n
    -x "xml_out: \<title\><swishtitle>\>\</title\>\n"
    -x "xml_out: <swishtitle fmt='<title>%s</title>'>\n"

=item -H [0|1|2|3|E<lt>nE<gt>]  (header output verbosity)

The C<-H n> switch generates extened I<header> output.  This is most useful when searching more than one
index file at a time by specifying more than one index file with the C<-f> switch.
C<-H 2> will generate a set of headers specific to each index file.
This gives access to the settings used to generate each index file.

Even when searching a single index file, C<-H n> will provided additional information about the index file,
how it was indexed, and how swish is interperting the query.

    -H 0 : print no header information, output only search result entries.
    -H 1 : print standard result header (default).
    -H 2 : print additional header information for each searched index file.
    -H 3 : enhanced header output (e.g. print stopwords).
    -H 9 : print diagnostic information in the header of the results (changed from: C<-v 4>)

=item -R [0|1] (Ranking Scheme)

B<This is an experimental feature!>

The default ranking scheme in SWISH-E evaluates each word in a query in terms of its frequency
and position in each document. The default scheme is 0.

New in version 2.4.3 you may optionally select an experimental ranking scheme that, in addition
to document frequency and position, uses Inverse Document Frequency (IDF),
or the relative frequency of each word across all the indexes
being searched, and Relative Density, or the normalization of the frequency of a word
in relationship to the number of words in the document.

B<NOTE:> IgnoreTotalWordCountWhenRanking must be set to B<no> or B<0> in your index(es)
for -R 1 to work.

Specify -R 1 to turn on IDF ranking. See the API documentation for how to set
the ranking scheme in your Perl or C program.

=back

=head1 OTHER SWITCHES

=over 4

=item -V (version)

Print the current version.

=item -k *letter* (print out keywords)

The C<-k> switch is used for testing and will cause swish to print out all keywords
in the index beginning with that letter.  You may enter C<-k '*'> to generate a list of all words indexed
by swish.

=item -D *index file*  (debug index)

The -D option is no longer supported in version 2.2.

=item -T *options* (trace/debug swish)

The -T option is used to print out information that may be helpful when debugging swish-e's
operation.  This option replaced the C<-D> option of previous versions.

Running C<-T help> will print out a list of available *options*

=back

=head1 Merging Index Files

In previous versions of Swish-e indexing would require a very large amount of memory and the indexing
process could be very slow.  Merging provided a way to index in chunks and then combine the indexes together
into a single index.

Indexing is much faster now and uses much less memory, and with the C<-e> switch very little memory is
needed to index a large site.

Still, at times it can be useful to merge different index files into one file for searching.
This could be because you want to keep separate site indexes and a common one for a global search, or
you have separate collections of documents that you wish to search all at one time, but manage separately.

=over 4

=item -M *index1 index2 ... indexN out_index

Merges the indexes specified on the command line -- the last file name entered is the output file.
The output index must not exist (otherwise merge will not proceed).

Only indexes that were indexed with common settings may be merged.
(e.g. don't mix stemming and non-stemming indexes, or indexes with different WordCharacter settings, etc.).

Use the C<-e> switch while merging to reduce memory usage.

Merge generates progress messages regardless of the setting of C<-v>.

=item -c *configuration file*

Specify a configuration file while indexing to add administrative information to the output index file.

=back

=head1 Document Info

$Id: SWISH-RUN.pod 1741 2005-05-17 02:22:40Z karman $

.


text:
function mOver(chapter){
	//alert(document.getElementById(chapter).className);
		document.getElementById(chapter).className= "m_over";
//		alert(document.getElementById(chapter).className);
	}
	function mOut(chapter){

		document.getElementById(chapter).className= "m_out";
	}

function loadChildSectionInline(doctype, subtype, divid, key) { // this one is called from a solution document.. results will display inline in the right-hand box
	var udiv = document.getElementById(divid);
	if (udiv.style.display=="none") {
		udiv.style.display="";
		//var ai = new AJAXInteraction( basepath + "/ajax-childs?OpenAgent&action=getsection&solutionkey=" + key + "&divid="+divid+"&doctype=" + doctype + "&subtype="+subtype+"&timestamp="+ getCacheStamp() ,  handleHttpResponseGeneric );
		ai.doGet();
	} else {
		udiv.style.display="none";
	}

}
function getCacheStamp() {
	Stamp = new Date(); // fix for IE cache problem: add timestamp to url on reload
	return Stamp.getDay()+""+Stamp.getHours()+Stamp.getMinutes()+Stamp.getSeconds();
}

/*
function toggle( panID ) {
	if (panID == 1)
	{
		document.getElementById("liByArea").className="lotusSelected";
		document.getElementById("liMyDocuments").className="";
	}
	else if (panID == 2)
	{
		document.getElementById("liByArea").className="";
		document.getElementById("liMyDocuments").className="lotusSelected";
	}
}*/


text:
package controlapi

import (
	"errors"
	"reflect"

	"github.com/docker/engine-api/types/reference"
	"github.com/docker/swarmkit/api"
	"github.com/docker/swarmkit/identity"
	"github.com/docker/swarmkit/manager/state/store"
	"golang.org/x/net/context"
	"google.golang.org/grpc"
	"google.golang.org/grpc/codes"
)

var (
	errNetworkUpdateNotSupported = errors.New("changing network in service is not supported")
)

func validateResources(r *api.Resources) error {
	if r == nil {
		return nil
	}

	if r.NanoCPUs != 0 && r.NanoCPUs < 1e6 {
		return grpc.Errorf(codes.InvalidArgument, "invalid cpu value %g: Must be at least %g", float64(r.NanoCPUs)/1e9, 1e6/1e9)
	}

	if r.MemoryBytes != 0 && r.MemoryBytes < 4*1024*1024 {
		return grpc.Errorf(codes.InvalidArgument, "invalid memory value %d: Must be at least 4MiB", r.MemoryBytes)
	}
	return nil
}

func validateResourceRequirements(r *api.ResourceRequirements) error {
	if r == nil {
		return nil
	}
	if err := validateResources(r.Limits); err != nil {
		return err
	}
	if err := validateResources(r.Reservations); err != nil {
		return err
	}
	return nil
}

func validateServiceSpecTemplate(spec *api.ServiceSpec) error {
	if err := validateResourceRequirements(spec.Task.Resources); err != nil {
		return err
	}

	if spec.Task.GetRuntime() == nil {
		return grpc.Errorf(codes.InvalidArgument, "TaskSpec: missing runtime")
	}

	_, ok := spec.Task.GetRuntime().(*api.TaskSpec_Container)
	if !ok {
		return grpc.Errorf(codes.Unimplemented, "RuntimeSpec: unimplemented runtime in service spec")
	}

	container := spec.Task.GetContainer()
	if container == nil {
		return grpc.Errorf(codes.InvalidArgument, "ContainerSpec: missing in service spec")
	}

	if container.Image == "" {
		return grpc.Errorf(codes.InvalidArgument, "ContainerSpec: image reference must be provided")
	}

	if _, _, err := reference.Parse(container.Image); err != nil {
		return grpc.Errorf(codes.InvalidArgument, "ContainerSpec: %q is not a valid repository/tag", container.Image)
	}
	return nil
}

func validateEndpointSpec(epSpec *api.EndpointSpec) error {
	// Endpoint spec is optional
	if epSpec == nil {
		return nil
	}

	portSet := make(map[api.PortConfig]struct{})
	for _, port := range epSpec.Ports {
		if _, ok := portSet[*port]; ok {
			return grpc.Errorf(codes.InvalidArgument, "EndpointSpec: duplicate ports provided")
		}

		portSet[*port] = struct{}{}
	}

	return nil
}

func validateServiceSpec(spec *api.ServiceSpec) error {
	if spec == nil {
		return grpc.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
	}
	if err := validateAnnotations(spec.Annotations); err != nil {
		return err
	}
	if err := validateServiceSpecTemplate(spec); err != nil {
		return err
	}
	return nil
}

// CreateService creates and return a Service based on the provided ServiceSpec.
// - Returns `InvalidArgument` if the ServiceSpec is malformed.
// - Returns `Unimplemented` if the ServiceSpec references unimplemented features.
// - Returns `AlreadyExists` if the ServiceID conflicts.
// - Returns an error if the creation fails.
func (s *Server) CreateService(ctx context.Context, request *api.CreateServiceRequest) (*api.CreateServiceResponse, error) {
	if err := validateServiceSpec(request.Spec); err != nil {
		return nil, err
	}

	// TODO(aluzzardi): Consider using `Name` as a primary key to handle
	// duplicate creations. See #65
	service := &api.Service{
		ID:   identity.NewID(),
		Spec: *request.Spec,
	}

	err := s.store.Update(func(tx store.Tx) error {
		return store.CreateService(tx, service)
	})
	if err != nil {
		return nil, err
	}

	return &api.CreateServiceResponse{
		Service: service,
	}, nil
}

// GetService returns a Service given a ServiceID.
// - Returns `InvalidArgument` if ServiceID is not provided.
// - Returns `NotFound` if the Service is not found.
func (s *Server) GetService(ctx context.Context, request *api.GetServiceRequest) (*api.GetServiceResponse, error) {
	if request.ServiceID == "" {
		return nil, grpc.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
	}

	var service *api.Service
	s.store.View(func(tx store.ReadTx) {
		service = store.GetService(tx, request.ServiceID)
	})
	if service == nil {
		return nil, grpc.Errorf(codes.NotFound, "service %s not found", request.ServiceID)
	}

	return &api.GetServiceResponse{
		Service: service,
	}, nil
}

// UpdateService updates a Service referenced by ServiceID with the given ServiceSpec.
// - Returns `NotFound` if the Service is not found.
// - Returns `InvalidArgument` if the ServiceSpec is malformed.
// - Returns `Unimplemented` if the ServiceSpec references unimplemented features.
// - Returns an error if the update fails.
func (s *Server) UpdateService(ctx context.Context, request *api.UpdateServiceRequest) (*api.UpdateServiceResponse, error) {
	if request.ServiceID == "" || request.ServiceVersion == nil {
		return nil, grpc.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
	}
	if err := validateServiceSpec(request.Spec); err != nil {
		return nil, err
	}

	var service *api.Service
	err := s.store.Update(func(tx store.Tx) error {
		service = store.GetService(tx, request.ServiceID)
		if service == nil {
			return nil
		}
		// temporary disable network update
		if request.Spec != nil && !reflect.DeepEqual(request.Spec.Networks, service.Spec.Networks) {
			return errNetworkUpdateNotSupported
		}

		service.Meta.Version = *request.ServiceVersion
		service.Spec = *request.Spec.Copy()
		return store.UpdateService(tx, service)
	})
	if err != nil {
		return nil, err
	}
	if service == nil {
		return nil, grpc.Errorf(codes.NotFound, "service %s not found", request.ServiceID)
	}
	return &api.UpdateServiceResponse{
		Service: service,
	}, nil
}

// RemoveService removes a Service referenced by ServiceID.
// - Returns `InvalidArgument` if ServiceID is not provided.
// - Returns `NotFound` if the Service is not found.
// - Returns an error if the deletion fails.
func (s *Server) RemoveService(ctx context.Context, request *api.RemoveServiceRequest) (*api.RemoveServiceResponse, error) {
	if request.ServiceID == "" {
		return nil, grpc.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
	}

	err := s.store.Update(func(tx store.Tx) error {
		return store.DeleteService(tx, request.ServiceID)
	})
	if err != nil {
		if err == store.ErrNotExist {
			return nil, grpc.Errorf(codes.NotFound, "service %s not found", request.ServiceID)
		}
		return nil, err
	}
	return &api.RemoveServiceResponse{}, nil
}

func filterServices(candidates []*api.Service, filters ...func(*api.Service) bool) []*api.Service {
	result := []*api.Service{}

	for _, c := range candidates {
		match := true
		for _, f := range filters {
			if !f(c) {
				match = false
				break
			}
		}
		if match {
			result = append(result, c)
		}
	}

	return result
}

// ListServices returns a list of all services.
func (s *Server) ListServices(ctx context.Context, request *api.ListServicesRequest) (*api.ListServicesResponse, error) {
	var (
		services []*api.Service
		err      error
	)

	s.store.View(func(tx store.ReadTx) {
		switch {
		case request.Filters != nil && len(request.Filters.Names) > 0:
			services, err = store.FindServices(tx, buildFilters(store.ByName, request.Filters.Names))
		case request.Filters != nil && len(request.Filters.IDPrefixes) > 0:
			services, err = store.FindServices(tx, buildFilters(store.ByIDPrefix, request.Filters.IDPrefixes))
		default:
			services, err = store.FindServices(tx, store.All)
		}
	})
	if err != nil {
		return nil, err
	}

	if request.Filters != nil {
		services = filterServices(services,
			func(e *api.Service) bool {
				return filterContains(e.Spec.Annotations.Name, request.Filters.Names)
			},
			func(e *api.Service) bool {
				return filterContainsPrefix(e.ID, request.Filters.IDPrefixes)
			},
			func(e *api.Service) bool {
				return filterMatchLabels(e.Spec.Annotations.Labels, request.Filters.Labels)
			},
		)
	}

	return &api.ListServicesResponse{
		Services: services,
	}, nil
}


text:
// AbstractSortableContainer.cs
// Implementation of an abstract sortable container.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;

namespace SortLib
{
    public abstract class AbstractSortableContainer<ObjectType>
        : List<ObjectType>
    {
        public AbstractSortableContainer() : base() { }

        public AbstractSortableContainer(AbstractSortableContainer<ObjectType> other)
            : base(other)
        { }

        public abstract void SortInPlace(SortOrder sortOrder);

        public abstract AbstractSortableContainer<ObjectType> SortIntoNew(SortOrder sortOrder);
    }
}


text:
package com.hypotemoose.cal.date;

/**
 * Tests {@link com.hypotemoose.cal.date.MayaCalendar}
 * @author Chris Engelsma
 * @since 2017.08.24
 */
public class MayaCalendarTest {
}


text:
package flags

import (
	"bytes"
	"io"
	"os"
	"path"
	"path/filepath"
	"reflect"
	"runtime"
	"strings"
	"testing"
)

type TestComplete struct {
}

func (t *TestComplete) Complete(match string) []Completion {
	options := []string{
		"hello world",
		"hello universe",
		"hello multiverse",
	}

	ret := make([]Completion, 0, len(options))

	for _, o := range options {
		if strings.HasPrefix(o, match) {
			ret = append(ret, Completion{
				Item: o,
			})
		}
	}

	return ret
}

var completionTestOptions struct {
	Verbose  bool `short:"v" long:"verbose" description:"Verbose messages"`
	Debug    bool `short:"d" long:"debug" description:"Enable debug"`
	Version  bool `long:"version" description:"Show version"`
	Required bool `long:"required" required:"true" description:"This is required"`
	Hidden   bool `long:"hidden" hidden:"true" description:"This is hidden"`

	AddCommand struct {
		Positional struct {
			Filename Filename
		} `positional-args:"yes"`
	} `command:"add" description:"add an item"`

	AddMultiCommand struct {
		Positional struct {
			Filename []Filename
		} `positional-args:"yes"`
	} `command:"add-multi" description:"add multiple items"`

	RemoveCommand struct {
		Other bool     `short:"o"`
		File  Filename `short:"f" long:"filename"`
	} `command:"rm" description:"remove an item"`

	RenameCommand struct {
		Completed TestComplete `short:"c" long:"completed"`
	} `command:"rename" description:"rename an item"`
}

type completionTest struct {
	Args             []string
	Completed        []string
	ShowDescriptions bool
}

var completionTests []completionTest

func init() {
	_, sourcefile, _, _ := runtime.Caller(0)
	completionTestSourcedir := filepath.Join(filepath.SplitList(path.Dir(sourcefile))...)

	completionTestFilename := []string{filepath.Join(completionTestSourcedir, "completion.go"), filepath.Join(completionTestSourcedir, "completion_test.go")}

	completionTests = []completionTest{
		{
			// Short names
			[]string{"-"},
			[]string{"-d", "-v"},
			false,
		},

		{
			// Short names concatenated
			[]string{"-dv"},
			[]string{"-dv"},
			false,
		},

		{
			// Long names
			[]string{"--"},
			[]string{"--debug", "--required", "--verbose", "--version"},
			false,
		},

		{
			// Long names with descriptions
			[]string{"--"},
			[]string{
				"--debug     # Enable debug",
				"--required  # This is required",
				"--verbose   # Verbose messages",
				"--version   # Show version",
			},
			true,
		},

		{
			// Long names partial
			[]string{"--ver"},
			[]string{"--verbose", "--version"},
			false,
		},

		{
			// Commands
			[]string{""},
			[]string{"add", "add-multi", "rename", "rm"},
			false,
		},

		{
			// Commands with descriptions
			[]string{""},
			[]string{
				"add        # add an item",
				"add-multi  # add multiple items",
				"rename     # rename an item",
				"rm         # remove an item",
			},
			true,
		},

		{
			// Commands partial
			[]string{"r"},
			[]string{"rename", "rm"},
			false,
		},

		{
			// Positional filename
			[]string{"add", filepath.Join(completionTestSourcedir, "completion")},
			completionTestFilename,
			false,
		},

		{
			// Multiple positional filename (1 arg)
			[]string{"add-multi", filepath.Join(completionTestSourcedir, "completion")},
			completionTestFilename,
			false,
		},
		{
			// Multiple positional filename (2 args)
			[]string{"add-multi", filepath.Join(completionTestSourcedir, "completion.go"), filepath.Join(completionTestSourcedir, "completion")},
			completionTestFilename,
			false,
		},
		{
			// Multiple positional filename (3 args)
			[]string{"add-multi", filepath.Join(completionTestSourcedir, "completion.go"), filepath.Join(completionTestSourcedir, "completion.go"), filepath.Join(completionTestSourcedir, "completion")},
			completionTestFilename,
			false,
		},

		{
			// Flag filename
			[]string{"rm", "-f", path.Join(completionTestSourcedir, "completion")},
			completionTestFilename,
			false,
		},

		{
			// Flag short concat last filename
			[]string{"rm", "-of", path.Join(completionTestSourcedir, "completion")},
			completionTestFilename,
			false,
		},

		{
			// Flag concat filename
			[]string{"rm", "-f" + path.Join(completionTestSourcedir, "completion")},
			[]string{"-f" + completionTestFilename[0], "-f" + completionTestFilename[1]},
			false,
		},

		{
			// Flag equal concat filename
			[]string{"rm", "-f=" + path.Join(completionTestSourcedir, "completion")},
			[]string{"-f=" + completionTestFilename[0], "-f=" + completionTestFilename[1]},
			false,
		},

		{
			// Flag concat long filename
			[]string{"rm", "--filename=" + path.Join(completionTestSourcedir, "completion")},
			[]string{"--filename=" + completionTestFilename[0], "--filename=" + completionTestFilename[1]},
			false,
		},

		{
			// Flag long filename
			[]string{"rm", "--filename", path.Join(completionTestSourcedir, "completion")},
			completionTestFilename,
			false,
		},

		{
			// Custom completed
			[]string{"rename", "-c", "hello un"},
			[]string{"hello universe"},
			false,
		},
	}
}

func TestCompletion(t *testing.T) {
	p := NewParser(&completionTestOptions, Default)
	c := &completion{parser: p}

	for _, test := range completionTests {
		if test.ShowDescriptions {
			continue
		}

		ret := c.complete(test.Args)
		items := make([]string, len(ret))

		for i, v := range ret {
			items[i] = v.Item
		}

		if !reflect.DeepEqual(items, test.Completed) {
			t.Errorf("Args: %#v, %#v\n  Expected: %#v\n  Got:     %#v", test.Args, test.ShowDescriptions, test.Completed, items)
		}
	}
}

func TestParserCompletion(t *testing.T) {
	for _, test := range completionTests {
		if test.ShowDescriptions {
			os.Setenv("GO_FLAGS_COMPLETION", "verbose")
		} else {
			os.Setenv("GO_FLAGS_COMPLETION", "1")
		}

		tmp := os.Stdout

		r, w, _ := os.Pipe()
		os.Stdout = w

		out := make(chan string)

		go func() {
			var buf bytes.Buffer

			io.Copy(&buf, r)

			out <- buf.String()
		}()

		p := NewParser(&completionTestOptions, None)

		p.CompletionHandler = func(items []Completion) {
			comp := &completion{parser: p}
			comp.print(items, test.ShowDescriptions)
		}

		_, err := p.ParseArgs(test.Args)

		w.Close()

		os.Stdout = tmp

		if err != nil {
			t.Fatalf("Unexpected error: %s", err)
		}

		got := strings.Split(strings.Trim(<-out, "\n"), "\n")

		if !reflect.DeepEqual(got, test.Completed) {
			t.Errorf("Expected: %#v\nGot: %#v", test.Completed, got)
		}
	}

	os.Setenv("GO_FLAGS_COMPLETION", "")
}


text:
<script type="text/javascript">
    var a = document.getElementsByTagName("a");
    for(var i = 0; i < a.length; i++) {
        if(!a[i].onclick && a[i].getAttribute("target") != "_blank") {
            a[i].onclick = function() {
                window.location = this.getAttribute("href");
                return false;
            }
        }
    }
</script>

<script src="{{{ asset('js/jquery.min.js') }}}" type="text/javascript"></script>
<script src="{{{ asset('js/bootstrap.min.js') }}}" type="text/javascript"></script>

@if (App::environment() == 'production')
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-46644132-1', 'cuidabolsillo.com');
  ga('send', 'pageview');
</script>
@endif


text:
Clazz.declarePackage ("J.render");
Clazz.load (["J.render.FontLineShapeRenderer", "JU.BS", "$.P3", "$.V3"], "J.render.SticksRenderer", ["java.lang.Float", "J.constant.EnumPalette", "J.modelset.Bond", "J.util.C", "$.JmolEdge"], function () {
c$ = Clazz.decorateAsClass (function () {
this.showMultipleBonds = false;
this.multipleBondSpacing = 0;
this.multipleBondRadiusFactor = 0;
this.modeMultipleBond = 0;
this.isCartesianExport = false;
this.endcaps = 0;
this.ssbondsBackbone = false;
this.hbondsBackbone = false;
this.bondsBackbone = false;
this.hbondsSolid = false;
this.a = null;
this.b = null;
this.bond = null;
this.xA = 0;
this.yA = 0;
this.zA = 0;
this.xB = 0;
this.yB = 0;
this.zB = 0;
this.dx = 0;
this.dy = 0;
this.mag2d = 0;
this.bondOrder = 0;
this.wireframeOnly = false;
this.isAntialiased = false;
this.slabbing = false;
this.slabByAtom = false;
this.x = null;
this.y = null;
this.z = null;
this.p1 = null;
this.p2 = null;
this.bsForPass2 = null;
this.isPass2 = false;
this.xAxis1 = 0;
this.yAxis1 = 0;
this.xAxis2 = 0;
this.yAxis2 = 0;
this.dxStep = 0;
this.dyStep = 0;
Clazz.instantialize (this, arguments);
}, J.render, "SticksRenderer", J.render.FontLineShapeRenderer);
Clazz.prepareFields (c$, function () {
this.x =  new JU.V3 ();
this.y =  new JU.V3 ();
this.z =  new JU.V3 ();
this.p1 =  new JU.P3 ();
this.p2 =  new JU.P3 ();
this.bsForPass2 = JU.BS.newN (64);
});
$_V(c$, "render",
function () {
var bonds = this.modelSet.bonds;
if (bonds == null) return false;
this.isPass2 = this.g3d.isPass2 ();
if (!this.isPass2) this.bsForPass2.clearAll ();
this.slabbing = this.viewer.getSlabEnabled ();
this.slabByAtom = this.viewer.getBoolean (603979938);
this.endcaps = 3;
this.dashDots = (this.viewer.getBoolean (603979889) ? J.render.FontLineShapeRenderer.sixdots : J.render.FontLineShapeRenderer.dashes);
this.multipleBondSpacing = this.viewer.getFloat (570425369);
this.isCartesianExport = (this.exportType == 1);
if (this.multipleBondSpacing == 0 && this.isCartesianExport) this.multipleBondSpacing = 0.2;
this.multipleBondRadiusFactor = this.viewer.getFloat (570425368);
this.modeMultipleBond = this.viewer.getModeMultipleBond ();
this.showMultipleBonds = (this.multipleBondSpacing != 0 && this.modeMultipleBond != 0 && this.viewer.getBoolean (603979928));
this.wireframeOnly = !this.viewer.checkMotionRendering (1678770178);
this.ssbondsBackbone = this.viewer.getBoolean (603979952);
this.hbondsBackbone = this.viewer.getBoolean (603979852);
this.bondsBackbone =  new Boolean (this.hbondsBackbone | this.ssbondsBackbone).valueOf ();
this.hbondsSolid = this.viewer.getBoolean (603979854);
this.isAntialiased = this.g3d.isAntialiased ();
var needTranslucent = false;
if (!this.isExport && this.isPass2) for (var i = this.bsForPass2.nextSetBit (0); i >= 0; i = this.bsForPass2.nextSetBit (i + 1)) {
this.bond = bonds[i];
this.renderBond ();
}
 else for (var i = this.modelSet.bondCount; --i >= 0; ) {
this.bond = bonds[i];
if ((this.bond.getShapeVisibilityFlags () & this.myVisibilityFlag) != 0 && this.renderBond ()) {
needTranslucent = true;
this.bsForPass2.set (i);
}}
return needTranslucent;
});
$_M(c$, "renderBond",
($fz = function () {
var atomA0;
var atomB0;
this.a = atomA0 = this.bond.getAtom1 ();
this.b = atomB0 = this.bond.getAtom2 ();
var order = this.bond.order & -131073;
if (this.bondsBackbone) {
if (this.ssbondsBackbone && (order & 256) != 0) {
this.a = this.a.getGroup ().getLeadAtomOr (this.a);
this.b = this.b.getGroup ().getLeadAtomOr (this.b);
} else if (this.hbondsBackbone && J.modelset.Bond.isOrderH (order)) {
this.a = this.a.getGroup ().getLeadAtomOr (this.a);
this.b = this.b.getGroup ().getLeadAtomOr (this.b);
}}if (!this.isPass2 && (!this.a.isInFrame () || !this.b.isInFrame () || !this.g3d.isInDisplayRange (this.a.screenX, this.a.screenY) || !this.g3d.isInDisplayRange (this.b.screenX, this.b.screenY) || this.modelSet.isAtomHidden (this.a.getIndex ()) || this.modelSet.isAtomHidden (this.b.getIndex ()))) return false;
if (this.slabbing) {
if (this.g3d.isClippedZ (this.a.screenZ) && this.g3d.isClippedZ (this.b.screenZ)) return false;
if (this.slabByAtom && (this.g3d.isClippedZ (this.a.screenZ) || this.g3d.isClippedZ (this.b.screenZ))) return false;
}this.zA = this.a.screenZ;
this.zB = this.b.screenZ;
if (this.zA == 1 || this.zB == 1) return false;
this.colixA = atomA0.getColix ();
this.colixB = atomB0.getColix ();
if (((this.colix = this.bond.colix) & -30721) == 2) {
this.colix = (this.colix & 30720);
this.colixA = J.util.C.getColixInherited ((this.colix | this.viewer.getColixAtomPalette (atomA0, J.constant.EnumPalette.CPK.id)), this.colixA);
this.colixB = J.util.C.getColixInherited ((this.colix | this.viewer.getColixAtomPalette (atomB0, J.constant.EnumPalette.CPK.id)), this.colixB);
} else {
this.colixA = J.util.C.getColixInherited (this.colix, this.colixA);
this.colixB = J.util.C.getColixInherited (this.colix, this.colixB);
}var needTranslucent = false;
if (!this.isExport && !this.isPass2) {
var doA = !J.util.C.isColixTranslucent (this.colixA);
var doB = !J.util.C.isColixTranslucent (this.colixB);
if (!doA || !doB) {
if (!doA && !doB && !needTranslucent) {
this.g3d.setColix (!doA ? this.colixA : this.colixB);
return true;
}needTranslucent = true;
}}this.bondOrder = order & -131073;
if ((this.bondOrder & 224) == 0) {
if ((this.bondOrder & 256) != 0) this.bondOrder &= -257;
if ((this.bondOrder & 1023) != 0) {
if (!this.showMultipleBonds || (this.modeMultipleBond == 2 && this.mad > 500) || (this.bondOrder & 65536) != 0) {
this.bondOrder = 1;
}}}var mask = 0;
switch (this.bondOrder) {
case 1:
case 2:
case 3:
case 4:
break;
case 17:
case 513:
this.bondOrder = 1;
mask = (order == 513 ? 0 : 1);
break;
case 515:
case 514:
this.bondOrder = 2;
mask = (order == 515 ? this.getAromaticDottedBondMask () : 0);
break;
default:
if ((this.bondOrder & 224) != 0) {
this.bondOrder = J.util.JmolEdge.getPartialBondOrder (order);
mask = J.util.JmolEdge.getPartialBondDotted (order);
} else if (J.modelset.Bond.isOrderH (this.bondOrder)) {
this.bondOrder = 1;
if (!this.hbondsSolid) mask = -1;
} else if (this.bondOrder == 32768) {
this.bondOrder = 1;
}}
this.xA = this.a.screenX;
this.yA = this.a.screenY;
this.xB = this.b.screenX;
this.yB = this.b.screenY;
this.mad = this.bond.mad;
if (this.multipleBondRadiusFactor > 0 && this.bondOrder > 1) this.mad *= this.multipleBondRadiusFactor;
this.dx = this.xB - this.xA;
this.dy = this.yB - this.yA;
this.width = Clazz.floatToInt (this.viewer.scaleToScreen (Clazz.doubleToInt ((this.zA + this.zB) / 2), this.mad));
if (this.wireframeOnly && this.width > 0) this.width = 1;
if (!this.isCartesianExport) {
this.asLineOnly = (this.width <= 1);
if (this.asLineOnly && (this.isAntialiased)) {
this.width = 3;
this.asLineOnly = false;
}}switch (mask) {
case -1:
this.drawDashed (this.xA, this.yA, this.zA, this.xB, this.yB, this.zB, J.render.FontLineShapeRenderer.hDashes);
break;
default:
this.drawBond (mask);
break;
}
return needTranslucent;
}, $fz.isPrivate = true, $fz));
$_M(c$, "drawBond",
($fz = function (dottedMask) {
if (this.isCartesianExport && this.bondOrder == 1) {
this.g3d.drawBond (this.a, this.b, this.colixA, this.colixB, this.endcaps, this.mad, -1);
return;
}var isEndOn = (this.dx == 0 && this.dy == 0);
if (isEndOn && this.asLineOnly) return;
var doFixedSpacing = (this.bondOrder > 1 && this.multipleBondSpacing > 0);
var isPiBonded = doFixedSpacing && (this.viewer.getHybridizationAndAxes (this.a.index, this.z, this.x, "pz") != null || this.viewer.getHybridizationAndAxes (this.b.index, this.z, this.x, "pz") != null) && !Float.isNaN (this.x.x);
if (isEndOn && !doFixedSpacing) {
var space = Clazz.doubleToInt (this.width / 8) + 3;
var step = this.width + space;
var y = this.yA - Clazz.doubleToInt ((this.bondOrder - 1) * step / 2);
do {
this.fillCylinder (this.colixA, this.colixA, this.endcaps, this.width, this.xA, y, this.zA, this.xA, y, this.zA);
y += step;
} while (--this.bondOrder > 0);
return;
}var isDashed = (dottedMask & 1) != 0;
if (this.bondOrder == 1) {
if (isDashed) this.drawDashed (this.xA, this.yA, this.zA, this.xB, this.yB, this.zB, this.dashDots);
 else this.fillCylinder (this.colixA, this.colixB, this.endcaps, this.width, this.xA, this.yA, this.zA, this.xB, this.yB, this.zB);
return;
}if (doFixedSpacing) {
if (!isPiBonded) this.z.set (3.141592653589793, 2.718281828459045, (8.539734222673566));
this.x.sub2 (this.b, this.a);
this.y.cross (this.x, this.z);
this.y.normalize ();
if (Float.isNaN (this.y.x)) {
this.z.set (3.141592653589793, 2.718281828459045, (8.539734222673566));
this.y.cross (this.x, this.z);
this.y.cross (this.y, this.x);
this.y.normalize ();
}this.y.scale (this.multipleBondSpacing);
this.x.setT (this.y);
this.x.scale ((this.bondOrder - 1) / 2);
this.p1.sub2 (this.a, this.x);
this.p2.sub2 (this.b, this.x);
while (true) {
if (this.isCartesianExport && !isDashed) {
this.g3d.drawBond (this.p1, this.p2, this.colixA, this.colixB, this.endcaps, this.mad, -2);
} else {
this.viewer.transformPtScr (this.p1, this.s1);
this.viewer.transformPtScr (this.p2, this.s2);
if (isDashed) this.drawDashed (this.s1.x, this.s1.y, this.s1.z, this.s2.x, this.s2.y, this.s2.z, this.dashDots);
 else this.fillCylinder (this.colixA, this.colixB, this.endcaps, this.width, this.s1.x, this.s1.y, this.s1.z, this.s2.x, this.s2.y, this.s2.z);
dottedMask >>= 1;
isDashed = (dottedMask & 1) != 0;
}if (--this.bondOrder <= 0) break;
this.p1.add (this.y);
this.p2.add (this.y);
this.stepAxisCoordinates ();
}
return;
}var dxB = this.dx * this.dx;
var dyB = this.dy * this.dy;
this.mag2d = Math.round (Math.sqrt (dxB + dyB));
this.resetAxisCoordinates ();
while (true) {
if ((dottedMask & 1) != 0) this.drawDashed (this.xAxis1, this.yAxis1, this.zA, this.xAxis2, this.yAxis2, this.zB, this.dashDots);
 else this.fillCylinder (this.colixA, this.colixB, this.endcaps, this.width, this.xAxis1, this.yAxis1, this.zA, this.xAxis2, this.yAxis2, this.zB);
dottedMask >>= 1;
if (--this.bondOrder <= 0) break;
this.stepAxisCoordinates ();
}
}, $fz.isPrivate = true, $fz), "~N");
$_M(c$, "resetAxisCoordinates",
($fz = function () {
var space = this.mag2d >> 3;
if (this.multipleBondSpacing != -1 && this.multipleBondSpacing < 0) space *= -this.multipleBondSpacing;
var step = this.width + space;
this.dxStep = Clazz.doubleToInt (step * this.dy / this.mag2d);
this.dyStep = Clazz.doubleToInt (step * -this.dx / this.mag2d);
this.xAxis1 = this.xA;
this.yAxis1 = this.yA;
this.xAxis2 = this.xB;
this.yAxis2 = this.yB;
var f = (this.bondOrder - 1);
this.xAxis1 -= Clazz.doubleToInt (this.dxStep * f / 2);
this.yAxis1 -= Clazz.doubleToInt (this.dyStep * f / 2);
this.xAxis2 -= Clazz.doubleToInt (this.dxStep * f / 2);
this.yAxis2 -= Clazz.doubleToInt (this.dyStep * f / 2);
}, $fz.isPrivate = true, $fz));
$_M(c$, "stepAxisCoordinates",
($fz = function () {
this.xAxis1 += this.dxStep;
this.yAxis1 += this.dyStep;
this.xAxis2 += this.dxStep;
this.yAxis2 += this.dyStep;
}, $fz.isPrivate = true, $fz));
$_M(c$, "getAromaticDottedBondMask",
($fz = function () {
var atomC = this.b.findAromaticNeighbor (this.a.getIndex ());
if (atomC == null) return 1;
var dxAC = atomC.screenX - this.xA;
var dyAC = atomC.screenY - this.yA;
return ((this.dx * dyAC - this.dy * dxAC) < 0 ? 2 : 1);
}, $fz.isPrivate = true, $fz));
});


text:
<!doctype html>

    <meta charset="utf-8">
    <title>Introduction to the Scala Type System</title>
    <meta name="description" content="Scala is a statically, strongly typed language with built in type inference. Its type system allows us to do some pretty interesting stuff like Ad-Hoc Polymorphism, defining recursive type, programming at the type level and so on. The things that we will cover in this talk include but not limited to some basic types in Scala, the concept of variance and bounds and also Ad-Hoc polymorphism.">
    <meta name="author" content="Andrew CS Sim">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
    <link rel="stylesheet" href="css/reveal.css">
    <link rel="stylesheet" href="css/theme/moon.css" id="theme">

    <link rel="stylesheet" href="lib/css/obsidian.css">

Type System in Scala

The Short Introduction

            Created by Andrew C.S. Sim / @andrewcssim

THE END

            Source code & documentation