text:
package com.alekseyzhelo.evilislands.mobplugin.script.highlighting;

import com.alekseyzhelo.evilislands.mobplugin.script.EIScriptParserDefinition;
import com.alekseyzhelo.evilislands.mobplugin.script.lexer.EILexer;
import com.alekseyzhelo.evilislands.mobplugin.script.psi.ScriptTypes;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;

import static com.alekseyzhelo.evilislands.mobplugin.script.highlighting.EIScriptSyntaxHighlightingColors.*;

public class EIScriptSyntaxHighlighter extends SyntaxHighlighterBase {

    private static final TextAttributesKey[] BAD_CHAR_KEYS = new TextAttributesKey[]{BAD_CHARACTER};
    private static final TextAttributesKey[] EQUALS_KEYS = new TextAttributesKey[]{EQUALS};
    private static final TextAttributesKey[] COMMA_KEYS = new TextAttributesKey[]{COMMA};
    private static final TextAttributesKey[] PARENTHESES_KEYS = new TextAttributesKey[]{PARENTHESES};
    private static final TextAttributesKey[] KEYWORD_KEYS = new TextAttributesKey[]{KEYWORD};
    private static final TextAttributesKey[] TYPE_KEYS = new TextAttributesKey[]{TYPE};
    private static final TextAttributesKey[] STRING_KEYS = new TextAttributesKey[]{STRING};
    private static final TextAttributesKey[] NUMBER_KEYS = new TextAttributesKey[]{NUMBER};
    private static final TextAttributesKey[] IDENTIFIER_KEYS = new TextAttributesKey[]{IDENTIFIER};
    private static final TextAttributesKey[] COMMENT_KEYS = new TextAttributesKey[]{COMMENT};
    private static final TextAttributesKey[] EMPTY_KEYS = new TextAttributesKey[0];

    @NotNull
    @Override
    public Lexer getHighlightingLexer() {
        return new EILexer();
    }

    @NotNull
    @Override
    public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
        if (tokenType.equals(ScriptTypes.EQUALS)) {
            return EQUALS_KEYS;
        } else if (tokenType.equals(ScriptTypes.COMMA)) {
            return COMMA_KEYS;
        } else if (EIScriptParserDefinition.PARENS.contains(tokenType)) {
            return PARENTHESES_KEYS;
        } else if (EIScriptParserDefinition.KEYWORDS.contains(tokenType)) {
            return KEYWORD_KEYS;
        } else if (EIScriptParserDefinition.TYPES.contains(tokenType)) {
            return TYPE_KEYS;
        } else if (EIScriptParserDefinition.STRING_LITERALS.contains(tokenType)) {
            return STRING_KEYS;
        } else if (EIScriptParserDefinition.NUMERIC_LITERALS.contains(tokenType)) {
            return NUMBER_KEYS;
        } else if (tokenType.equals(ScriptTypes.IDENTIFIER)) {
            return IDENTIFIER_KEYS;
        } else if (EIScriptParserDefinition.COMMENTS.contains(tokenType)) {
            return COMMENT_KEYS;
        } else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
            return BAD_CHAR_KEYS;
        } else {
            return EMPTY_KEYS;
        }
    }
}


text:
package org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog;

