text:
package com.github.onsdigital.babbage.util;

import org.apache.commons.lang3.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by bren on 28/05/15.
 *

 * Several utilities for formatting, cleaning  and resolving given uri
 *

 * Uris are deemed valid if without parameters, starting with slash("/") and without multiple slashes
 */
public class URIUtil {

    private final static Pattern uriPattern = Pattern.compile("/(([^/]+)/?)*");

    /**
     * Removes endpoint from given uri ( the first uri segment )
     *

     * e.g. uri for /data/economy/inflationandpriceindices is /economy/inflationandpriceindices
     *
     * @return The URI path, lowercased, without the endpoint title or trailing
     * slash.
     */
    public static String removeEndpoint(String uriString) {
        uriString = cleanUri(uriString);
        //TODO: Java regex does not return when there are two slashes in the uri cpu usage goes all the way up. Faulty regex ? Reactivate validation handle errors approprieately
//        validate(uriString);
        int indexOfSecondSlash = StringUtils.indexOf(uriString, "/", 1);
        if (indexOfSecondSlash == -1) {
            return "/";
        } else {
            return StringUtils.substring(uriString, indexOfSecondSlash);  //Remove endpoint title
        }
    }

    /**
     * Extracts request type from request type suffixed uris (the last uri segment)
     *

     * e.g.
     * for uri "/economy/inflationandpriceindices/data" request type is "data"
     *
     * @return request type
     */
    public static String resolveRequestType(String uriString) {
        uriString = cleanUri(uriString);
//        validate(uriString);
        if ("/".equals(uriString)) {
            return uriString;
        }

        int lastSlashIndex = StringUtils.lastIndexOf(uriString, "/");
        return StringUtils.substring(uriString, lastSlashIndex + 1);
    }

    public static boolean isDataRequest(String uriString) {
        return "data".equals(resolveRequestType(uriString));
    }

    /**
     * Extracts resource uri from request type suffixed uris.
     *

     * e.g.
     * for uri "/economy/inflationandpriceindices/data" resource uri "/economy/inflationandpriceindices"
     *
     * @return uri
     */
    public static String removeLastSegment(String uriString) {
        uriString = cleanUri(uriString);
//        validate(uriString);

        int lastSlashIndex = StringUtils.lastIndexOf(uriString, "/");
        return StringUtils.substring(uriString, 0, lastSlashIndex);

    }

    public static void validate(String uriString) {
        uriString = StringUtils.defaultIfBlank(uriString, "/");
        Matcher matcher = uriPattern.matcher(uriString);

        if (!matcher.matches()) {
            throw new InvalidUriException(uriString);
        }
    }

    //Remove trailing slash if any and make lowercase
    public static String cleanUri(String uriString) {
        uriString = StringUtils.trim(StringUtils.defaultIfBlank(uriString, "/"));
        if ("/".equals(uriString)) {
            return uriString;
        }
        // Remove multiple trailing slashes
        while(StringUtils.isNotEmpty(uriString) && !uriString.equals("/") && uriString.endsWith("/")) {
            uriString = StringUtils.removeEnd(uriString, "/");
        }
        return StringUtils.lowerCase(uriString);
    }

    public static class InvalidUriException extends RuntimeException {
        public InvalidUriException(String uriString) {
            super("Invalid uri: " + uriString);
        }
    }
}


text:
var loginUtils = {
    init: function(){
        $('#githubBtn').on('click', function(){
            loginUtils.doGitHub();
        });
    },
    doGitHub: function(){
        window.location.href = '/auth/github/';
    }
}

redpajama_set_name: RedPajamaGithub


text:
#import "NSObject.h"

#import "TSCH3DBarChartAppearance-Protocol.h"
#import "TSCHUnretainedParent-Protocol.h"

@class TSCH3DChartBarElementProperties;

// Not exported
@interface TSCH3DBarChartDefaultAppearance : NSObject <TSCHUnretainedParent, TSCH3DBarChartAppearance>
{
    TSCH3DChartBarElementProperties *mProperties;
}

+ (struct BarExtrusionDetails)defaultDetails;
+ (int)shapeType;
- (_Bool)isCircular;
- (float)depthForScene:(id)arg1;
- (float)chartMinZForScene:(id)arg1;
- (float)signedValueForSeries:(id)arg1 index:(const tvec2_3b141483 *)arg2;
- (float)maxValueForSeries:(long long)arg1;
- (void)clearParent;
- (void)dealloc;
- (id)initWithProperties:(id)arg1;

@end


text:
const express = require('express');
const config = require('./');

const env = process.env.NODE_ENV || 'development';

module.exports = (app) => {
	// Static files middleware
	app.use(express.static(`${config.root}/public`));

	// set views path, template engine and default layout
	app.set('views', `${config.root}/views`);
	app.set('view engine', 'ejs');

	if (env === 'development') {
		app.locals.pretty = true;
	}
};


text: Waiting for rework


text:
/**
 *
  Package: MAG - VistA Imaging
  WARNING: Per VHA Directive 2004-038, this routine should not be modified.
  Date Created:
  Site Name:  Washington OI Field Office, Silver Spring, MD
  Developer:  vhaiswpeterb
  Description:

        ;; +--------------------------------------------------------------------+
        ;; Property of the US Government.
        ;; No permission to copy or redistribute this software is given.
        ;; Use of unreleased versions of this software requires the user
        ;;  to execute a written test agreement with the VistA Imaging
        ;;  Development Office of the Department of Veterans Affairs,
        ;;  telephone (301) 734-0100.
        ;;
        ;; The Food and Drug Administration classifies this software as
        ;; a Class II medical device.  As such, it may not be changed
        ;; in any way.  Modifications to this software may result in an
        ;; adulterated medical device under 21CFR820, the use of which
        ;; is considered to be a violation of US Federal Statutes.
        ;; +--------------------------------------------------------------------+

*/

package gov.va.med.imaging.vistaimagingdatasource.dicom.storage;

import gov.va.med.imaging.artifactsource.ResolvedArtifactSource;
import gov.va.med.imaging.core.interfaces.exceptions.ConnectionException;
import gov.va.med.imaging.core.interfaces.exceptions.MethodException;
import gov.va.med.imaging.core.interfaces.exceptions.SecurityException;
import gov.va.med.imaging.datasource.AbstractVersionableDataSource;
import gov.va.med.imaging.datasource.DicomApplicationEntityDataSourceSpi;
import gov.va.med.imaging.exchange.business.ResolvedSite;
import gov.va.med.imaging.exchange.business.Site;
import gov.va.med.imaging.exchange.business.dicom.DicomAE;
import gov.va.med.imaging.exchange.enums.ImagingSecurityContextType;
import gov.va.med.imaging.transactioncontext.TransactionContextFactory;
import gov.va.med.imaging.vistadatasource.session.VistaSession;
import gov.va.med.imaging.vistaimagingdatasource.common.VistaSessionFactory;

import java.io.IOException;

public class VistaImagingDicomApplicationEntityDataSourceService
extends AbstractVersionableDataSource
implements DicomApplicationEntityDataSourceSpi, VistaSessionFactory {

	public final static String MAG_REQUIRED_VERSION = "3.0P116";
	public final static String SUPPORTED_PROTOCOL = "vistaimaging";

	public VistaImagingDicomApplicationEntityDataSourceService(
			ResolvedArtifactSource resolvedArtifactSource, String protocol) {
		super(resolvedArtifactSource, protocol);
	}

	// to support local data source
	public VistaImagingDicomApplicationEntityDataSourceService(
			ResolvedArtifactSource resolvedArtifactSource)
	{
		super(resolvedArtifactSource, SUPPORTED_PROTOCOL);
	}

	@Override
	public VistaSession getVistaSession() throws IOException,
			ConnectionException, MethodException {
		TransactionContextFactory.get().setImagingSecurityContextType(ImagingSecurityContextType.DICOM_QR_CONTEXT.name());
		return VistaSession.getOrCreate(getMetadataUrl(), getSite());
	}

	@Override
	public DicomAE getAEByAETandLocation(DicomAE appEntity)
				throws MethodException, ConnectionException {
		DicomAEDAO dao = new DicomAEDAO(this);
		return dao.getEntityByExample(appEntity);
	}

	/* (non-Javadoc)
	 * @see gov.va.med.imaging.datasource.AbstractVersionableDataSource#isVersionCompatible()
	 */
	@Override
	public boolean isVersionCompatible() throws SecurityException {
		return true;
	}

	/**
	 * The artifact source must be checked in the constructor to assure that it is an instance
	 * of ResolvedSite.
	 *
	 * @return
	 */
	protected ResolvedSite getResolvedSite()
	{
		return (ResolvedSite)getResolvedArtifactSource();
	}

	protected Site getSite()
	{
		return getResolvedSite().getSite();
	}
}