import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.behavior.Draggable;
import de.agilecoders.wicket.extensions.markup.html.bootstrap.behavior.DraggableConfig;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.syncope.client.console.panels.AbstractModalPanel;
import org.apache.syncope.client.console.wicket.ajax.form.IndicatorModalCloseBehavior;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.buttons.DefaultModalCloseButton;
import org.apache.syncope.client.ui.commons.panels.ModalPanel;
import org.apache.syncope.client.ui.commons.panels.NotificationPanel;
import org.apache.syncope.client.ui.commons.panels.SubmitableModalPanel;
import org.apache.wicket.Component;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
import org.apache.wicket.event.IEvent;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.util.io.IClusterable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BaseModal<T extends Serializable> extends Modal<T> {

    private static final long serialVersionUID = -6142277554912316095L;

    protected static final Logger LOG = LoggerFactory.getLogger(BaseModal.class);

    /** the default id of the content component */
    public static final String CONTENT_ID = "content";

    private static final String SUBMIT = "submit";

    private static final String FORM = "form";

    protected NotificationPanel notificationPanel;

    private final List<Component> components;

    private WindowClosedCallback windowClosedCallback;

    private Panel content;

    private AjaxSubmitLink submitButton;

    private final Form<T> form;

    private final DefaultModalCloseButton defaultModalCloseButton;

    private AjaxEventBehavior closeBehavior;

    private WebMarkupContainer footer;

    public BaseModal(final String id) {
        super(id);

        form = new Form<>(FORM);
        form.setOutputMarkupId(true);
        add(form);

        content = new AbstractModalPanel<>(this, null) {

            private static final long serialVersionUID = -6142277554912316095L;

        };

        content.setOutputMarkupId(true);

        form.add(content);

        useCloseHandler(true);
        this.windowClosedCallback = null;
        components = new ArrayList<>();

        // Note: not adding this would imply adding of WebjarsJavaScriptResourceReference about JQuery draggable
        add(new Draggable(new DraggableConfig().withHandle(".modal-header").withCursor("move")));

        defaultModalCloseButton = new DefaultModalCloseButton();
        addButton(defaultModalCloseButton);
        setUseKeyboard(true);
        setFadeIn(true);
    }

    public Form<T> getForm() {
        return form;
    }

    public BaseModal<T> setFormModel(final T modelObject) {
        form.setModel(new CompoundPropertyModel<>(modelObject));
        return this;
    }

    public BaseModal<T> setFormModel(final IModel<T> model) {
        form.setModel(model);
        return this;
    }

    public BaseModal<T> setFormAsMultipart(final boolean multipart) {
        form.setMultiPart(multipart);
        return this;
    }

    public T getFormModel() {
        return form.getModelObject();
    }

    public ModalPanel getContent() {
        if (content instanceof ModalPanel) {
            return (ModalPanel) content;
        }
        throw new IllegalStateException();
    }

    public BaseModal<T> setContent(final ModalPanel component) {
        if (component instanceof Panel) {
            return setInternalContent(Panel.class.cast(component));
        }
        throw new IllegalArgumentException("Panel instance is required");
    }

    public BaseModal<T> setContent(final ModalPanel component, final AjaxRequestTarget target) {
        setContent(component);
        target.add(content);
        return this;
    }

    public BaseModal<T> changeCloseButtonLabel(final String label) {
        defaultModalCloseButton.getModel().setObject(label);
        return this;
    }

    public BaseModal<T> changeCloseButtonLabel(final String label, final AjaxRequestTarget target) {
        changeCloseButtonLabel(label);
        target.add(defaultModalCloseButton);
        return this;
    }

    private BaseModal<T> setInternalContent(final Panel component) {
        if (!component.getId().equals(CONTENT_ID)) {
            throw new WicketRuntimeException("Modal content id is wrong. "
                    + "Component ID: " + component.getId() + "; content ID: " + CONTENT_ID);
        }

        content.replaceWith(component);
        content = component;

        return this;
    }

    public BaseModal<T> setWindowClosedCallback(final WindowClosedCallback callback) {
        windowClosedCallback = callback;
        return this;
    }

    @Override
    protected void onClose(final IPartialPageRequestHandler target) {
        if (windowClosedCallback != null) {
            windowClosedCallback.onClose((AjaxRequestTarget) target);
        }
    }

    public AjaxSubmitLink addSubmitButton() {
        if (!(BaseModal.this.getContent() instanceof SubmitableModalPanel)) {
            throw new IllegalStateException();
        }

        AjaxSubmitLink submit = new AjaxSubmitLink(SUBMIT, form) {

            private static final long serialVersionUID = -5783994974426198290L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target) {
                SubmitableModalPanel.class.cast(BaseModal.this.getContent()).onSubmit(target);
            }

            @Override
            protected void onError(final AjaxRequestTarget target) {
                SubmitableModalPanel.class.cast(BaseModal.this.getContent()).onError(target);
            }
        };

        submit.setOutputMarkupId(true);

        if (submitButton == null) {
            submitButton = submit;
            components.add(submitButton);
        } else {
            submitButton.replaceWith(submit);
            submitButton = submit;
        }

        return submit;
    }

    public void removeSubmitButton() {
        if (!(BaseModal.this.getContent() instanceof SubmitableModalPanel)) {
            throw new IllegalStateException();
        }

        components.stream().
                filter(component -> SUBMIT.equals(component.getId())).
                findFirst().
                ifPresent(components::remove);

        submitButton = null;
    }

    @Override
    protected void onInitialize() {
        super.onInitialize();

        final WebMarkupContainer dialog = (WebMarkupContainer) this.get("dialog");
        dialog.setMarkupId(this.getId());

        footer = (WebMarkupContainer) this.get("dialog:footer");
        footer.addOrReplace(new ListView<>("inputs", components) {

            private static final long serialVersionUID = 4949588177564901031L;

            @Override
            protected void populateItem(final ListItem<Component> item) {
                item.add(item.getModelObject());
            }
        }.setOutputMarkupId(true)).setOutputMarkupId(true);
    }

    /**
     * Generic modal event.
     */
    public static class ModalEvent implements Serializable {

        private static final long serialVersionUID = 2668922412196063559L;

        /**
         * Request target.
         */
        private final AjaxRequestTarget target;

        /**
         * Constructor.
         *
         * @param target request target.
         */
        public ModalEvent(final AjaxRequestTarget target) {
            this.target = target;
        }

        /**
         * Target getter.
         *
         * @return request target.
         */
        public AjaxRequestTarget getTarget() {
            return target;
        }
    }

    public static class ChangeFooterVisibilityEvent extends ModalEvent {

        private static final long serialVersionUID = -6157576856659866343L;

        public ChangeFooterVisibilityEvent(final AjaxRequestTarget target) {
            super(target);
        }
    }

    @Override
    public void onEvent(final IEvent<?> event) {
        if (event.getPayload() instanceof ChangeFooterVisibilityEvent) {
            if (BaseModal.this.footer != null) {
                final AjaxRequestTarget target = ChangeFooterVisibilityEvent.class.cast(event.getPayload()).getTarget();
                target.add(BaseModal.this.footer.setEnabled(!BaseModal.this.footer.isEnabled()));
            }
        }
    }

    //--------------------------------------------------------
    // Reqired for SYNCOPE-846
    //--------------------------------------------------------
    /**
     * Sets whether the close handler is used or not. Default is false.
     *
     * @param useCloseHandler True if close handler should be used
     * @return This
     */
    public final Modal<T> useCloseHandler(final boolean useCloseHandler) {
        if (useCloseHandler) {
            if (closeBehavior == null) {
                closeBehavior = new IndicatorModalCloseBehavior() {

                    private static final long serialVersionUID = -4955472558917915340L;

                    @Override
                    protected void onEvent(final AjaxRequestTarget target) {
                        if (isVisible()) {
                            onClose(target);
                            appendCloseDialogJavaScript(target);
                        }
                    }
                };
                add(closeBehavior);
            }
        } else if (closeBehavior != null) {
            remove(closeBehavior);
            closeBehavior = null;
        }
        return this;
    }

    @Override
    public void renderHead(final IHeaderResponse response) {
        super.renderHead(response);
        response.render(OnDomReadyHeaderItem.forScript(createInitializerScript(getMarkupId(true))));
    }

    /**
     * creates the initializer script of the modal dialog.
     *
     * @param markupId The component's markup id
     * @return initializer script
     */
    private String createInitializerScript(final String markupId) {
        return addCloseHandlerScript(markupId, createBasicInitializerScript(markupId));
    }

    /**
     * adds close handler to initializer script, if use of close handler has been defined.
     *
     * @param markupId markup id
     * @param script base script to prepend
     * @return close handler script
     */
    private String addCloseHandlerScript(final String markupId, final String script) {
        if (closeBehavior != null) {
            return script + ";$('#" + markupId + "').on('hidden', function () { "
                    + "  Wicket.Ajax.ajax({'u':'" + closeBehavior.getCallbackUrl() + "','c':'" + markupId + "'});"
                    + "})";
        }

        return script;
    }
    //--------------------------------------------------------

    /**
     * Callback called after the window has been closed. If no callback instance is specified using
     * {@link BaseModal#setWindowClosedCallback(BaseModal.WindowClosedCallback)}, no ajax
     * request will be fired.
     */
    @FunctionalInterface
    public interface WindowClosedCallback extends IClusterable {

        /**
         * Called after the window has been closed.
         *
         * @param target {@link org.apache.wicket.ajax.AjaxRequestTarget} instance bound with the ajax request.
         */
        void onClose(AjaxRequestTarget target);
    }
}

redpajama_set_name: RedPajamaGithub


text:
using System;
using System.Text.RegularExpressions;
using System.Linq;
using System.Text;
using System.IO;

class TxtractTextFromXML
{
    static void Main()
    {
        using (StreamReader reader = new StreamReader ("textXML.xml"))
        {
            string text = reader.ReadToEnd();
            string newText = Regex.Replace(text, @"<.*?>", " ");
            newText = Regex.Replace(newText, @"[ ]{2,}", " ");
            Console.WriteLine(newText.Trim());
        }
    }
}


text:
package gcbatch.utils.mail;

import gcbatch.base.RuntimeContext;
import gcbatch.base.exception.BusinessException;
import gcbatch.utils.FileUtil;
import gcbatch.utils.StringUtil;
import lotus.domino.*;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Vector;

/**
 * 手动关闭
 */
public class NotesMailSender implements AutoCloseable {
	private Session session;
	private Database db;

	public NotesMailSender(String mailDBFile, String hostName, String userName, String password) throws NotesException {
		session = NotesFactory.createSession(hostName, userName, password);
		db = session.getDatabase("", mailDBFile);
		session.setConvertMIME(false);
	}

	public NotesMailSender(MailConfig mailConfig) throws NotesException {
		session = NotesFactory.createSession(mailConfig.getHost(), mailConfig.getUserName(), mailConfig.getPassword());
		db = session.getDatabase("", mailConfig.getMailDB());
		session.setConvertMIME(false);
	}