text:
package sun.io;

import sun.nio.cs.ext.IBM33722;

/**
* Tables and data to convert Unicode to Cp33722
*
* @author Malcolm Ayres, assisted by UniMap program
*/
public class CharToByteCp33722
        extends CharToByteEUC

{
        private final static IBM33722 nioCoder = new IBM33722();

        // Return the character set id
        public String getCharacterEncoding()
        {
                return "Cp33722";
        }

        public int getMaxBytesPerChar() {
                return 3;
        }

        public CharToByteCp33722()
        {
                super();
                super.mask1 = 0xFFE0;
                super.mask2 = 0x001F;
                super.shift = 5;
                super.index1 = nioCoder.getEncoderIndex1();
                super.index2 = nioCoder.getEncoderIndex2();
                super.index2a = nioCoder.getEncoderIndex2a();
                super.index2b = nioCoder.getEncoderIndex2b();
        }
}


text:
package sk.sorien.silexplugin.pimple;

import com.intellij.codeInsight.completion.InsertionContext;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementPresentation;
import com.intellij.openapi.project.Project;
import com.jetbrains.php.PhpIndex;
import com.jetbrains.php.lang.psi.elements.PhpClass;
import org.jetbrains.annotations.NotNull;
import sk.sorien.silexplugin.SilexIcons;

import java.util.Collection;

/**
 * @author Stanislav Turza
 */
public class ServiceLookupElement extends LookupElement {

    private final Service service;
    private final Project project;

    public ServiceLookupElement(Service service, Project project) {
        this.service = service;
        this.project = project;
    }

    @NotNull
    @Override
    public String getLookupString() {
        return service.getName();
    }

    public void renderElement(LookupElementPresentation presentation) {

        presentation.setItemText(getLookupString());
        presentation.setTypeText(service.getClassName().substring(1));
        presentation.setIcon(SilexIcons.Service);
    }

    @NotNull
    public Object getObject() {

        Collection<PhpClass> classes = PhpIndex.getInstance(project).getClassesByFQN(service.getClassName());
        return !classes.isEmpty() ? classes.iterator().next() : this;
    }

    @Override
    public void handleInsert(InsertionContext context) {
        Utils.CONTAINER_INSERT_HANDLER.handleInsert(context, this);
    }
}


text:
require 'spec_helper'

describe OctoMerge::PullRequest do
  include WebmockStubs

  subject(:pull_request) {
    described_class.new(repo: "rails/rails", number: "23")
  }

  its(:url) { is_expected.to eq("https://github.com/rails/rails/pull/23") }
  its(:remote) { is_expected.to eq("jackdempsey") }
  its(:remote_url) { is_expected.to eq("git@github.com:jackdempsey/rails.git") }
  its(:remote_branch) { is_expected.to eq("fix_requires") }
  its(:number_branch) { is_expected.to eq("pull/23") }
  its(:number) { is_expected.to eq("23") }
  its(:title) { is_expected.to eq("Fix requires for inflection related files") }
  its(:body) { is_expected.to start_with("Documented an issue") }

  describe "==" do
    let(:another_pull_request) {
      described_class.new(repo: "rails/rails", number: "23")
    }

    specify { expect(pull_request).to eq(another_pull_request) }
  end
end