	public NotesMailSender(RuntimeContext ctx, String mailConfigName) throws NotesException, BusinessException {
		this(ctx.getValue(mailConfigName, MailConfig.class));
	}

	public void sendNoteMail(String subject, String content, String... toMails) throws Exception {
		sendNoteMail(toMails, new String[0], new String[0], subject, content, new String[0]);
	}

	public void sendNoteMail(
			String[] toMails,
			String[] copyToMails,
			String[] blindCopyToMails,
			String subject,
			String content,
			String[] attachFilePaths) throws Exception {
		Document doc = null;
		ArrayList<Stream> attrstreams = new ArrayList<>();

		try {
			Vector<String> toMailsVector = StringUtil.arrayToVector(toMails);
			Vector<String> copyToMailsVector = StringUtil.arrayToVector(copyToMails);
			Vector<String> blindCopyToMailsVector = StringUtil.arrayToVector(blindCopyToMails);
			// session = NotesFactory.createSession(hostName);

			doc = db.createDocument();
			doc.replaceItemValue("Subject", subject);

			// 抄送
			if(copyToMailsVector != null) doc.replaceItemValue("CopyTo", copyToMailsVector);
			if(blindCopyToMailsVector != null) doc.replaceItemValue("BlindCopyTo", blindCopyToMailsVector);

			boolean ishtml = true;
			if (ishtml) {
				MIMEEntity body = doc.createMIMEEntity();
				MIMEEntity bodyChild = body.createChildEntity();

				Stream stream = session.createStream();
				stream.writeText(content);
				bodyChild.setContentFromText(stream, "text/html;charset=utf-8", MIMEEntity.ENC_NONE);
				stream.close();

				String filePath;
				String fileName;

				if (attachFilePaths != null) {
					for (String attachFilePath : attachFilePaths) {
						filePath = attachFilePath;
						fileName = FileUtil.getFileNameFromPath(filePath);

						MIMEEntity attChild = body.createChildEntity();
						MIMEHeader header = attChild.createHeader("Content-Type");
						header.setHeaderVal("multipart/related;charset=utf-8");

						MIMEHeader contentheader = attChild.createHeader("Content-Disposition");

						contentheader.setHeaderVal("attachment; filename==?UTF-8?B?" + Base64.getMimeEncoder().encodeToString(fileName.getBytes(StandardCharsets.UTF_8)) + "?=");

						Stream attrstream = session.createStream();
						attrstream.open(filePath, "binary");
						attChild.setContentFromBytes(attrstream, "application/octet-stream;charset=utf-8", MIMEEntity.ENC_IDENTITY_BINARY);
						attrstreams.add(attrstream);
					}
				}
			} else {
				RichTextItem body = doc.createRichTextItem("Body");
				body.appendText(content);

				body.addNewLine(2);

				String filePath;
				String fileName;
				if (attachFilePaths != null) {
					for (String attachFilePath : attachFilePaths) {
						filePath = attachFilePath;
						fileName = FileUtil.getFileNameFromPath(filePath);
						body.embedObject(EmbeddedObject.EMBED_ATTACHMENT, null, filePath, fileName);
					}
				}
			}

			// doc.replaceItemValue("Form", "Memo");
			doc.replaceItemValue("Logo", "StdNotesLtr2");
			doc.replaceItemValue("dLogo", "StdNotesLtr2");
//			StringTokenizer st = new StringTokenizer(attributes, this.SEPERATOR);
//			while (st.hasMoreTokens()) {
//			    String field = null;
//			    field = st.nextToken().trim();
//			    String[] keyvalue = field.split("=");
//			    if (keyvalue.length == 2) {
//			      doc.replaceItemValue(keyvalue[0], keyvalue[1]);
//			    }
//			}

			doc.send(false, toMailsVector);
			if (ishtml) session.setConvertMIME(true);
		} catch (NotesException e) {
			throw new BusinessException("52352", "发送NOTES邮件异常!" + e.text, e);
		} finally {
			for (Stream stream : attrstreams) {
				try {
					stream.close();
					stream.recycle();
				} catch (NotesException e) { e.printStackTrace(); }
			}
			if (doc != null) try { doc.recycle(); } catch (NotesException e) { e.printStackTrace(); }
		}
	}

	public void sendNoteMail(
			String[] toMails,
			String[] copyToMails,
			String[] blindCopyToMails,
			String subject,
			String content,
			String[] fileNames,
			Stream[] fileStreams
	) throws Exception {
		Document doc = null;

		try {
			Vector<String> toMailsVector = StringUtil.arrayToVector(toMails);
			Vector<String> copyToMailsVector = StringUtil.arrayToVector(copyToMails);
			Vector<String> blindCopyToMailsVector = StringUtil.arrayToVector(blindCopyToMails);
			// session = NotesFactory.createSession(hostName);

			doc = db.createDocument();
			doc.replaceItemValue("Subject", subject);

			// 抄送
			if(copyToMailsVector != null) doc.replaceItemValue("CopyTo", copyToMailsVector);
			if(blindCopyToMailsVector != null) doc.replaceItemValue("BlindCopyTo", blindCopyToMailsVector);

			MIMEEntity body = doc.createMIMEEntity();
			MIMEEntity bodyChild = body.createChildEntity();

			Stream stream = session.createStream();
			stream.writeText(content);
			bodyChild.setContentFromText(stream, "text/html;charset=utf-8", 1725);
			stream.close();

			if (fileNames != null) {
				for (int i = 0; i < fileNames.length; ++i) {
					MIMEEntity attChild = body.createChildEntity();
					MIMEHeader header = attChild.createHeader("Content-Type");
					header.setHeaderVal("multipart/related;charset=utf-8");

					MIMEHeader contentheader = attChild.createHeader("Content-Disposition");

					contentheader.setHeaderVal("attachment; filename==?UTF-8?B?" + Base64.getMimeEncoder().encodeToString(fileNames[i].getBytes(StandardCharsets.UTF_8)) + "?=");
					attChild.setContentFromBytes(fileStreams[i], "application/octet-stream;charset=utf-8", 1730);
				}
			}

			// doc.replaceItemValue("Form", "Memo");
			doc.replaceItemValue("Logo", "StdNotesLtr2");
			doc.replaceItemValue("dLogo", "StdNotesLtr2");

			doc.send(false, toMailsVector);
			session.setConvertMIME(true);
		} catch (NotesException e) {
			throw new BusinessException("52352", "发送NOTES邮件异常!" + e.text, e);
		} finally {
			if (doc != null) try { doc.recycle(); } catch (NotesException e) { e.printStackTrace(); }
		}
	}