text:
using EDDiscovery.DB;
using EDDiscovery.EliteDangerous;
using EDDiscovery.EliteDangerous.JournalEvents;
using EDDiscovery2;
using EDDiscovery2.DB;
using OpenTK;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.Common;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace EDDiscovery
{
    [DebuggerDisplay("Event {EntryType} {System.name} ({System.x,nq},{System.y,nq},{System.z,nq}) {EventTimeUTC} JID:{Journalid}")]
    public class HistoryEntry           // DONT store commander ID.. this history is externally filtered on it.
    {
        #region Variables

        public int Indexno;            // for display purposes.

        public EliteDangerous.JournalTypeEnum EntryType;
        public long Journalid;
        public JournalEntry journalEntry;
        public EDCommander Commander;

        public ISystem System;         // Must be set! All entries, even if they are not FSD entries.
                                       // The Minimum is name and edsm_id
                                       // x/y/z can be NANs or position.
                                       // if edsm_id = 0, no edsm match was found.
                                       // when the front end needs to use it, it will call EnsureSystemEDSM/FillInPositions to see if it can be filled up
                                       // if System.status != SystemStatusEnum.EDSC then its presumed its an inmemory load and the system table can be checked
                                       //       and if edsm_id>0 a load from SystemTable will occur with the edsm_id used
                                       //       if edsm_id=-1 a load from SystemTable will occur with the name used
                                       // SO the journal reader can just read data in that table only, does not need to do a system match

        public DateTime EventTimeLocal { get { return EventTimeUTC.ToLocalTime(); } }
        public DateTime EventTimeUTC;
        public string EventSummary;
        public string EventDescription;
        public string EventDetailedInfo;

        public int MapColour;

        public bool IsStarPosFromEDSM;  // flag populated from journal entry when HE is made. Was the star position taken from EDSM?
        public bool EdsmSync;           // flag populated from journal entry when HE is made. Have we synced?
        public bool EDDNSync;           // flag populated from journal entry when HE is made. Have we synced?
        public bool StartMarker;        // flag populated from journal entry when HE is made. Is this a system distance measurement system
        public bool StopMarker;         // flag populated from journal entry when HE is made. Is this a system distance measurement stop point
        public bool IsFSDJump { get { return EntryType == EliteDangerous.JournalTypeEnum.FSDJump; } }
        public bool IsLocOrJump { get { return EntryType == JournalTypeEnum.FSDJump || EntryType == JournalTypeEnum.Location; } }
        public bool IsFuelScoop { get { return EntryType == JournalTypeEnum.FuelScoop; } }
        public bool ISEDDNMessage
        {
            get
            {
                DateTime ed22 = new DateTime(2016, 10, 25, 12, 0, 0);
                if ((EntryType == JournalTypeEnum.Scan || EntryType == JournalTypeEnum.Docked || EntryType == JournalTypeEnum.FSDJump) && EventTimeUTC>ed22 ) return true; else return false;
            }
        }
        public MaterialCommoditiesList MaterialCommodity { get { return materialscommodities; } }

        // Calculated values, not from JE

        public SystemNoteClass snc;     // system note class found attached to this entry

        private double travelled_distance;  // start/stop distance and time computation
        public double TravelledDistance { get { return travelled_distance; } }

        private TimeSpan travelled_seconds;
        public TimeSpan TravelledSeconds { get { return travelled_seconds; } }

        bool travelling;
        public bool isTravelling { get { return travelling; } }

        int travelled_missingjump;
        public int TravelledMissingjump { get { return travelled_missingjump; } }
        public int Travelledjumps { get { return travelled_jumps; } }
        int travelled_jumps;

        MaterialCommoditiesList materialscommodities;

        private bool? docked;                       // are we docked.  Null if don't know, else true/false
        private bool? landed;                       // are we landed on the planet surface.  Null if don't know, else true/false
        private string wheredocked = "";            // empty if in space, else where docked
        private string shiptype = "Unknown";

        public bool IsLanded { get { return landed.HasValue && landed.Value == true; } }
        public bool IsDocked { get { return docked.HasValue && docked.Value == true; } }
        public string WhereAmI { get { return wheredocked; } }
        public string ShipType { get { return shiptype; } }

        #endregion

        #region Constructors

        public void MakeVSEntry(ISystem sys, DateTime eventt, int m, string dist, string info, int journalid = 0)
        {
            Debug.Assert(sys != null);
            EntryType = EliteDangerous.JournalTypeEnum.FSDJump;
            System = sys;
            EventTimeUTC = eventt;
            EventSummary = "Jump to " + System.name;
            EventDescription = dist;
            EventDetailedInfo = info;
            MapColour = m;
            Journalid = journalid;
            EdsmSync = true;
        }

        public static HistoryEntry FromJournalEntry(EliteDangerous.JournalEntry je, HistoryEntry prev, bool checkedsm, out bool journalupdate, SQLiteConnectionSystem conn = null, EDCommander cmdr = null)
        {
            ISystem isys = prev == null ? new SystemClass("Unknown") : prev.System;
            int indexno = prev == null ? 1 : prev.Indexno + 1;

            int mapcolour = 0;
            journalupdate = false;
            bool starposfromedsm = false;

            if (je.EventTypeID == EliteDangerous.JournalTypeEnum.Location || je.EventTypeID == EliteDangerous.JournalTypeEnum.FSDJump)
            {
                EDDiscovery.EliteDangerous.JournalEvents.JournalLocOrJump jl = je as EDDiscovery.EliteDangerous.JournalEvents.JournalLocOrJump;
                EDDiscovery.EliteDangerous.JournalEvents.JournalFSDJump jfsd = je as EDDiscovery.EliteDangerous.JournalEvents.JournalFSDJump;

                ISystem newsys;

                if (jl.HasCoordinate)       // LAZY LOAD IF it has a co-ord.. the front end will when it needs it
                {
                    newsys = new SystemClass(jl.StarSystem, jl.StarPos.X, jl.StarPos.Y, jl.StarPos.Z);
                    newsys.id_edsm = jl.EdsmID < 0 ? 0 : jl.EdsmID;       // pass across the EDSMID for the lazy load process.

                    if (jfsd != null && jfsd.JumpDist <= 0 && isys.HasCoordinate)     // if we don't have a jump distance (pre 2.2) but the last sys does have pos, we can compute distance and update entry
                    {
                        jfsd.JumpDist = SystemClass.Distance(isys, newsys); // fill it out here
                        journalupdate = true;
                    }

                }
                else
                {                           // Default one
                    newsys = new SystemClass(jl.StarSystem);
                    newsys.id_edsm = jl.EdsmID;

                    if (checkedsm)          // see if we can find the right system
                    {
                        SystemClass s = SystemClass.FindEDSM(newsys, conn);      // has no co-ord, did we find it?

                        if (s != null)                                          // yes, use, and update the journal with the esdmid, and also the position if we have a co-ord
                        {                                                       // so next time we don't have to do this again..
                            if (jl.HasCoordinate)
                            {
                                s.x = Math.Round(jl.StarPos.X * 32.0) / 32.0;
                                s.y = Math.Round(jl.StarPos.Y * 32.0) / 32.0;
                                s.z = Math.Round(jl.StarPos.Z * 32.0) / 32.0;
                            }

                            newsys = s;

                            if (jfsd != null && jfsd.JumpDist <= 0 && newsys.HasCoordinate && isys.HasCoordinate)     // if we don't have a jump distance (pre 2.2) but the last sys does, we can compute
                            {
                                jfsd.JumpDist = SystemClass.Distance(isys, newsys); // fill it out here.  EDSM systems always have co-ords, but we should check anyway
                                journalupdate = true;
                            }

                            if (jl.EdsmID <= 0 && newsys.id_edsm > 0)
                            {
                                journalupdate = true;
                            }
                        }
                    }
                }

                if (jfsd != null)
                {
                    if (jfsd.JumpDist <= 0 && isys.HasCoordinate && newsys.HasCoordinate) // if no JDist, its a really old entry, and if previous has a co-ord
                    {
                        jfsd.JumpDist = SystemClass.Distance(isys, newsys); // fill it out here
                        journalupdate = true;
                    }

                    mapcolour = jfsd.MapColor;
                }

                isys = newsys;
                starposfromedsm = jl.HasCoordinate ? jl.StarPosFromEDSM : newsys.HasCoordinate;
            }

            string summary, info, detailed;
            je.FillInformation(out summary, out info, out detailed);

            HistoryEntry he = new HistoryEntry
            {
                Indexno = indexno,
                EntryType = je.EventTypeID,
                Journalid = je.Id,
                journalEntry = je,
                System = isys,
                EventTimeUTC = je.EventTimeUTC,
                MapColour = mapcolour,
                EdsmSync = je.SyncedEDSM,
                EDDNSync = je.SyncedEDDN,
                StartMarker = je.StartMarker,
                StopMarker = je.StopMarker,
                EventSummary = summary,
                EventDescription = info,
                EventDetailedInfo = detailed,
                IsStarPosFromEDSM = starposfromedsm,
                Commander = cmdr ?? EDDConfig.Instance.Commander(je.CommanderId)
            };

            if (prev != null && prev.travelling)      // if we are travelling..
            {
                he.travelled_distance = prev.travelled_distance;
                he.travelled_missingjump = prev.travelled_missingjump;
                he.travelled_jumps = prev.travelled_jumps;

                if (he.IsFSDJump)
                {
                    double dist = ((EliteDangerous.JournalEvents.JournalFSDJump)je).JumpDist;
                    if (dist <= 0)
                        he.travelled_missingjump++;
                    else
                    {
                        he.travelled_distance += dist;
                        he.travelled_jumps++;
                    }
                }

                he.travelled_seconds = prev.travelled_seconds;
                TimeSpan diff = he.EventTimeUTC.Subtract(prev.EventTimeUTC);

                if (he.EntryType != EliteDangerous.JournalTypeEnum.LoadGame && diff < new TimeSpan(2, 0, 0))   // time between last entry and load game is not real time
                {
                    he.travelled_seconds += diff;
                }

                if (he.StopMarker || he.StartMarker)
                {
                    he.travelling = false;
                    he.EventDetailedInfo += ((he.EventDetailedInfo.Length > 0) ? Environment.NewLine : "") + "Travelled " + he.travelled_distance.ToString("0.0") + " LY"
                                        + ", " + he.travelled_jumps + " jumps"
                                        + ((he.travelled_missingjump > 0) ? ", " + he.travelled_missingjump + " unknown distance jumps" : "") +
                                        ", time " + he.travelled_seconds;

                    he.travelled_distance = 0;
                    he.travelled_seconds = new TimeSpan(0);
                }
                else
                {
                    he.travelling = true;
                    he.EventDetailedInfo += ((he.EventDetailedInfo.Length > 0) ? Environment.NewLine : "") + "Travelling";

                    if (he.IsFSDJump)
                    {
                        he.EventDetailedInfo += " distance " + he.travelled_distance.ToString("0.0") + " LY"
                                        + ", " + he.travelled_jumps + " jumps"
                                        + ((he.travelled_missingjump > 0) ? ", " + he.travelled_missingjump + " unknown distance jumps" : "") +
                                        ", time " + he.travelled_seconds;
                    }
                }

            }

            if (he.StartMarker)
                he.travelling = true;

            // WORK out docked/landed state

            if (prev != null)
            {
                if (prev.docked.HasValue)                   // copy docked..
                    he.docked = prev.docked;
                if (prev.landed.HasValue)
                    he.landed = prev.landed;

                he.shiptype = prev.shiptype;
                he.wheredocked = prev.wheredocked;
            }

            if (je.EventTypeID == JournalTypeEnum.Location)
            {
                EliteDangerous.JournalEvents.JournalLocation jl = je as EliteDangerous.JournalEvents.JournalLocation;
                he.docked = jl.Docked;
                he.wheredocked = jl.Docked ? jl.StationName : "";
            }
            else if (je.EventTypeID == JournalTypeEnum.Docked)
            {
                EliteDangerous.JournalEvents.JournalDocked jl = je as EliteDangerous.JournalEvents.JournalDocked;
                he.docked = true;
                he.wheredocked = jl.StationName;
            }
            else if (je.EventTypeID == JournalTypeEnum.Undocked)
            {
                he.docked = false;
            }
            else if (je.EventTypeID == JournalTypeEnum.Touchdown)
            {
                he.landed = true;
            }
            else if (je.EventTypeID == JournalTypeEnum.Liftoff)
                he.landed = false;
            else if (je.EventTypeID == JournalTypeEnum.LoadGame)
            {
                he.landed = (je as EliteDangerous.JournalEvents.JournalLoadGame).StartLanded;
                he.shiptype = (je as EliteDangerous.JournalEvents.JournalLoadGame).Ship;
            }
            else if (je.EventTypeID == JournalTypeEnum.ShipyardBuy)
                he.shiptype = (je as EliteDangerous.JournalEvents.JournalShipyardBuy).ShipType;
            else if (je.EventTypeID == JournalTypeEnum.ShipyardNew)
                he.shiptype = (je as EliteDangerous.JournalEvents.JournalShipyardNew).ShipType;
            else if (je.EventTypeID == JournalTypeEnum.ShipyardSwap)
                he.shiptype = (je as EliteDangerous.JournalEvents.JournalShipyardSwap).ShipType;

            return he;
        }

        public void ProcessWithUserDb(EliteDangerous.JournalEntry je, HistoryEntry prev, HistoryList hl , SQLiteConnectionUser conn )      // called after above with a USER connection
        {
            materialscommodities = MaterialCommoditiesList.Process(je, prev?.materialscommodities, conn, EDDiscoveryForm.EDDConfig.ClearMaterials, EDDiscoveryForm.EDDConfig.ClearCommodities);

            snc = SystemNoteClass.GetNoteOnJournalEntry(Journalid);

            if (snc == null && IsFSDJump)
            {
                snc = SystemNoteClass.GetNoteOnSystem(System.name, System.id_edsm);

                if ( snc != null )      // if found..
                {
                    if ( System.id_edsm > 0 && snc.EdsmId <= 0 )    // if we have a system id, but snc not set, update it for next time.
                    {
                        snc.EdsmId = System.id_edsm;
                        snc.Update(conn);
                    }
                }
            }
        }

        #endregion

        public System.Drawing.Bitmap GetIcon
        {
            get
            {
                return EliteDangerous.JournalEntry.GetIcon(EntryType.ToString(),EventDescription);
            }
        }

        public void UpdateMapColour(int v)
        {
            if (EntryType == EliteDangerous.JournalTypeEnum.FSDJump)
            {
                MapColour = v;
                if (Journalid != 0)
                    EliteDangerous.JournalEntry.UpdateMapColour(Journalid, v);
            }
        }

        public void UpdateCommanderID(int v)
        {
            if (Journalid != 0)
            {
                EliteDangerous.JournalEntry.UpdateCommanderID(Journalid, v);
            }
        }

        public void SetEdsmSync()
        {
            EdsmSync = true;
            if (Journalid != 0)
            {
                EliteDangerous.JournalEntry.UpdateSyncFlagBit(Journalid, EliteDangerous.SyncFlags.EDSM, true );
            }
        }
        public void SetEddnSync()
        {
            EDDNSync = true;
            if (Journalid != 0)
            {
                EliteDangerous.JournalEntry.UpdateSyncFlagBit(Journalid, EliteDangerous.SyncFlags.EDDN, true);
            }
        }

        public bool IsJournalEventInEventFilter(string[] events)
        {
            return events.Contains(Tools.SplitCapsWord(EntryType.ToString()));
        }

        public bool IsJournalEventInEventFilter(string eventstr)
        {
            return eventstr == "All" || IsJournalEventInEventFilter(eventstr.Split(';'));
        }

        public bool UpdateSystemNote(string txt)
        {
            if ((snc == null && txt.Length > 0) || (snc != null && !snc.Note.Equals(txt))) // if no system note, and text,  or system not is not text
            {
                if (snc != null && (snc.Journalid == Journalid || snc.Journalid == 0 || (snc.Name.Equals(System.name, StringComparison.InvariantCultureIgnoreCase) && snc.EdsmId <= 0) || (snc.EdsmId > 0 && snc.EdsmId == System.id_edsm)))           // already there, update
                {
                    snc.Note = txt;
                    snc.Time = DateTime.Now;
                    snc.Name = (IsFSDJump) ? System.name : "";
                    snc.Journalid = Journalid;
                    snc.EdsmId = IsFSDJump ? System.id_edsm : 0;
                    snc.Update();
                }
                else
                {
                    snc = new SystemNoteClass();
                    snc.Note = txt;
                    snc.Time = DateTime.Now;
                    snc.Name = IsFSDJump ? System.name : "";
                    snc.Journalid = Journalid;
                    snc.EdsmId = IsFSDJump ? System.id_edsm : 0;
                    snc.Add();
                }

                Debug.WriteLine("Store note {0} {1}", snc.Name, snc.EdsmId);

                return true;
            }

            return false;
        }
    }

    public class HistoryList : IEnumerable<HistoryEntry>
    {
        private List<HistoryEntry> historylist = new List<HistoryEntry>();  // oldest first here

        public MaterialCommoditiesLedger materialcommodititiesledger = new MaterialCommoditiesLedger();       // and the ledger..

        public EliteDangerous.StarScan starscan = new StarScan();                                           // and the results of scanning

        public int CommanderId;

        public HistoryList() { }

        public HistoryList(List<HistoryEntry> hl) { historylist = hl; }

        public void Clear()
        {
            historylist.Clear();
        }

        public void Add(HistoryEntry e)
        {
            historylist.Add(e);
        }

        public List<HistoryEntry> FilterByNumber(int max)
        {
            return historylist.OrderByDescending(s => s.EventTimeUTC).Take(max).ToList();
        }

        public List<HistoryEntry> FilterByDate(TimeSpan days)
        {
            var oldestData = DateTime.UtcNow.Subtract(days);
            return (from systems in historylist where systems.EventTimeUTC >= oldestData orderby systems.EventTimeUTC descending select systems).ToList();
        }

        public int Count { get { return historylist.Count;  } }

        public List<HistoryEntry> EntryOrder
        {
            get
            {
                return historylist;
            }
        }

        public List<HistoryEntry> LastFirst
        {
            get
            {
                return historylist.OrderByDescending(s => s.Indexno).ToList();
            }
        }

        public List<HistoryEntry> OrderByDate
        {
            get
            {
                return historylist.OrderByDescending(s => s.EventTimeUTC).ToList();
            }
        }

        public List<HistoryEntry> FilterByNotEDSMSyncedAndFSD
        {
            get
            {
                return (from s in historylist where s.EdsmSync == false && s.IsFSDJump orderby s.EventTimeUTC ascending select s).ToList();
            }
        }

        public List<HistoryEntry> FilterByScanNotEDDNSynced
        {
            get
            {
                return (from s in historylist where s.EDDNSync == false && s.EntryType== JournalTypeEnum.Scan  orderby s.EventTimeUTC ascending select s).ToList();
            }
        }

        public List<HistoryEntry> FilterByFSDAndPosition
        {
            get
            {
                return (from s in historylist where s.IsFSDJump && s.System.HasCoordinate select s).ToList();
            }
        }

        public List<HistoryEntry> FilterByTravel
        {
            get
            {
                List<HistoryEntry> ents = new List<HistoryEntry>();
                bool resurrect = true;
                foreach (HistoryEntry he in historylist)
                {
                    if (he.EntryType == JournalTypeEnum.Resurrect || he.EntryType == JournalTypeEnum.Died)
                    {
                        resurrect = true;
                        ents.Add(he);
                    }
                    else if ((resurrect && he.EntryType == JournalTypeEnum.Location) || he.EntryType == JournalTypeEnum.FSDJump)
                    {
                        resurrect = false;
                        ents.Add(he);
                    }
                }

                return ents;
            }
        }

        public List<HistoryEntry> FilterByFSD
        {
            get
            {
                return (from s in historylist where s.IsFSDJump select s).ToList();
            }
        }

        public HistoryEntry GetLast
        {
            get
            {
                if (historylist.Count > 0)
                    return historylist[historylist.Count - 1];
                else
                    return null;
            }
        }

        public HistoryEntry GetLastFSD
        {
            get
            {
                return historylist.FindLast(x => x.IsFSDJump);
            }
        }

        public HistoryEntry GetLastHistoryEntry(Predicate<HistoryEntry> where)
        {
            return historylist.FindLast(where);
        }

        public HistoryEntry GetLastWithPosition
        {
            get
            {
                return historylist.FindLast(x => x.System.HasCoordinate);
            }
        }

        public DateTime GetMaxDate
        {
            get
            {
                return historylist.Max(x => x.EventTimeUTC);
            }
        }
        public DateTime GetMinDate
        {
            get
            {
                return historylist.Min(x => x.EventTimeUTC);
            }
        }

        public int GetVisitsCount(string name, long edsmid = 0)
        {
            return historylist.Where(he => he.IsFSDJump && he.System.name.Equals(name, StringComparison.InvariantCultureIgnoreCase) && (edsmid <= 0 || he.System.id_edsm == edsmid)).Count();
        }
        public List<JournalScan> GetScans(string name, long edsmid = 0)
        {
            return (from s in historylist where (s.journalEntry.EventTypeID == JournalTypeEnum.Scan && s.System.name.Equals(name, StringComparison.InvariantCultureIgnoreCase) && (edsmid <= 0 || s.System.id_edsm == edsmid)) select s.journalEntry as JournalScan).ToList<JournalScan>();
        }

        public int GetFSDJumps( TimeSpan t )
        {
            DateTime tme = DateTime.UtcNow.Subtract(t);
            return (from s in historylist where s.IsFSDJump && s.EventTimeUTC>=tme select s).Count();
        }

        public int GetFSDJumps(DateTime start, DateTime to)
        {
            return (from s in historylist where s.IsFSDJump && s.EventTimeLocal >= start && s.EventTimeLocal<to  select s).Count();
        }

        public int GetDocked(DateTime start, DateTime to)
        {
            return (from s in historylist where s.EntryType == JournalTypeEnum.Docked && s.EventTimeLocal >= start && s.EventTimeLocal < to select s).Count();
        }

        public int GetJetConeBoost(DateTime start, DateTime to)
        {
            return (from s in historylist where s.EntryType == JournalTypeEnum.JetConeBoost && s.EventTimeLocal >= start && s.EventTimeLocal < to select s).Count();
        }

        public int GetFSDBoostUsed(DateTime start, DateTime to)
        {
            var list = (from s in historylist where s.EntryType == JournalTypeEnum.FSDJump && s.EventTimeLocal >= start && s.EventTimeLocal   < to select s.journalEntry as JournalFSDJump).ToList<JournalFSDJump>();
            return (from s in list where s.BoostUsed == true select s  ).Count();
        }

        public int GetTouchDown(DateTime start, DateTime to)
        {
            return (from s in historylist where s.EntryType == JournalTypeEnum.Touchdown && s.EventTimeLocal >= start && s.EventTimeLocal < to select s).Count();
        }

        public int GetHeatWarning(DateTime start, DateTime to)
        {
            return (from s in historylist where s.EntryType == JournalTypeEnum.HeatWarning && s.EventTimeLocal >= start && s.EventTimeLocal < to select s).Count();
        }

        public int GetHeatDamage(DateTime start, DateTime to)
        {
            return (from s in historylist where s.EntryType == JournalTypeEnum.HeatDamage && s.EventTimeLocal >= start && s.EventTimeLocal < to select s).Count();
        }

        public int GetFuelScooped(DateTime start, DateTime to)
        {
            return (from s in historylist where s.EntryType == JournalTypeEnum.FuelScoop && s.EventTimeLocal >= start && s.EventTimeLocal < to select s).Count();
        }

        public double GetFuelScoopedTons(DateTime start, DateTime to)
        {
             var list = (from s in historylist where s.EntryType == JournalTypeEnum.FuelScoop && s.EventTimeLocal >= start && s.EventTimeLocal < to select s.journalEntry as JournalFuelScoop).ToList<JournalFuelScoop>();

            return (from s in list select s.Scooped).Sum();
        }

        public double GetTraveledLy(DateTime start, DateTime to)
        {
            var list = (from s in historylist where s.EntryType == JournalTypeEnum.FSDJump && s.EventTimeLocal >= start && s.EventTimeLocal < to select s.journalEntry as JournalFSDJump).ToList<JournalFSDJump>();

            return (from s in list select s.JumpDist).Sum();
        }

        public List<JournalScan> GetScanList(DateTime start, DateTime to)
        {
            var list = (from s in historylist where s.EntryType == JournalTypeEnum.Scan && s.EventTimeLocal >= start && s.EventTimeLocal < to select s.journalEntry as JournalScan).ToList<JournalScan>();
            return list;
        }

        public int GetFSDJumpsBeforeUTC(DateTime utc)
        {
            return (from s in historylist where s.IsFSDJump && s.EventTimeLocal < utc select s).Count();
        }

        public delegate bool FurthestFund(HistoryEntry he, ref double lastv);
        public HistoryEntry GetConditionally( double lastv, FurthestFund f )              // give a comparision function, find entry
        {
            HistoryEntry best = null;
            foreach( HistoryEntry s in historylist )
            {
                if (f(s, ref lastv))
                    best = s;
            }

            return best;
        }

        public void FillInPositionsFSDJumps()       // call if you want to ensure we have the best posibile position data on FSD Jumps.  Only occurs on pre 2.1 with lazy load of just name/edsmid
        {
            List<Tuple<HistoryEntry, SystemClass>> updatesystems = new List<Tuple<HistoryEntry, SystemClass>>();

            using (SQLiteConnectionSystem cn = new SQLiteConnectionSystem())
            {
                foreach (HistoryEntry he in historylist)
                {
                    if (he.IsFSDJump && !he.System.HasCoordinate)   // try and load ones without position.. if its got pos we are happy
                        updatesystems.Add(new Tuple<HistoryEntry, SystemClass>(he, FindEDSM(he)));
                }
            }

            foreach (Tuple<HistoryEntry, SystemClass> he in updatesystems)
            {
                FillEDSM(he.Item1, edsmsys: he.Item2);  // fill, we already have an EDSM system to use
            }
        }

        private SystemClass FindEDSM(HistoryEntry syspos, SQLiteConnectionSystem conn = null, bool reload = false)
        {
            if (syspos.System.status == SystemStatusEnum.EDSC || (!reload && syspos.System.id_edsm == -1))  // if set already, or we tried and failed..
                return null;

            bool ownconn = false;

            try
            {
                if (conn == null)
                {
                    ownconn = true;
                    conn = new SQLiteConnectionSystem();
                }

                return SystemClass.FindEDSM(syspos.System, conn);
            }
            finally
            {
                if (ownconn && conn != null)
                {
                    conn.Dispose();
                }
            }
        }

        public void FillEDSM(HistoryEntry syspos, SystemClass edsmsys = null, bool reload = false, SQLiteConnectionUser uconn = null )       // call to fill in ESDM data for entry, and also fills in all others pointing to the system object
        {
            if (syspos.System.status == SystemStatusEnum.EDSC || (!reload && syspos.System.id_edsm == -1) )  // if set already, or we tried and failed..
                return;

            List<HistoryEntry> alsomatching = new List<HistoryEntry>();

            foreach (HistoryEntry he in historylist)       // list of systems in historylist using the same system object
            {
                if (Object.ReferenceEquals(he.System, syspos.System))
                    alsomatching.Add(he);
            }

            if (edsmsys==null)                              // if we found it externally, do not find again
                edsmsys = FindEDSM(syspos, reload: reload);

            if (edsmsys != null)
            {
                foreach (HistoryEntry he in alsomatching)       // list of systems in historylist using the same system object
                {
                    bool updateedsmid = he.System.id_edsm <= 0;
                    bool updatepos = (he.EntryType == EliteDangerous.JournalTypeEnum.FSDJump || he.EntryType == EliteDangerous.JournalTypeEnum.Location) && !syspos.System.HasCoordinate && edsmsys.HasCoordinate;

                    if (updatepos || updateedsmid)
                        EliteDangerous.JournalEntry.UpdateEDSMIDPosJump(he.Journalid, edsmsys, updatepos, -1 , uconn);  // update pos and edsmid, jdist not updated

                    he.System = edsmsys;
                }
            }
            else
            {
                foreach (HistoryEntry he in alsomatching)       // list of systems in historylist using the same system object
                    he.System.id_edsm = -1;                     // can't do it
            }
        }

        public void CalculateSqDistances(SortedList<double, ISystem> distlist, double x, double y, double z, int maxitems, bool removezerodiststar)
        {
            double dist;
            double dx, dy, dz;

            foreach (HistoryEntry pos in historylist)
            {
                var list = distlist.Values.ToList();

                if (pos.System.HasCoordinate && list.FindIndex(qx => qx.name.Equals(pos.System.name, StringComparison.InvariantCultureIgnoreCase)) == -1)
                {
                    dx = (pos.System.x - x);
                    dy = (pos.System.y - y);
                    dz = (pos.System.z - z);
                    dist = dx * dx + dy * dy + dz * dz;

                    if (dist >= 0.1 || !removezerodiststar)
                    {
                        if (distlist.Count < maxitems)          // if less than max, add..
                            distlist.Add(dist, pos.System);
                        else if (dist < distlist.Last().Key)   // if last entry (which must be the biggest) is greater than dist..
                        {
                            distlist.Add(dist, pos.System);           // add in
                            distlist.RemoveAt(maxitems);        // remove last..
                        }
                    }
                }
            }
        }

        public HistoryEntry FindByName(string name, bool fsdjump = false)
        {
            if (fsdjump)
                return historylist.FindLast(x => x.System.name.Equals(name, StringComparison.InvariantCultureIgnoreCase));
            else
                return historylist.FindLast(x => x.System.name.Equals(name, StringComparison.InvariantCultureIgnoreCase) && x.IsFSDJump);
        }

        public ISystem FindSystem(string name, EDSM.GalacticMapping glist = null)        // in system or name
        {
            ISystem ds1 = SystemClass.GetSystem(name);

            if (ds1 == null)
            {
                HistoryEntry vs = FindByName(name);

                if (vs != null)
                    ds1 = vs.System;
                else if (glist != null)
                {
                    EDSM.GalacticMapObject gmo = glist.Find(name, true, true);

                    if (gmo != null && gmo.points.Count > 0)
                    {
                        return new SystemClass(gmo.name, gmo.points[0].X, gmo.points[0].Y, gmo.points[0].Z);        // fudge it into a system
                    }
                }
            }

            return ds1;
        }

        public HistoryEntry PreviousFrom(HistoryEntry e, bool fsdjumps)
        {
            if (e != null)
            {
                int curindex = historylist.IndexOf(e);

                if (curindex > 0)       // no point with index=0, there is no last.
                {
                    int lastindex = historylist.FindLastIndex(curindex - 1, x => (fsdjumps) ? x.IsFSDJump : true);

                    if (lastindex >= 0)
                        return historylist[lastindex];
                }
            }

            return null;
        }

        public IEnumerator<HistoryEntry> GetEnumerator()
        {
            foreach (var e in historylist)
            {
                yield return e;
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public void SetStartStop( HistoryEntry hs )
        {
            bool started = false;

            foreach ( HistoryEntry he in historylist )
            {
                if (hs == he)
                {
                    if (he.StartMarker)
                    {
                        EliteDangerous.JournalEntry.UpdateSyncFlagBit(hs.Journalid, EliteDangerous.SyncFlags.StartMarker, false);
                        he.StartMarker = false;
                    }
                    else if (he.StopMarker)
                    {
                        EliteDangerous.JournalEntry.UpdateSyncFlagBit(hs.Journalid, EliteDangerous.SyncFlags.StopMarker, false);
                        he.StopMarker = false;
                    }
                    else if (started == false)
                    {
                        EliteDangerous.JournalEntry.UpdateSyncFlagBit(hs.Journalid, EliteDangerous.SyncFlags.StartMarker, true);
                        he.StartMarker = true;
                    }
                    else
                    {
                        EliteDangerous.JournalEntry.UpdateSyncFlagBit(hs.Journalid, EliteDangerous.SyncFlags.StopMarker, true);
                        he.StopMarker = true;
                    }

                    break;
                }
                else if (he.StartMarker)
                    started = true;
                else if (he.StopMarker)
                    started = false;
            }
        }

        // go through the history list and recalculate the materials ledger and the materials count, plus any other stuff..
        public void ProcessUserHistoryListEntries(Func<HistoryList, List<HistoryEntry>> hlfilter)
        {
            List<HistoryEntry> hl = hlfilter(this);

            using (SQLiteConnectionUser conn = new SQLiteConnectionUser())      // splitting the update into two, one using system, one using user helped
            {
                for (int i = 0; i < hl.Count; i++)
                {
                    HistoryEntry he = hl[i];
                    JournalEntry je = he.journalEntry;
                    he.ProcessWithUserDb(je, (i > 0) ? hl[i - 1] : null, this, conn);        // let the HE do what it wants to with the user db

                    Debug.Assert(he.MaterialCommodity != null);

                    this.materialcommodititiesledger.Process(je, conn);            // update the ledger

                    if (je.EventTypeID == JournalTypeEnum.Scan)
                    {
                        if (!this.starscan.AddScanToBestSystem(je as JournalScan, i, hl))
                        {
                            System.Diagnostics.Debug.WriteLine("******** Cannot add scan to system " + (je as JournalScan).BodyName + " in " + he.System.name);
                        }
                    }
                }
            }
        }

        public HistoryEntry AddJournalEntry(JournalEntry je, Action<string> logerror)
        {
            if (je.CommanderId == CommanderId)     // we are only interested at this point accepting ones for the display commander
            {
                HistoryEntry last = GetLast;

                bool journalupdate = false;
                HistoryEntry he = HistoryEntry.FromJournalEntry(je, last, true, out journalupdate);

                if (journalupdate)
                {
                    EliteDangerous.JournalEvents.JournalFSDJump jfsd = je as EliteDangerous.JournalEvents.JournalFSDJump;

                    if (jfsd != null)
                    {
                        EliteDangerous.JournalEntry.UpdateEDSMIDPosJump(jfsd.Id, he.System, !jfsd.HasCoordinate && he.System.HasCoordinate, jfsd.JumpDist);
                    }
                }

                using (SQLiteConnectionUser conn = new SQLiteConnectionUser())
                {
                    he.ProcessWithUserDb(je, last, this, conn);           // let some processes which need the user db to work

                    materialcommodititiesledger.Process(je, conn);
                }

                Add(he);

                if (je.EventTypeID == JournalTypeEnum.Scan)
                {
                    JournalScan js = je as JournalScan;
                    if (!starscan.AddScanToBestSystem(js, Count - 1, EntryOrder))
                    {
                        logerror("Cannot add scan to system - alert the EDDiscovery developers using either discord or Github (see help)" + Environment.NewLine +
                                         "Scan object " + js.BodyName + " in " + he.System.name);
                    }
                }

                return he;
            }
            else
            {
                return null;
            }
        }

        public static HistoryList LoadHistory(EDJournalClass journalmonitor, Func<bool> cancelRequested, Action<int, string> reportProgress, string NetLogPath = null, bool ForceNetLogReload = false, bool ForceJournalReload = false, bool CheckEdsm = false, int CurrentCommander = Int32.MinValue)
        {
            List<HistoryEntry> hl = new List<HistoryEntry>();
            EDCommander cmdr = null;

            if (CurrentCommander >= 0)
            {
                cmdr = EDDConfig.Instance.Commander(CurrentCommander);
                journalmonitor.ParseJournalFiles(() => cancelRequested(), (p, s) => reportProgress(p, s), forceReload: ForceJournalReload);   // Parse files stop monitor..

                if (NetLogPath != null)
                {
                    string errstr = null;
                    NetLogClass.ParseFiles(NetLogPath, out errstr, EDDConfig.Instance.DefaultMapColour, () => cancelRequested(), (p, s) => reportProgress(p, s), ForceNetLogReload, currentcmdrid: CurrentCommander);
                }
            }

            reportProgress(-1, "Resolving systems");

            List<EliteDangerous.JournalEntry> jlist = EliteDangerous.JournalEntry.GetAll(CurrentCommander).OrderBy(x => x.EventTimeUTC).ThenBy(x => x.Id).ToList();
            List<Tuple<EliteDangerous.JournalEntry, HistoryEntry>> jlistUpdated = new List<Tuple<EliteDangerous.JournalEntry, HistoryEntry>>();

            using (SQLiteConnectionSystem conn = new SQLiteConnectionSystem())
            {
                HistoryEntry prev = null;
                foreach (EliteDangerous.JournalEntry je in jlist)
                {
                    bool journalupdate = false;
                    HistoryEntry he = HistoryEntry.FromJournalEntry(je, prev, CheckEdsm, out journalupdate, conn, cmdr);
                    prev = he;

                    hl.Add(he);                        // add to the history list here..

                    if (journalupdate)
                    {
                        jlistUpdated.Add(new Tuple<EliteDangerous.JournalEntry, HistoryEntry>(je, he));
                    }
                }
            }

            if (jlistUpdated.Count > 0)
            {
                reportProgress(-1, "Updating journal entries");

                using (SQLiteConnectionUser conn = new SQLiteConnectionUser(utc: true))
                {
                    using (DbTransaction txn = conn.BeginTransaction())
                    {
                        foreach (Tuple<EliteDangerous.JournalEntry, HistoryEntry> jehe in jlistUpdated)
                        {
                            EliteDangerous.JournalEntry je = jehe.Item1;
                            HistoryEntry he = jehe.Item2;
                            EliteDangerous.JournalEvents.JournalFSDJump jfsd = je as EliteDangerous.JournalEvents.JournalFSDJump;
                            if (jfsd != null)
                            {
                                EliteDangerous.JournalEntry.UpdateEDSMIDPosJump(jfsd.Id, he.System, !jfsd.HasCoordinate && he.System.HasCoordinate, jfsd.JumpDist, conn, txn);
                            }
                        }

                        txn.Commit();
                    }
                }
            }

            // now database has been updated due to initial fill, now fill in stuff which needs the user database

            HistoryList hist = new HistoryList(hl);
            hist.CommanderId = CurrentCommander;

            hist.ProcessUserHistoryListEntries(h => h.ToList());      // here, we update the DBs in HistoryEntry and any global DBs in historylist

            return hist;
        }

        public static HistoryEntry FindNextSystem(List<HistoryEntry> syslist, string sysname, int dir)
        {
            int index = syslist.FindIndex(x => x.System.name.Equals(sysname));

            if (index != -1)
            {
                if (dir == -1)
                {
                    if (index < 1)                                  //0, we go to the end and work from back..
                        index = syslist.Count;

                    int indexn = syslist.FindLastIndex(index - 1, x => x.System.HasCoordinate);

                    if (indexn == -1)                             // from where we were, did not find one, try from back..
                        indexn = syslist.FindLastIndex(x => x.System.HasCoordinate);

                    return (indexn != -1) ? syslist[indexn] : null;
                }
                else
                {
                    index++;

                    if (index == syslist.Count)             // if at end, go to beginning
                        index = 0;

                    int indexn = syslist.FindIndex(index, x => x.System.HasCoordinate);

                    if (indexn == -1)                             // if not found, go to beginning
                        indexn = syslist.FindIndex(x => x.System.HasCoordinate);

                    return (indexn != -1) ? syslist[indexn] : null;
                }
            }
            else
            {
                index = syslist.FindLastIndex(x => x.System.HasCoordinate);
                return (index != -1) ? syslist[index] : null;
            }
        }

        public static HistoryEntry FindLastFSDKnownPosition(List<HistoryEntry> syslist)
        {
            return syslist.FindLast(x => x.System.HasCoordinate && x.IsLocOrJump);
        }

        public static HistoryEntry FindByPos(List<HistoryEntry> syslist, Vector3 p, double limit)     // go thru setting the lastknowsystem
        {
            return syslist.FindLast(x => x.System.HasCoordinate &&
                                            Math.Abs(x.System.x - p.X) < limit &&
                                            Math.Abs(x.System.y - p.Y) < limit &&
                                            Math.Abs(x.System.z - p.Z) < limit);
        }

        public static List<HistoryEntry> FilterByJournalEvent(List<HistoryEntry> he , string eventstring , out int count)
        {
            count = 0;
            if (eventstring.Equals("All"))
                return he;
            else
            {
                string[] events = eventstring.Split(';');
                List<HistoryEntry> ret = (from systems in he where systems.IsJournalEventInEventFilter(events) select systems).ToList();
                count = he.Count - ret.Count;
                return ret;
            }
        }

    }
}


text:
<!DOCTYPE HTML>

<title>Uses of Class mil.nga.geopackage.user.custom.UserCustomDao (GeoPackage 6.5.0 API)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="dc.created" content="2022-09-22">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../../jquery/jquery-ui.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

All Classes

SEARCH:
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">

JavaScript is disabled on your browser.

Uses of Class
mil.nga.geopackage.user.custom.UserCustomDao

Packages that use UserCustomDao

Package
Description

mil.nga.geopackage

mil.nga.geopackage.extension.nga.style

mil.nga.geopackage.extension.related

mil.nga.geopackage.extension.related.media

mil.nga.geopackage.extension.related.simple

mil.nga.geopackage.extension.rtree

mil.nga.geopackage.user.custom

Uses of UserCustomDao in mil.nga.geopackage

Methods in mil.nga.geopackage that return UserCustomDao

Modifier and Type
Method
Description

UserCustomDao
GeoPackage.getUserCustomDao(String tableName)

Get a User Custom DAO from a table name

UserCustomDao
GeoPackage.getUserCustomDao(UserCustomTable table)

Get a User Custom DAO from a table

UserCustomDao
GeoPackageImpl.getUserCustomDao(String tableName)

Get a User Custom DAO from a table name

UserCustomDao
GeoPackageImpl.getUserCustomDao(UserCustomTable table)

Get a User Custom DAO from a table

Uses of UserCustomDao in mil.nga.geopackage.extension.nga.style

Subclasses of UserCustomDao in mil.nga.geopackage.extension.nga.style

Modifier and Type
Class
Description

class
IconDao

Icon DAO for reading icon tables

class
StyleMappingDao

Style Mapping DAO for reading style mapping data tables

Constructors in mil.nga.geopackage.extension.nga.style with parameters of type UserCustomDao

Constructor
Description

IconDao(UserCustomDao dao)

Constructor

StyleMappingDao(UserCustomDao dao)

Constructor

Uses of UserCustomDao in mil.nga.geopackage.extension.related

Subclasses of UserCustomDao in mil.nga.geopackage.extension.related

Modifier and Type
Class
Description

class
UserMappingDao

User Mapping DAO for reading user mapping data tables

Methods in mil.nga.geopackage.extension.related that return UserCustomDao

Modifier and Type
Method
Description

UserCustomDao
RelatedTablesExtension.getUserDao(String tableName)

Get a User Custom DAO from a table name

Constructors in mil.nga.geopackage.extension.related with parameters of type UserCustomDao

Constructor
Description

UserMappingDao(UserCustomDao dao)

Constructor

UserMappingDao(UserCustomDao dao,
              UserMappingTable userMappingTable)

Constructor

Uses of UserCustomDao in mil.nga.geopackage.extension.related.media

Subclasses of UserCustomDao in mil.nga.geopackage.extension.related.media

Modifier and Type
Class
Description

class
MediaDao

User Media DAO for reading user media data tables

Constructors in mil.nga.geopackage.extension.related.media with parameters of type UserCustomDao

Constructor
Description

MediaDao(UserCustomDao dao)

Constructor

MediaDao(UserCustomDao dao,
        MediaTable mediaTable)

Constructor

Uses of UserCustomDao in mil.nga.geopackage.extension.related.simple

Subclasses of UserCustomDao in mil.nga.geopackage.extension.related.simple

Modifier and Type
Class
Description

class
SimpleAttributesDao

User Simple Attributes DAO for reading user simple attributes data tables

Constructors in mil.nga.geopackage.extension.related.simple with parameters of type UserCustomDao

Constructor
Description

SimpleAttributesDao(UserCustomDao dao)

Constructor

SimpleAttributesDao(UserCustomDao dao,
                   SimpleAttributesTable simpleAttributesTable)

Constructor

Uses of UserCustomDao in mil.nga.geopackage.extension.rtree

Subclasses of UserCustomDao in mil.nga.geopackage.extension.rtree

Modifier and Type
Class
Description

class
RTreeIndexTableDao

RTree Index Table DAO for reading geometry index ranges

Uses of UserCustomDao in mil.nga.geopackage.user.custom

Methods in mil.nga.geopackage.user.custom that return UserCustomDao

Modifier and Type
Method
Description

UserCustomDao
UserCustomPaginatedResults.getDao()

static UserCustomDao
UserCustomDao.readTable(String database,
         GeoPackageConnection connection,
         String tableName)

Read the database table and create a DAO

Methods in mil.nga.geopackage.user.custom with parameters of type UserCustomDao

Modifier and Type
Method
Description

static UserCustomPaginatedResults
UserCustomPaginatedResults.create(UserCustomDao dao,
      UserCustomResultSet results)

Create paginated results

Constructors in mil.nga.geopackage.user.custom with parameters of type UserCustomDao

Constructor
Description

UserCustomDao(UserCustomDao dao)

Constructor

UserCustomDao(UserCustomDao dao,
             UserCustomTable userCustomTable)

Constructor

UserCustomPaginatedResults(UserCustomDao dao,
                          UserCustomResultSet results)

Constructor

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

All Classes

JavaScript is disabled on your browser.

Copyright © 2022 National Geospatial-Intelligence Agency. All rights reserved.


text:
/*
 * This client takes in 2 gearmand server definitions and support the 4
 * combinations possible of of gearman_client(s).
 */

#pragma once

#include <vector>

#define ARRAY_LENGTH 4
struct multi_client_test_st
{
  // index 0: no connected clients index 1: only connected to server 1 index 2:
  // only connected to server 2 index 3: connected to both servers
  gearman_client_st* _client_array[ARRAY_LENGTH];
  gearman_client_st* _clone_array[ARRAY_LENGTH];

  multi_client_test_st(server_startup_st& container_, int timeout= 0) :
    _server_container(container_)
  {
    bool has_failed= false;
    for (size_t x= 0; (x < ARRAY_LENGTH) and has_failed == false; x++)
    {
      _clone_array[x]= NULL;
      _client_array[x]= gearman_client_create(NULL);
      has_failed= (_client_array[x] == NULL);
      if (has_failed == false and (timeout > 0))
      {
        gearman_client_set_timeout(_client_array[x], timeout);
      }
    }

    if (has_failed)
    {
      FATAL("new gearman_client_create() failed");
    }
  }

  ~multi_client_test_st()
  {
    for (size_t x= 0; x < ARRAY_LENGTH; ++x)
    {
      if (_client_array[x])
      {
        gearman_client_free(_client_array[x]);
        _client_array[x]= NULL;
      }
      if (_clone_array[x])
      {
        gearman_client_free(_clone_array[x]);
        _clone_array[x]= NULL;
      }
    }
  }

  void add_server(const char* hostname_1, in_port_t port_arg_1, const char* hostname_2, in_port_t port_arg_2)
  {
    gearman_client_add_server(_client_array[1], hostname_1, port_arg_1);
    gearman_client_add_server(_client_array[2], hostname_2, port_arg_2);
    gearman_client_add_server(_client_array[3], hostname_1, port_arg_1);
    gearman_client_add_server(_client_array[3], hostname_2, port_arg_2);
  }

  server_startup_st& server_container(void) const
  {
    return _server_container;
  }

  void push_port(in_port_t arg)
  {
    _ports.push_back(arg);
  }

  in_port_t port(size_t pos)
  {
    FATAL_IF(pos >= _ports.size());
    return _ports[pos];
  }

#define CLIENT_METHODS(NAME, I) \
  gearman_client_st* NAME##_client() \
  { \
    return client(I); \
  } \
  void reset_##NAME##_clone() \
  { \
    reset_clone(I); \
  } \
  void clear_##NAME##_clone() \
  { \
    clear_clone(I); \
  }

  CLIENT_METHODS(unconnected, 0);
  CLIENT_METHODS(connected_to_1, 1);
  CLIENT_METHODS(connected_to_2, 2);
  CLIENT_METHODS(connected_to_both, 3);

private:
  gearman_client_st *client(int index)
  {
    if (_clone_array[index] == NULL)
    {
      _clone_array[index]= gearman_client_clone(NULL, _client_array[index]);
    }

    return _clone_array[index];

  }

  void clear_clone(int index)
  {
    if (_clone_array[index])
    {
      gearman_client_free(_clone_array[index]);
    }

    _clone_array[index]= gearman_client_create(NULL);
  }

  void reset_clone(int index)
  {
    if (_clone_array[index])
    {
      gearman_client_free(_clone_array[index]);
    }

    _clone_array[index]= gearman_client_clone(NULL, _client_array[index]);
  }

private:
  server_startup_st& _server_container;
  std::vector<in_port_t> _ports;
};


text:
The Noto project develops fonts to support all the languages in the world.
For more information about Noto, go to google.com/get/noto

This is the Serif Latin, Greek and Cyrillic and Devanagari family.
It has Regular, Bold, Italic and Bold Italic styles and is hinted.
It has a Sans-Serif sister family, Noto Sans.

Noto fonts for many other languages are available as web fonts in Google Fonts Early Access.


text:
<?xml version="1.0" encoding="UTF-8"?>
<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8">
	<name>Elgg Developer Tools</name>
	<author>Core developers</author>
	<version>1.0</version>
	<category>bundled</category>
	<category>development</category>
	<blurb>Developer tools for Elgg</blurb>
	<description>A set of tools for writing plugins and themes. It is recommended that you have this plugin at the top of the plugin list.</description>
	<website>http://www.elgg.org/</website>
	<bugtracker>http://trac.elgg.org</bugtracker>
	<copyright>See COPYRIGHT.txt</copyright>
	<license>GNU General Public License version 2</license>

	<requires>
		<type>elgg_release</type>
		<version>1.8</version>
	</requires>
</plugin_manifest>