	@Override
	public void close() {
		if (db != null) try { db.recycle(); } catch (NotesException e) { e.printStackTrace(); }
		if (session != null) try { session.recycle(); } catch(NotesException e) {e.printStackTrace();}
	}
}


text:
@interface XMGEssenceViewController ()

@end

@implementation XMGEssenceViewController

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

    // 设置导航条
    [self setupNavBar];
}

#pragma mark - 设置导航条
- (void)setupNavBar
{

    // 左边按钮
    // 把UIButton包装成UIBarButtonItem.就导致按钮点击区域扩大
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithimage:[UIImage imageNamed:@"nav_item_game_icon"] highImage:[UIImage imageNamed:@"nav_item_game_click_icon"] target:self action:@selector(game)];

    // 右边按钮
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithimage:[UIImage imageNamed:@"navigationButtonRandom"] highImage:[UIImage imageNamed:@"navigationButtonRandomClick"] target:nil action:nil];

    // titleView
    self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"MainTitle"]];

}

- (void)game
{
    XMGFunc;
}

@end


text:
<?php

namespace Esockets\Base;

final class PingPacket
{
    private $value;
    private $response;

    private function __construct(int $value, bool $response)
    {
        $this->value = $value;
        $this->response = $response;
    }

    public static function request(int $value): self
    {
        return new self($value, false);
    }

    public static function response(int $value): self
    {
        return new self($value, true);
    }

    /**
     * Является ли данный пакет "понг" пакетом.
     */
    public function isResponse(): bool
    {
        return $this->response;
    }

    public function getValue(): int
    {
        return $this->value;
    }
}


text:
using OrchardCore.DisplayManagement.Manifest;
using OrchardCore.Modules.Manifest;

[assembly: Theme(
    Name = "The Blog Theme",
    Author = ManifestConstants.OrchardCoreTeam,
    Website = ManifestConstants.OrchardCoreWebsite,
    Version = ManifestConstants.OrchardCoreVersion,
    Description = "A theme adapted for blogs.",
    Tags = new[] { "Blog", "Bootstrap", "Liquid" }
)]


text:
{% extends 'weblab-master.html' %}

{% block head %}
<link href="{{ url_for('admin.static', filename='select2/select2.css') }}" rel="stylesheet">
{% endblock %}

{% block body %}

{% from "_form_helpers.html" import render_field, render_simple_field %}

General

        <form method="POST" action="{{ request.url }}" class="form-horizontal">
            {{ form.hidden_tag() }}
            <input type="hidden" name="action" value="weblab-create" />

            <fieldset>
                {{ render_field(form.name) }}
                {{ render_field(form.base_url) }}
                {{ render_field(form.username) }}
                {{ render_field(form.password) }}

                    Back
                    <button type="submit" class="btn btn-primary">Save</button>

            </fieldset>
        </form>

{% if experiments %}

Associations

                    Remote system
                    Local mapping
                    Action

            {% for exp in experiments %}

                    <form class="icon" method="POST" action="{{ request.url }}">
                    {{ exp['form'].hidden_tag() }}
                    <input type="hidden" name="action" value="{{ exp['prefix'] }}"></input>
                    {# Label #}
                    {{ exp['experiment'] }}

                    {% if exp['action'] == 'remove' %}
                        {{ render_simple_field(exp['form'].identifier) }}
                        {{ exp['local_name'] }}
                    {% else %}
                        {{ render_simple_field(exp['form'].experiment_identifier) }}
                    {% endif %}

                    {% if exp['action'] == 'remove' %}
                        <button class="btn" type="submit"></button>
                    {% else %}
                        <button class="btn" type="submit"></button>
                    {% endif %}

                    </form>

            {% endfor %}

        {% if misconfigured_experiments %}

Misconfigured associations

The following associations were once added and now the remote system does not provide them anymore

                    Old remote name
                    Local mapping
                    Action

            {% for exp in misconfigured_experiments %}

                    <form class="icon" method="POST" action="{{ request.url }}">
                    {{ exp['form'].hidden_tag() }}
                    <input type="hidden" name="action" value="{{ exp['prefix'] }}"></input>
                    {{ exp['experiment'] }}

                        {{ render_simple_field(exp['form'].identifier) }}
                        {{ exp['local_name'] }}

                        <button class="btn" type="submit"></button>

                    </form>

            {% endfor %}

        {% endif %}

{% endif %}

{% endblock %}

{% block tail %}

{% endblock %}


text:
package sobolan.projecteuler.problems;

/**
 * @author Radu Murzea
 *
 * @problemstatement
 * If the numbers 1 to 5 are written out in words: one, two, three, four, five,
 * then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
 * If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
 * NOTE: Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters
 * and 115 (one hundred and fifteen) contains 20 letters.
 * The use of "and" when writing out numbers is in compliance with British usage.
 */
public class ProjectEuler017 extends AbstractExecutableProblem
{
    private final int WORD_AND = 3;        //and
    private final int WORD_HUNDRED = 7;    //hundred
    private final int WORD_THOUSAND = 8;    //thousand

    private final int[] DIGITS = {
        0,    //zero (won't be used, so won't have any effect)
        3,    //one
        3,    //two
        5,    //three
        4,    //four
        4,    //five
        3,    //six
        5,    //seven
        5,    //eight
        4    //nine
    };

    private final int[] TENS = {
        0,    //zero (won't be used, so won't have any effect)
        3,    //ten
        6,    //twenty
        6,    //thirty
        5,    //forty
        5,    //fifty
        5,    //sixty
        7,    //seventy
        6,    //eighty
        6    //ninety
    };

    private final int[] SPECIALS = {
        0,    //zero (won't be used, so won't have any effect)
        6,    //eleven
        6,    //twelve
        8,    //thirteen
        8,    //fourteen
        7,    //fifteen
        7,    //sixteen
        9,    //seventeen
        8,    //eighteen
        8    //nineteen
    };

    @Override
    public String getResult()
    {
        //start at zero
        int result = 0;

        result += this.getCountFromOneToNineteen();

        //count from 20 to 1000
        for (int i = 20; i <= 1000; i++) {
            //numbers made up of 2 digits
            if (i <= 99) {
                result += this.getCountForTwoDigitNumbers(i);

            //numbers made up of 3 digits
            } else if (i >= 100 && i <= 999) {
                result += this.getCountForThreeDigitNumbers(i);

            //add the one thousand...
            } else if (i == 1000) {
                result += (this.DIGITS[1] + this.WORD_THOUSAND);
            }
        }

        return Integer.toString(result);
    }

    private int getCountFromOneToNineteen()
    {
        int result = 0;

        //count from 1 to 9
        for (int i = 1; i <= 9; i++) {
            result += this.DIGITS[i];
        }

        //count 10
        result += this.TENS[1];

        //count from 11 to 19
        for (int i = 1; i < 10; i++) {
            result += this.SPECIALS[i];
        }

        return result;
    }

    private int getCountForTwoDigitNumbers(int number)
    {
        int tens = number / 10;
        int digit = number % 10;

        //count the tens part and the digits part
        return this.TENS[tens] + this.DIGITS[digit];
    }

    private int getCountForThreeDigitNumbers(int number)
    {
        int result = 0;
        int hundreds = number / 100;
        int tens = (number / 10) % 10;
        int digit = number % 10;

        //add the hundreds part ("five hundred")
        result += this.DIGITS[hundreds];
        result += this.WORD_HUNDRED;

        //if it's not 200 or 300 or 400, then the word "and" must be added
        if (tens != 0 || digit != 0) {
            result += this.WORD_AND;
        }

        switch (tens) {
            //if we're in the ten/eleven/twelve/etc. zone, then it's
            //a little more special
            case 1:
                result += (digit == 0) ? this.TENS[1] : this.SPECIALS[digit];
                break;

            //if the number is of the form 304, 506 etc.,
            //only the digit counts
            case 0:
                result += this.DIGITS[digit];
                break;

            //if it's a "normal" number (342 :D ), then count
            //the tens and the digit
            default:
                result += (this.TENS[tens] + this.DIGITS[digit]);
        }

        return result;
    }
}