text:
#include <stdlib.h>
#include <sys/lock.h>
#include "sdkconfig.h"
#if CONFIG_SDM_ENABLE_DEBUG_LOG
// The local log level must be defined before including esp_log.h
// Set the maximum log level for this source file
#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
#endif
#include "freertos/FreeRTOS.h"
#include "esp_attr.h"
#include "esp_err.h"
#include "esp_heap_caps.h"
#include "esp_log.h"
#include "esp_check.h"
#include "esp_pm.h"
#include "driver/gpio.h"
#include "driver/sdm.h"
#include "hal/gpio_hal.h"
#include "hal/sdm_hal.h"
#include "hal/sdm_ll.h"
#include "soc/sdm_periph.h"
#include "esp_private/esp_clk.h"

#if CONFIG_SDM_CTRL_FUNC_IN_IRAM
#define SDM_MEM_ALLOC_CAPS      (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
#else
#define SDM_MEM_ALLOC_CAPS      MALLOC_CAP_DEFAULT
#endif

#define SDM_PM_LOCK_NAME_LEN_MAX 16

static const char *TAG = "sdm";

typedef struct sdm_platform_t sdm_platform_t;
typedef struct sdm_group_t sdm_group_t;
typedef struct sdm_channel_t sdm_channel_t;

struct sdm_platform_t {
    _lock_t mutex;                                 // platform level mutex lock
    sdm_group_t *groups[SOC_SDM_GROUPS]; // sdm group pool
    int group_ref_counts[SOC_SDM_GROUPS];     // reference count used to protect group install/uninstall
};

struct sdm_group_t {
    int group_id;               // Group ID, index from 0
    portMUX_TYPE spinlock;      // to protect per-group register level concurrent access
    sdm_hal_context_t hal; // hal context
    sdm_channel_t *channels[SOC_SDM_CHANNELS_PER_GROUP]; // array of sdm channels
    sdm_clock_source_t clk_src; // Clock source
};

typedef enum {
    SDM_FSM_INIT,
    SDM_FSM_ENABLE,
} sdm_fsm_t;

struct sdm_channel_t {
    sdm_group_t *group;         // which group the sdm channel belongs to
    uint32_t chan_id;                // allocated channel numerical ID
    int gpio_num;                    // GPIO number
    uint32_t sample_rate_hz;         // Sample rate, in Hz
    portMUX_TYPE spinlock;           // to protect per-channels resources concurrently accessed by task and ISR handler
    esp_pm_lock_handle_t pm_lock;    // PM lock, for glitch filter, as that module can only be functional under APB
    sdm_fsm_t fsm;              // FSM state
#if CONFIG_PM_ENABLE
    char pm_lock_name[SDM_PM_LOCK_NAME_LEN_MAX]; // pm lock name
#endif
};

// sdm driver platform, it's always a singleton
static sdm_platform_t s_platform;

static sdm_group_t *sdm_acquire_group_handle(int group_id)
{
    bool new_group = false;
    sdm_group_t *group = NULL;

    // prevent install sdm group concurrently
    _lock_acquire(&s_platform.mutex);
    if (!s_platform.groups[group_id]) {
        group = heap_caps_calloc(1, sizeof(sdm_group_t), SDM_MEM_ALLOC_CAPS);
        if (group) {
            new_group = true;
            s_platform.groups[group_id] = group; // register to platform
            // initialize sdm group members
            group->group_id = group_id;
            group->spinlock = (portMUX_TYPE)portMUX_INITIALIZER_UNLOCKED;
            group->clk_src = 0;
            // initialize HAL context
            sdm_hal_init(&group->hal, group_id);
            // enable clock
            // note that, this will enables all the channels' output, and channel can't be disable/enable separately
            sdm_ll_enable_clock(group->hal.dev, true);
        }
    } else {
        group = s_platform.groups[group_id];
    }
    if (group) {
        // someone acquired the group handle means we have a new object that refer to this group
        s_platform.group_ref_counts[group_id]++;
    }
    _lock_release(&s_platform.mutex);

    if (new_group) {
        ESP_LOGD(TAG, "new group (%d) at %p", group_id, group);
    }

    return group;
}

static void sdm_release_group_handle(sdm_group_t *group)
{
    int group_id = group->group_id;
    bool do_deinitialize = false;

    _lock_acquire(&s_platform.mutex);
    s_platform.group_ref_counts[group_id]--;
    if (s_platform.group_ref_counts[group_id] == 0) {
        assert(s_platform.groups[group_id]);
        do_deinitialize = true;
        s_platform.groups[group_id] = NULL; // deregister from platform
        sdm_ll_enable_clock(group->hal.dev, false);
    }
    _lock_release(&s_platform.mutex);

    if (do_deinitialize) {
        free(group);
        ESP_LOGD(TAG, "del group (%d)", group_id);
    }
}

static esp_err_t sdm_register_to_group(sdm_channel_t *chan)
{
    sdm_group_t *group = NULL;
    int chan_id = -1;
    for (int i = 0; i < SOC_SDM_GROUPS; i++) {
        group = sdm_acquire_group_handle(i);
        ESP_RETURN_ON_FALSE(group, ESP_ERR_NO_MEM, TAG, "no mem for group (%d)", i);
        // loop to search free unit in the group
        portENTER_CRITICAL(&group->spinlock);
        for (int j = 0; j < SOC_SDM_CHANNELS_PER_GROUP; j++) {
            if (!group->channels[j]) {
                chan_id = j;
                group->channels[j] = chan;
                break;
            }
        }
        portEXIT_CRITICAL(&group->spinlock);
        if (chan_id < 0) {
            sdm_release_group_handle(group);
            group = NULL;
        } else {
            chan->group = group;
            chan->chan_id = chan_id;
            break;
        }
    }
    ESP_RETURN_ON_FALSE(chan_id != -1, ESP_ERR_NOT_FOUND, TAG, "no free channels");
    return ESP_OK;
}

static void sdm_unregister_from_group(sdm_channel_t *chan)
{
    sdm_group_t *group = chan->group;
    int chan_id = chan->chan_id;
    portENTER_CRITICAL(&group->spinlock);
    group->channels[chan_id] = NULL;
    portEXIT_CRITICAL(&group->spinlock);
    // channel has a reference on group, release it now
    sdm_release_group_handle(group);
}

static esp_err_t sdm_destory(sdm_channel_t *chan)
{
    if (chan->pm_lock) {
        ESP_RETURN_ON_ERROR(esp_pm_lock_delete(chan->pm_lock), TAG, "delete pm lock failed");
    }
    if (chan->group) {
        sdm_unregister_from_group(chan);
    }
    free(chan);
    return ESP_OK;
}

esp_err_t sdm_new_channel(const sdm_config_t *config, sdm_channel_handle_t *ret_chan)
{
#if CONFIG_SDM_ENABLE_DEBUG_LOG
    esp_log_level_set(TAG, ESP_LOG_DEBUG);
#endif
    esp_err_t ret = ESP_OK;
    sdm_channel_t *chan = NULL;
    ESP_GOTO_ON_FALSE(config && ret_chan, ESP_ERR_INVALID_ARG, err, TAG, "invalid argument");
    ESP_GOTO_ON_FALSE(GPIO_IS_VALID_OUTPUT_GPIO(config->gpio_num), ESP_ERR_INVALID_ARG, err, TAG, "invalid GPIO number");

    chan = heap_caps_calloc(1, sizeof(sdm_channel_t), SDM_MEM_ALLOC_CAPS);
    ESP_GOTO_ON_FALSE(chan, ESP_ERR_NO_MEM, err, TAG, "no mem for channel");
    // register channel to the group
    ESP_GOTO_ON_ERROR(sdm_register_to_group(chan), err, TAG, "register to group failed");
    sdm_group_t *group = chan->group;
    int group_id = group->group_id;
    int chan_id = chan->chan_id;

    ESP_GOTO_ON_FALSE(group->clk_src == 0 || group->clk_src == config->clk_src, ESP_ERR_INVALID_ARG, err, TAG, "clock source conflict");
    uint32_t src_clk_hz = 0;
    switch (config->clk_src) {
    case SDM_CLK_SRC_APB:
        src_clk_hz = esp_clk_apb_freq();
#if CONFIG_PM_ENABLE
        sprintf(chan->pm_lock_name, "sdm_%d_%d", group->group_id, chan_id); // e.g. sdm_0_0
        ret  = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, chan->pm_lock_name, &chan->pm_lock);
        ESP_RETURN_ON_ERROR(ret, TAG, "create APB_FREQ_MAX lock failed");
#endif
        break;
    default:
        ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "clock source %d is not support", config->clk_src);
        break;
    }
    group->clk_src = config->clk_src;

    // GPIO configuration
    gpio_config_t gpio_conf = {
        .intr_type = GPIO_INTR_DISABLE,
        // also enable the input path is `io_loop_back` is on, this is useful for debug
        .mode = GPIO_MODE_OUTPUT | (config->flags.io_loop_back ? GPIO_MODE_INPUT : 0),
        .pull_down_en = false,
        .pull_up_en = true,
        .pin_bit_mask = 1ULL << config->gpio_num,
    };
    ESP_GOTO_ON_ERROR(gpio_config(&gpio_conf), err, TAG, "config GPIO failed");
    esp_rom_gpio_connect_out_signal(config->gpio_num, sigma_delta_periph_signals.channels[chan_id].sd_sig, config->flags.invert_out, false);
    chan->gpio_num = config->gpio_num;

    // set prescale based on sample rate
    uint32_t prescale = src_clk_hz / config->sample_rate_hz;
    sdm_ll_set_prescale(group->hal.dev, chan_id, prescale);
    chan->sample_rate_hz = src_clk_hz / prescale;
    // preset the duty cycle to zero
    sdm_ll_set_duty(group->hal.dev, chan_id, 0);

    // initialize other members of timer
    chan->spinlock = (portMUX_TYPE)portMUX_INITIALIZER_UNLOCKED;
    chan->fsm = SDM_FSM_INIT; // put the channel into init state

    ESP_LOGD(TAG, "new sdm channel (%d,%d) at %p, gpio=%d, sample rate=%"PRIu32"Hz", group_id, chan_id, chan, chan->gpio_num, chan->sample_rate_hz);
    *ret_chan = chan;
    return ESP_OK;
err:
    if (chan) {
        sdm_destory(chan);
    }
    return ret;
}

esp_err_t sdm_del_channel(sdm_channel_handle_t chan)
{
    ESP_RETURN_ON_FALSE(chan, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
    ESP_RETURN_ON_FALSE(chan->fsm == SDM_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "channel not in init state");
    sdm_group_t *group = chan->group;
    int group_id = group->group_id;
    int chan_id = chan->chan_id;
    ESP_LOGD(TAG, "del channel (%d,%d)", group_id, chan_id);
    // recycle memory resource
    ESP_RETURN_ON_ERROR(sdm_destory(chan), TAG, "destory channel failed");
    return ESP_OK;
}

esp_err_t sdm_channel_enable(sdm_channel_handle_t chan)
{
    ESP_RETURN_ON_FALSE(chan, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
    ESP_RETURN_ON_FALSE(chan->fsm == SDM_FSM_INIT, ESP_ERR_INVALID_STATE, TAG, "channel not in init state");

    // acquire power manager lock
    if (chan->pm_lock) {
        ESP_RETURN_ON_ERROR(esp_pm_lock_acquire(chan->pm_lock), TAG, "acquire pm_lock failed");
    }
    chan->fsm = SDM_FSM_ENABLE;
    return ESP_OK;
}

esp_err_t sdm_channel_disable(sdm_channel_handle_t chan)
{
    ESP_RETURN_ON_FALSE(chan, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
    ESP_RETURN_ON_FALSE(chan->fsm == SDM_FSM_ENABLE, ESP_ERR_INVALID_STATE, TAG, "channel not in enable state");

    // release power manager lock
    if (chan->pm_lock) {
        ESP_RETURN_ON_ERROR(esp_pm_lock_release(chan->pm_lock), TAG, "release pm_lock failed");
    }
    chan->fsm = SDM_FSM_INIT;
    return ESP_OK;
}

esp_err_t sdm_channel_set_duty(sdm_channel_handle_t chan, int8_t duty)
{
    ESP_RETURN_ON_FALSE_ISR(chan, ESP_ERR_INVALID_ARG, TAG, "invalid argument");

    sdm_group_t *group = chan->group;
    int chan_id = chan->chan_id;

    portENTER_CRITICAL_SAFE(&chan->spinlock);
    sdm_ll_set_duty(group->hal.dev, chan_id, duty);
    portEXIT_CRITICAL_SAFE(&chan->spinlock);

    return ESP_OK;
}


text:
package com.intellij.execution.impl;

import com.intellij.execution.ui.ConsoleView;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.ide.ui.LafManager;
import com.intellij.ide.ui.LafManagerListener;
import com.intellij.ide.ui.UISettings;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.EditorSettings;
import com.intellij.openapi.editor.HighlighterColors;
import com.intellij.openapi.editor.colors.*;
import com.intellij.openapi.editor.colors.impl.DelegateColorScheme;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.impl.EditorFactoryImpl;
import com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.containers.ConcurrentFactoryMap;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.awt.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import static com.intellij.execution.ui.ConsoleViewContentType.registerNewConsoleViewType;

/**
 * @author peter
 */
public class ConsoleViewUtil {

  public static final Key<Boolean> EDITOR_IS_CONSOLE_VIEW = Key.create("EDITOR_IS_CONSOLE_VIEW");

  public static EditorEx setupConsoleEditor(Project project, final boolean foldingOutlineShown, final boolean lineMarkerAreaShown) {
    EditorFactory editorFactory = EditorFactory.getInstance();
    EditorEx editor = (EditorEx) editorFactory.createViewer(((EditorFactoryImpl)editorFactory).createDocument(true), project);
    setupConsoleEditor(editor, foldingOutlineShown, lineMarkerAreaShown);
    return editor;
  }

  public static void setupConsoleEditor(@NotNull final EditorEx editor, final boolean foldingOutlineShown, final boolean lineMarkerAreaShown) {
    ApplicationManager.getApplication().runReadAction(new Runnable() {
      @Override
      public void run() {
        editor.setSoftWrapAppliancePlace(SoftWrapAppliancePlaces.CONSOLE);

        final EditorSettings editorSettings = editor.getSettings();
        editorSettings.setLineMarkerAreaShown(lineMarkerAreaShown);
        editorSettings.setIndentGuidesShown(false);
        editorSettings.setLineNumbersShown(false);
        editorSettings.setFoldingOutlineShown(foldingOutlineShown);
        editorSettings.setAdditionalPageAtBottom(false);
        editorSettings.setAdditionalColumnsCount(0);
        editorSettings.setAdditionalLinesCount(0);
        editorSettings.setRightMarginShown(false);
        editorSettings.setCaretRowShown(false);
        editor.getGutterComponentEx().setPaintBackground(false);

        editor.putUserData(EDITOR_IS_CONSOLE_VIEW, true);

        final DelegateColorScheme scheme = updateConsoleColorScheme(editor.getColorsScheme());
        if (UISettings.getInstance().PRESENTATION_MODE) {
          scheme.setEditorFontSize(UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE);
        }
        editor.setColorsScheme(scheme);
      }
    });
  }

  @NotNull
  public static DelegateColorScheme updateConsoleColorScheme(@NotNull EditorColorsScheme scheme) {
    return new DelegateColorScheme(scheme) {
      @NotNull
      @Override
      public Color getDefaultBackground() {
        final Color color = getColor(ConsoleViewContentType.CONSOLE_BACKGROUND_KEY);
        return color == null ? super.getDefaultBackground() : color;
      }

      @NotNull
      @Override
      public FontPreferences getFontPreferences() {
        return getConsoleFontPreferences();
      }

      @Override
      public int getEditorFontSize() {
        return getConsoleFontSize();
      }

      @Override
      public String getEditorFontName() {
        return getConsoleFontName();
      }

      @Override
      public float getLineSpacing() {
        return getConsoleLineSpacing();
      }

      @Override
      public Font getFont(EditorFontType key) {
        return super.getFont(EditorFontType.getConsoleType(key));
      }

      @Override
      public void setEditorFontSize(int fontSize) {
        setConsoleFontSize(fontSize);
      }
    };
  }

  public static boolean isConsoleViewEditor(@NotNull Editor editor) {
    return editor.getUserData(EDITOR_IS_CONSOLE_VIEW) == Boolean.TRUE;
  }

  @SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
  private static class ColorCache {
    static {
      LafManager.getInstance().addLafManagerListener(new LafManagerListener() {
        @Override
        public void lookAndFeelChanged(LafManager source) {
          mergedTextAttributes.clear();
        }
      });
    }
    static final Map<Key, List<TextAttributesKey>> textAttributeKeys = ContainerUtil.newConcurrentMap();
    static final Map<Key, TextAttributes> mergedTextAttributes = new ConcurrentFactoryMap<Key, TextAttributes>() {
      @Nullable
      @Override
      protected TextAttributes create(Key contentKey) {
        EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
        TextAttributes result = scheme.getAttributes(HighlighterColors.TEXT);
        for (TextAttributesKey key : textAttributeKeys.get(contentKey)) {
          TextAttributes attributes = scheme.getAttributes(key);
          if (attributes != null) {
            result = TextAttributes.merge(result, attributes);
          }
        }
        return result;
      }
    };

    static final Map<List<TextAttributesKey>, Key> keys = new ConcurrentFactoryMap<List<TextAttributesKey>, Key>() {
      @Override
      protected Key create(List<TextAttributesKey> keys) {
        StringBuilder keyName = new StringBuilder("ConsoleViewUtil_");
        for (TextAttributesKey key : keys) {
          keyName.append("_").append(key.getExternalName());
        }
        final Key newKey = new Key(keyName.toString());
        textAttributeKeys.put(newKey, keys);
        ConsoleViewContentType contentType = new ConsoleViewContentType(keyName.toString(), HighlighterColors.TEXT) {
          @Override
          public TextAttributes getAttributes() {
            return mergedTextAttributes.get(newKey);
          }
        };

        registerNewConsoleViewType(newKey, contentType);
        return newKey;
      }
    };
  }

  public static void printWithHighlighting(@NotNull ConsoleView console, @NotNull String text, @NotNull SyntaxHighlighter highlighter) {
    Lexer lexer = highlighter.getHighlightingLexer();
    lexer.start(text, 0, text.length(), 0);

    IElementType tokenType;
    while ((tokenType = lexer.getTokenType()) != null) {
      console.print(lexer.getTokenText(), getContentTypeForToken(tokenType, highlighter));
      lexer.advance();
    }
  }

  @NotNull
  public static ConsoleViewContentType getContentTypeForToken(@NotNull IElementType tokenType, @NotNull SyntaxHighlighter highlighter) {
    TextAttributesKey[] keys = highlighter.getTokenHighlights(tokenType);
    return keys.length == 0 ? ConsoleViewContentType.NORMAL_OUTPUT :
           ConsoleViewContentType.getConsoleViewType(ColorCache.keys.get(Arrays.asList(keys)));
  }

  public static void printAsFileType(@NotNull ConsoleView console, @NotNull String text, @NotNull FileType fileType) {
    SyntaxHighlighter highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, null, null);
    if (highlighter != null) {
      printWithHighlighting(console, text, highlighter);
    }
    else {
      console.print(text, ConsoleViewContentType.NORMAL_OUTPUT);
    }
  }
}

redpajama_set_name: RedPajamaGithub


text:
namespace mirage.grid.design {
    export interface IGridChildShape {
        col: number;
        row: number;
        colspan: number;
        rowspan: number;

        hasAutoAuto: boolean;
        hasStarAuto: boolean;
        hasAutoStar: boolean;

        init (child: core.LayoutNode, cm: Segment[][], rm: Segment[][]);
        shouldMeasurePass (pass: MeasureOverridePass): boolean;
        calcConstraint (pass: MeasureOverridePass, gridHasAutoStar: boolean, cm: Segment[][], rm: Segment[][]): ISize;
    }

    export function NewGridChildShape(): IGridChildShape {
        let starRow = false;
        let autoRow = false;
        let starCol = false;
        let autoCol = false;

        let col = 0;
        let row = 0;
        let colspan = 1;
        let rowspan = 1;

        let dopass = MeasureOverridePass.autoAuto;

        function getConstraintInitialSize(pass: MeasureOverridePass, gridHasAutoStar: boolean): ISize {
            switch (pass) {
                case MeasureOverridePass.autoAuto:
                    return new Size(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
                case MeasureOverridePass.starAuto:
                    return new Size(
                        Number.POSITIVE_INFINITY,
                        gridHasAutoStar ? Number.POSITIVE_INFINITY : 0
                    );
                case MeasureOverridePass.starAutoAgain:
                    return new Size(Number.POSITIVE_INFINITY, 0);
                case MeasureOverridePass.autoStar:
                    return new Size(0, Number.POSITIVE_INFINITY);
                case MeasureOverridePass.nonStar:
                    return new Size(
                        autoCol ? Number.POSITIVE_INFINITY : 0,
                        autoRow ? Number.POSITIVE_INFINITY : 0
                    );
            }
            return new Size();
        }

        return {
            col: 0,
            row: 0,
            colspan: 1,
            rowspan: 1,
            hasAutoAuto: false,
            hasStarAuto: false,
            hasAutoStar: false,
            init(child: core.LayoutNode, cm: Segment[][], rm: Segment[][]) {
                col = Math.min(Math.max(0, Grid.getColumn(child) || 0), cm.length - 1);
                row = Math.min(Math.max(0, Grid.getRow(child) || 0), rm.length - 1);
                colspan = Math.min(Math.max(1, Grid.getColumnSpan(child) || 0), cm.length - col);
                rowspan = Math.min(Math.max(1, Grid.getRowSpan(child) || 0), cm.length - col);

                this.col = col;
                this.row = row;
                this.colspan = colspan;
                this.rowspan = rowspan;

                starRow = autoRow = starCol = autoCol = false;
                for (let i = row; i < row + rowspan; i++) {
                    starRow = starRow || (rm[i][i].type === GridUnitType.star);
                    autoRow = autoRow || (rm[i][i].type === GridUnitType.auto);
                }
                for (let i = col; i < col + colspan; i++) {
                    starCol = starCol || (cm[i][i].type === GridUnitType.star);
                    autoCol = autoCol || (cm[i][i].type === GridUnitType.auto);
                }

                this.hasAutoAuto = autoRow && autoCol && !starRow && !starCol;
                this.hasStarAuto = starRow && autoCol;
                this.hasAutoStar = autoRow && starCol;

                if (autoRow && autoCol && !starRow && !starCol) {
                    dopass = MeasureOverridePass.autoAuto;
                } else if (starRow && autoCol && !starCol) {
                    dopass = MeasureOverridePass.starAuto;
                } else if (autoRow && starCol && !starRow) {
                    dopass = MeasureOverridePass.autoStar;
                } else if (!(starRow || starCol)) {
                    dopass = MeasureOverridePass.nonStar;
                } else {
                    dopass = MeasureOverridePass.remainingStar;
                }
            },
            shouldMeasurePass(pass: MeasureOverridePass): boolean {
                return dopass === pass
                    || (pass === MeasureOverridePass.starAutoAgain && dopass === MeasureOverridePass.starAuto);
            },
            calcConstraint (pass: MeasureOverridePass, gridHasAutoStar: boolean, cm: Segment[][], rm: Segment[][]): ISize {
                let childSize = getConstraintInitialSize(pass, gridHasAutoStar);
                for (let i = col; i < col + colspan; i++) {
                    childSize.width += cm[i][i].offered;
                }
                for (let i = row; i < row + rowspan; i++) {
                    childSize.height += rm[i][i].offered;
                }
                return childSize;
            },
        };
    }
}


text:
import React from "react";
import StorybookWrapper from "stories/helpers/storybookWrapper.js";
import StorybookWrapperCore from "stories/helpers/storybookWrapperCore.js";
import baseProps from "stories/helpers/baseProps.js";
import Component from "components/views/Targeting/index.js";
import CoreComponent from "components/views/Targeting/core.js";
import TargetingMock from "mocks/cards/Targeting.mock.js";

export default {
  title: "Cards|Weapons/Targeting",
};
export const Targeting = () => (
  <StorybookWrapper mocks={TargetingMock}>
    <Component {...baseProps} />
  </StorybookWrapper>
);
export const Core = () => (
  <StorybookWrapperCore mocks={TargetingMock}>
    <CoreComponent {...baseProps} />
  </StorybookWrapperCore>
);


text:
package com.zt.core.demo;

import android.app.Application;

import com.squareup.leakcanary.LeakCanary;

/**
 * Created by zhouteng on 2019-09-11
 */
public class DemoApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        if (LeakCanary.isInAnalyzerProcess(this)) {
            return;
        }
        LeakCanary.install(this);
    }
}


text:
.. Instagram PHP documentation master file, created by
   sphinx-quickstart on Thu Jul 21 15:28:11 2016.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

Welcome to Instagram PHP's documentation!
=========================================

Contents:

.. toctree::
   :maxdepth: 2

   overview
   quickstart
   endpoints

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`


text:
function [badtrials trial_var goodtrials]  = CalculateBadTrials(X, thr)
% Function takes input data matrix X (#chans, # trials, # samples)
% It collapses across channels and calculates the variability within a
% trial. If the within trial variance is greater than thr * (across channels ...
% variance). Then reject the trial.

% default threshold is 2 std
if ~exist('thr','var'), thr = 2; end

[nch ntr nbins]=size(X);

% zscore by channel
XZ = bsxfun(@minus,X(:,:),nanmean(X(:,:),2));
XZ = bsxfun(@rdivide,XZ,nanstd(XZ,0,2));
XZ = reshape(XZ,[nch ntr nbins]);

% collapse across channels and calculate the trial covariane matrix
X = permute(XZ,[2 1 3]); clear XZ;
trial_var = nanvar(X(:,:),0,2);

% calculate an upper bound on the variance for each trial
high_var_bound = nanmean(trial_var)+thr*nanstd(trial_var);

% deterime bad trials
badtrials = (trial_var > high_var_bound);
goodtrials= (trial_var < high_var_bound);


text:
<?php

/**
 * Catalog Product Flat observer
 *
 * @category   Mage
 * @package    Mage_Catalog
 * @author     Magento Core Team <core@magentocommerce.com>
 */
class Mage_Catalog_Model_Product_Flat_Observer
{
    /**
     * Retrieve Catalog Product Flat Helper
     *
     * @return Mage_Catalog_Helper_Product_Flat
     */
    protected function _getHelper()
    {
        return Mage::helper('catalog/product_flat');
    }

    /**
     * Retrieve Catalog Product Flat Indexer model
     *
     * @return Mage_Catalog_Model_Product_Flat_Indexer
     */
    protected function _getIndexer() {
        return Mage::getSingleton('catalog/product_flat_indexer');
    }

    /**
     * Catalog Entity attribute after save process
     *
     * @param Varien_Event_Observer $observer
     * @return Mage_Catalog_Model_Product_Flat_Observer
     */
    public function catalogEntityAttributeSaveAfter(Varien_Event_Observer $observer)
    {
        if (!$this->_getHelper()->isBuilt()) {
            return $this;
        }

        $attribute = $observer->getEvent()->getAttribute();
        /* @var $attribute Mage_Catalog_Model_Entity_Attribute */

        $enableBefore   = ($attribute->getOrigData('backend_type') == 'static')
            || ($this->_getHelper()->isAddFilterableAttributes() && $attribute->getOrigData('is_filterable') > 0)
            || ($attribute->getOrigData('used_in_product_listing') == 1)
            || ($attribute->getOrigData('used_for_sort_by') == 1);
        $enableAfter    = ($attribute->getData('backend_type') == 'static')
            || ($this->_getHelper()->isAddFilterableAttributes() && $attribute->getData('is_filterable') > 0)
            || ($attribute->getData('used_in_product_listing') == 1)
            || ($attribute->getData('used_for_sort_by') == 1);

        if (!$enableAfter && !$enableBefore) {
            return $this;
        }

        if ($enableBefore && !$enableAfter) {
            // delete attribute data from flat
            $this->_getIndexer()->prepareDataStorage();
        }
        else {
            $this->_getIndexer()->updateAttribute($attribute->getAttributeCode());
        }

        return $this;
    }

    /**
     * Catalog Product Status Update
     *
     * @param Varien_Event_Observer $observer
     * @return Mage_Catalog_Model_Product_Flat_Observer
     */
    public function catalogProductStatusUpdate(Varien_Event_Observer $observer)
    {
        if (!$this->_getHelper()->isBuilt()) {
            return $this;
        }

        $productId  = $observer->getEvent()->getProductId();
        $status     = $observer->getEvent()->getStatus();
        $storeId    = $observer->getEvent()->getStoreId();
        $storeId    = $storeId > 0 ? $storeId : null;

        $this->_getIndexer()->updateProductStatus($productId, $status, $storeId);

        return $this;
    }

    /**
     * Catalog Product Website(s) update
     *
     * @param Varien_Event_Observer $observer
     * @return Mage_Catalog_Model_Product_Flat_Observer
     */
    public function catalogProductWebsiteUpdate(Varien_Event_Observer $observer)
    {
        if (!$this->_getHelper()->isBuilt()) {
            return $this;
        }

        $websiteIds = $observer->getEvent()->getWebsiteIds();
        $productIds = $observer->getEvent()->getProductIds();

        foreach ($websiteIds as $websiteId) {
            $website = Mage::app()->getWebsite($websiteId);
            foreach ($website->getStores() as $store) {
                if ($observer->getEvent()->getAction() == 'remove') {
                    $this->_getIndexer()->removeProduct($productIds, $store->getId());
                }
                else {
                    $this->_getIndexer()->updateProduct($productIds, $store->getId());
                }
            }
        }

        return $this;
    }

    /**
     * Catalog Product After Save
     *
     * @param Varien_Event_Observer $observer
     * @return Mage_Catalog_Model_Product_Flat_Observer
     */
    public function catalogProductSaveAfter(Varien_Event_Observer $observer) {
        if (!$this->_getHelper()->isBuilt()) {
            return $this;
        }

        $product   = $observer->getEvent()->getProduct();
        $productId = $product->getId();

        $this->_getIndexer()->saveProduct($productId);

        return $this;
    }

    /**
     * Add new store flat process
     *
     * @param Varien_Event_Observer $observer
     * @return Mage_Catalog_Model_Product_Flat_Observer
     */
    public function storeAdd(Varien_Event_Observer $observer)
    {
        if (!$this->_getHelper()->isBuilt()) {
            return $this;
        }

        $store = $observer->getEvent()->getStore();
        /* @var $store Mage_Core_Model_Store */
        $this->_getIndexer()->rebuild($store->getId());

        return $this;
    }

    /**
     * Store edit action, check change store group
     *
     * @param Varien_Event_Observer $observer
     * @return Mage_Catalog_Model_Product_Flat_Observer
     */
    public function storeEdit(Varien_Event_Observer $observer)
    {
        if (!$this->_getHelper()->isBuilt()) {
            return $this;
        }

        $store = $observer->getEvent()->getStore();
        /* @var $store Mage_Core_Model_Store */
        if ($store->dataHasChangedFor('group_id')) {
            $this->_getIndexer()->rebuild($store->getId());
        }

        return $this;
    }

    /**
     * Store delete after process
     *
     * @param Varien_Event_Observer $observer
     * @return Mage_Catalog_Model_Product_Flat_Observer
     */
    public function storeDelete(Varien_Event_Observer $observer)
    {
        if (!$this->_getHelper()->isBuilt()) {
            return $this;
        }

        $store = $observer->getEvent()->getStore();
        /* @var $store Mage_Core_Model_Store */

        $this->_getIndexer()->deleteStore($store->getId());

        return $this;
    }

    /**
     * Store Group Save process
     *
     * @param Varien_Event_Observer $observer
     * @return Mage_Catalog_Model_Product_Flat_Observer
     */
    public function storeGroupSave(Varien_Event_Observer $observer)
    {
        if (!$this->_getHelper()->isBuilt()) {
            return $this;
        }

        $group = $observer->getEvent()->getGroup();
        /* @var $group Mage_Core_Model_Store_Group */

        if ($group->dataHasChangedFor('website_id')) {
            foreach ($group->getStores() as $store) {
                /* @var $store Mage_Core_Model_Store */
                $this->_getIndexer()->rebuild($store->getId());
            }
        }

        return $this;
    }

    /**
     * Catalog Product Import After process
     *
     * @param Varien_Event_Observer $observer
     * @return Mage_Catalog_Model_Product_Flat_Observer
     */
    public function catalogProductImportAfter(Varien_Event_Observer $observer)
    {
        if (!$this->_getHelper()->isBuilt()) {
            return $this;
        }

        $this->_getIndexer()->rebuild();

        return $this;
    }

    /**
     * Customer Group save after process
     *
     * @param Varien_Event_Observer_Collection $observer
     * @return Mage_Catalog_Model_Product_Flat_Observer
     */
    public function customerGroupSaveAfter(Varien_Event_Observer $observer)
    {
        if (!$this->_getHelper()->isBuilt()) {
            return $this;
        }

        $customerGroup = $observer->getEvent()->getObject();
        /* @var $customerGroup Mage_Customer_Model_Group */
        if ($customerGroup->dataHasChangedFor($customerGroup->getIdFieldName())
            || $customerGroup->dataHasChangedFor('tax_class_id')) {
            $this->_getIndexer()->updateEventAttributes();
        }
        return $this;
    }

    /**
     * Update category ids in flat
     *
     * @deprecated 1.3.2.2
     * @param Varien_Event_Observer $observer
     * @return Mage_Catalog_Model_Product_Flat_Observer
     */
    public function catalogCategoryChangeProducts(Varien_Event_Observer $observer)
    {
        return $this;
    }
}


text:
/*
IMPORTANT:
In order to preserve the uniform grid appearance, all cell styles need to have padding, margin and border sizes.
No built-in (selected, editable, highlight, flashing, invalid, loading, :focus) or user-specified CSS
classes should alter those!
*/

.slick-header-columns {
  background: url('../lib/js/lib/slickgrid/images/header-columns-bg.gif') repeat-x center bottom;
  border-bottom: 1px solid silver;
}

.slick-header-column {
  background: url('../lib/js/lib/slickgrid/images/header-columns-bg.gif') repeat-x center bottom;
  border-right: 1px solid silver;
}

.slick-header-column:hover, .slick-header-column-active {
  background: white url('../lib/js/lib/slickgrid/images/header-columns-over-bg.gif') repeat-x center bottom;
}

.slick-headerrow {
  background: #fafafa;
}

.slick-headerrow-column {
  background: #fafafa;
  border-bottom: 0;
  height: 100%;
}

.slick-row.ui-state-active {
  background: #F5F7D7;
}

.slick-row {
  position: absolute;
  background: white;
  border: 0px;
  line-height: 20px;
}

.slick-row.selected {
  z-index: 10;
  background: #DFE8F6;
}

.slick-cell {
  padding-left: 4px;
  padding-right: 4px;
}

.slick-group {
  border-bottom: 2px solid silver;
}

.slick-group-toggle {
  width: 9px;
  height: 9px;
  margin-right: 5px;
}

.slick-group-toggle.expanded {
  background: url(../lib/js/lib/slickgrid/images/collapse.gif) no-repeat center center;
}

.slick-group-toggle.collapsed {
  background: url(../lib/js/lib/slickgrid/images/expand.gif) no-repeat center center;
}

.slick-group-totals {
  color: gray;
  background: white;
}

.slick-cell.selected {
  background-color: beige;
}

.slick-cell.active {
  border-color: gray;
  border-style: solid;
}

.slick-sortable-placeholder {
  background: silver !important;
}

.slick-row[row$="1"], .slick-row[row$="3"], .slick-row[row$="5"], .slick-row[row$="7"], .slick-row[row$="9"] {
  background: #fafafa;
}

.slick-row.ui-state-active {
  background: #F5F7D7;
}

.slick-row.loading {
  opacity: 0.5;
  filter: alpha(opacity = 50);
}

.slick-cell.invalid {
  border-color: red;
}

.grid-header {
  border: 1px solid gray;
  border-bottom: 0;
  border-top: 0;
  background: url('../lib/js/lib/slickgrid/images/header-bg.gif') repeat-x center top;
  color: black;
  height: 24px;
  line-height: 24px;
}

.grid-header label {
  display: inline-block;
  font-weight: bold;
  margin: auto auto auto 6px;
}

.grid-header .ui-icon {
  margin: 4px 4px auto 6px;
  background-color: transparent;
  border-color: transparent;
}

.grid-header .ui-icon.ui-state-hover {
  background-color: white;
}

.grid-header #txtSearch {
  margin: 0 4px 0 4px;
  padding: 2px 2px;
  -moz-border-radius: 2px;
  -webkit-border-radius: 2px;
  border: 1px solid silver;
}

.options-panel {
  -moz-border-radius: 6px;
  -webkit-border-radius: 6px;
  border: 1px solid silver;
  background: #f0f0f0;
  padding: 4px;
  margin-bottom: 20px;
  width: 320px;
  position: absolute;
  top: 0px;
  left: 650px;
}

/* Individual cell styles */
.slick-cell.task-name {
  font-weight: bold;
  text-align: right;
}

.slick-cell.task-percent {
  text-align: right;
}

.slick-cell.cell-move-handle {
  font-weight: bold;
  text-align: right;
  border-right: solid gray;

  background: #efefef;
  cursor: move;
}

.cell-move-handle:hover {
  background: #b6b9bd;
}

.slick-row.selected .cell-move-handle {
  background: #D5DC8D;
}

.slick-row .cell-actions {
  text-align: left;
}

.slick-row.complete {
  background-color: #DFD;
  color: #555;
}

.percent-complete-bar {
  display: inline-block;
  height: 6px;
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;
}

/* Slick.Editors.Text, Slick.Editors.Date */
input.editor-text {
  width: 100%;
  height: 100%;
  border: 0;
  margin: 0;
  background: transparent;
  outline: 0;
  padding: 0;

}

.ui-datepicker-trigger {
  margin-top: 2px;
  padding: 0;
  vertical-align: top;
}

/* Slick.Editors.PercentComplete */
input.editor-percentcomplete {
  width: 100%;
  height: 100%;
  border: 0;
  margin: 0;
  background: transparent;
  outline: 0;
  padding: 0;

  float: left;
}

.editor-percentcomplete-picker {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 100%;
  background: url("../lib/js/lib/slickgrid/images/pencil.gif") no-repeat center center;
  overflow: visible;
  z-index: 1000;
  float: right;
}

.editor-percentcomplete-helper {
  border: 0 solid gray;
  position: absolute;
  top: -2px;
  left: -9px;
  background: url("../lib/js/lib/slickgrid/images/editor-helper-bg.gif") no-repeat top left;
  padding-left: 9px;

  width: 120px;
  height: 140px;
  display: none;
  overflow: visible;
}

.editor-percentcomplete-wrapper {
  background: beige;
  padding: 20px 8px;

  width: 100%;
  height: 98px;
  border: 1px solid gray;
  border-left: 0;
}

.editor-percentcomplete-buttons {
  float: right;
}

.editor-percentcomplete-buttons button {
  width: 80px;
}

.editor-percentcomplete-slider {
  float: left;
}

.editor-percentcomplete-picker:hover .editor-percentcomplete-helper {
  display: block;
}

.editor-percentcomplete-helper:hover {
  display: block;
}

/* Slick.Editors.YesNoSelect */
select.editor-yesno {
  width: 100%;
  margin: 0;
  vertical-align: middle;
}

/* Slick.Editors.Checkbox */
input.editor-checkbox {
  margin: 0;
  height: 100%;
  padding: 0;
  border: 0;
}


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
/*
 * This code was generated by https://github.com/googleapis/google-api-java-client-services/
 * Modify at your own risk.
 */

package com.google.api.services.vault.v1.model;

/**
 * Options for Drive exports.
 *
 *
 This is the Java data model class that specifies how to parse/serialize into the JSON that is
 * transmitted over HTTP when working with the Google Vault API. For a detailed explanation see:
 * https://developers.google.com/api-client-library/java/google-http-java-client/json
 *

 *
 * @author Google, Inc.
 */
@SuppressWarnings("javadoc")
public final class DriveExportOptions extends com.google.api.client.json.GenericJson {

  /**
   * To include access level information for users with [indirect
   * access](https://support.google.com/vault/answer/6099459#metadata) to files, set to **true**.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.Boolean includeAccessInfo;

  /**
   * To include access level information for users with [indirect
   * access](https://support.google.com/vault/answer/6099459#metadata) to files, set to **true**.
   * @return value or {@code null} for none
   */
  public java.lang.Boolean getIncludeAccessInfo() {
    return includeAccessInfo;
  }

  /**
   * To include access level information for users with [indirect
   * access](https://support.google.com/vault/answer/6099459#metadata) to files, set to **true**.
   * @param includeAccessInfo includeAccessInfo or {@code null} for none
   */
  public DriveExportOptions setIncludeAccessInfo(java.lang.Boolean includeAccessInfo) {
    this.includeAccessInfo = includeAccessInfo;
    return this;
  }

  @Override
  public DriveExportOptions set(String fieldName, Object value) {
    return (DriveExportOptions) super.set(fieldName, value);
  }

  @Override
  public DriveExportOptions clone() {
    return (DriveExportOptions) super.clone();
  }

}


text:
package org.apache.flink.api.common.typeutils.base;

import org.apache.flink.annotation.Internal;
import org.apache.flink.api.common.typeutils.SimpleTypeSerializerSnapshot;
import org.apache.flink.api.common.typeutils.TypeSerializerSnapshot;
import org.apache.flink.core.memory.DataInputView;
import org.apache.flink.core.memory.DataOutputView;

import java.io.IOException;

/**
 * Type serializer for {@code Long}.
 */
@Internal
public final class LongSerializer extends TypeSerializerSingleton<Long> {

	private static final long serialVersionUID = 1L;

	/** Sharable instance of the LongSerializer. */
	public static final LongSerializer INSTANCE = new LongSerializer();

	private static final Long ZERO = 0L;

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

	@Override
	public Long createInstance() {
		return ZERO;
	}

	@Override
	public Long copy(Long from) {
		return from;
	}

	@Override
	public Long copy(Long from, Long reuse) {
		return from;
	}

	@Override
	public int getLength() {
		return Long.BYTES;
	}

	@Override
	public void serialize(Long record, DataOutputView target) throws IOException {
		target.writeLong(record);
	}

	@Override
	public Long deserialize(DataInputView source) throws IOException {
		return source.readLong();
	}

	@Override
	public Long deserialize(Long reuse, DataInputView source) throws IOException {
		return deserialize(source);
	}

	@Override
	public void copy(DataInputView source, DataOutputView target) throws IOException {
		target.writeLong(source.readLong());
	}

	@Override
	public TypeSerializerSnapshot<Long> snapshotConfiguration() {
		return new LongSerializerSnapshot();
	}

	// ------------------------------------------------------------------------

	/**
	 * Serializer configuration snapshot for compatibility and format evolution.
	 */
	@SuppressWarnings("WeakerAccess")
	public static final class LongSerializerSnapshot extends SimpleTypeSerializerSnapshot<Long> {

		public LongSerializerSnapshot() {
			super(() -> INSTANCE);
		}
	}
}


text:
const ReactDataGrid = require('react-data-grid');
const exampleWrapper = require('../components/exampleWrapper');
const React = require('react');
const faker = require('faker');
const Immutable = require('immutable');
const {
  ToolsPanel: { AdvancedToolbar: Toolbar, GroupedColumnsPanel },
  Data: { Selectors },
  Draggable: { Container: DraggableContainer }
 } = require('react-data-grid-addons');

import PropTypes from 'prop-types';

faker.locale = 'en_GB';

let _rows = [];
let _cols = [];

for (let j = 0; j < 50; j++) {
  _cols.push({key: 'col' + j, name: 'col' + j, width: 150, draggable: true});
}

for (let rowIdx = 1; rowIdx < 100; rowIdx++) {
  let row = {};
  _cols.forEach((c, colIdx) => {
    row[c.key] = '(' + colIdx + ',' + rowIdx + ')';
  });
  _rows.push(row);
}

class CustomToolbar extends React.Component {
  static propTypes = {
    groupBy: PropTypes.array.isRequired,
    onColumnGroupAdded: PropTypes.func.isRequired,
    onColumnGroupDeleted: PropTypes.func.isRequired
  };

  render() {
    return (
      <Toolbar>
        <GroupedColumnsPanel groupBy={this.props.groupBy} onColumnGroupAdded={this.props.onColumnGroupAdded} onColumnGroupDeleted={this.props.onColumnGroupDeleted}/>
      </Toolbar>);
  }
}

class Example extends React.Component {
  state = {
    rows: new Immutable.fromJS(_rows),
    cols: new Immutable.List(_cols),
    groupBy: [],
    expandedRows: {}
  };

  getRows = () => {
    let rows = Selectors.getRows(this.state);
    return rows;
  };

  getRowAt = (index) => {
    let rows = this.getRows();
    return rows.get(index);
  };

  getSize = () => {
    return this.getRows().size;
  };

  onColumnGroupAdded = (colName) => {
    let columnGroups = this.state.groupBy.slice(0);
    if (columnGroups.indexOf(colName) === -1) {
      columnGroups.push(colName);
    }
    this.setState({ groupBy: columnGroups });
  };

  onColumnGroupDeleted = (name) => {
    let columnGroups = this.state.groupBy.filter(function(g) {return g !== name;});
    this.setState({ groupBy: columnGroups });
  };

  onRowExpandToggle = (args) => {
    let expandedRows = Object.assign({}, this.state.expandedRows);
    expandedRows[args.columnGroupName] = Object.assign({}, expandedRows[args.columnGroupName]);
    expandedRows[args.columnGroupName][args.name] = { isExpanded: args.shouldExpand };
    this.setState({expandedRows: expandedRows});
  };

  render() {
    return (
      <DraggableContainer>
          <ReactDataGrid
            ref={ node => this.grid = node }
            enableCellSelect={true}
            enableDragAndDrop={true}
            columns={_cols}
            rowGetter={this.getRowAt}
            rowsCount={this.getSize()}
            onRowExpandToggle={this.onRowExpandToggle}
            toolbar={<CustomToolbar groupBy={this.state.groupBy} onColumnGroupAdded={this.onColumnGroupAdded} onColumnGroupDeleted={this.onColumnGroupDeleted}/>}
            rowHeight={50}
            minHeight={600}
            />
      </DraggableContainer>
    );
  }
}

module.exports = exampleWrapper({
  WrappedComponent: Example,
  exampleName: 'Row Grouping (immutable collection input) Example',
  examplePath: './scripts/example23-immutable-data-grouping.js'
});


text:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Twitch.Base.Models.NewAPI.Schedule;
using Twitch.Base.Models.NewAPI.Users;

namespace Twitch.Base.UnitTests.NewAPI
{
    [TestClass]
    public class ScheduleServiceUnitTests : UnitTestBase
    {
        [TestMethod]
        public void GetSchedule()
        {
            TestWrapper(async (TwitchConnection connection) =>
            {
                UserModel broadcaster = await UsersServiceUnitTests.GetCurrentUser(connection);

                ScheduleModel schedule = await connection.NewAPI.Schedule.GetSchedule(broadcaster, 5);

                Assert.IsNotNull(schedule);
                Assert.IsNotNull(schedule.segments);
                Assert.IsTrue(schedule.segments.Count > 0);
            });
        }
    }
}


text:
package com.vityuk.ginger;

import com.vityuk.ginger.provider.LocalizationProvider;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.fest.assertions.api.Assertions.assertThat;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class DefaultLocalizationTest {
    @Rule
    public ExpectedException thrown = ExpectedException.none();

    private Localization<Localizable> localization;

    @Mock
    private LocalizationProvider localizationProvider;

    @Before
    public void setUp() throws Exception {
        localization = new DefaultLocalization(localizationProvider);
    }

    @Test
    public void testStringConstant() {
        String testValue = "test value";
        when(localizationProvider.getString("test.string")).thenReturn(testValue);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        String result = constants.testString();

        assertThat(result).isNotNull().isEqualTo(testValue);
    }

    @Test
    public void testStringConstantWithNullValue() {
        when(localizationProvider.getString("test.string")).thenReturn(null);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        String result = constants.testString();

        assertThat(result).isNull();
    }

    @Test(expected = RuntimeException.class)
    public void testStringConstantWithException() {
        when(localizationProvider.getString("test.string")).thenThrow(new RuntimeException());
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        constants.testString();
    }

    @Test
    public void testBooleanConstant() {
        Boolean testValue = Boolean.TRUE;
        when(localizationProvider.getBoolean("test.boolean")).thenReturn(testValue);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        Boolean result = constants.testBoolean();

        assertThat(result).isNotNull().isEqualTo(testValue);
    }

    @Test
    public void testBooleanConstantWithNullValue() {
        when(localizationProvider.getBoolean("test.boolean")).thenReturn(null);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        Boolean result = constants.testBoolean();

        assertThat(result).isNull();
    }

    @Test(expected = RuntimeException.class)
    public void testBooleanConstantWithException() {
        when(localizationProvider.getBoolean("test.boolean")).thenThrow(new RuntimeException());
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        constants.testBoolean();
    }

    @Test
    public void testIntegerConstant() {
        Integer testValue = Integer.MAX_VALUE;
        when(localizationProvider.getInteger("test.int")).thenReturn(testValue);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        Integer result = constants.testInt();

        assertThat(result).isNotNull().isEqualTo(testValue);
    }

    @Test
    public void testIntegerConstantWithNullValue() {
        when(localizationProvider.getInteger("test.int")).thenReturn(null);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        Integer result = constants.testInt();

        assertThat(result).isNull();
    }

    @Test(expected = RuntimeException.class)
    public void testIntegerConstantWithException() {
        when(localizationProvider.getInteger("test.int")).thenThrow(new RuntimeException());
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        constants.testInt();
    }

    @Test
    public void testLongConstant() {
        Long testValue = Long.MIN_VALUE;
        when(localizationProvider.getLong("test.long")).thenReturn(testValue);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        Long result = constants.testLong();

        assertThat(result).isNotNull().isEqualTo(testValue);
    }

    @Test
    public void testLongConstantWithNullValue() {
        when(localizationProvider.getLong("test.long")).thenReturn(null);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        Long result = constants.testLong();

        assertThat(result).isNull();
    }

    @Test(expected = RuntimeException.class)
    public void testLongConstantWithException() {
        when(localizationProvider.getLong("test.long")).thenThrow(new RuntimeException());
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        constants.testLong();
    }

    @Test
    public void testFloatConstant() {
        Float testValue = Float.MAX_VALUE;
        when(localizationProvider.getFloat("test.float")).thenReturn(testValue);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        Float result = constants.testFloat();

        assertThat(result).isNotNull().isEqualTo(testValue);
    }

    @Test
    public void testFloatConstantWithNullValue() {
        when(localizationProvider.getFloat("test.float")).thenReturn(null);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        Float result = constants.testFloat();

        assertThat(result).isNull();
    }

    @Test(expected = RuntimeException.class)
    public void testFloatConstantWithException() {
        when(localizationProvider.getFloat("test.float")).thenThrow(new RuntimeException());
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        constants.testFloat();
    }

    @Test
    public void testDoubleConstant() {
        Double testValue = Double.MIN_VALUE;
        when(localizationProvider.getDouble("test.double")).thenReturn(testValue);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        Double result = constants.testDouble();

        assertThat(result).isNotNull().isEqualTo(testValue);
    }

    @Test
    public void testDoubleConstantWithNullValue() {
        when(localizationProvider.getDouble("test.double")).thenReturn(null);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        Double result = constants.testDouble();

        assertThat(result).isNull();
    }

    @Test(expected = RuntimeException.class)
    public void testDoubleConstantWithException() {
        when(localizationProvider.getDouble("test.double")).thenThrow(new RuntimeException());
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        constants.testDouble();
    }

    @Test
    public void testStringListConstant() {
        List<String> testValue = Arrays.asList("a", "b", "c");
        when(localizationProvider.getStringList("test.string.list")).thenReturn(testValue);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        List<String> result = constants.testStringList();

        assertThat(result).isNotNull().isEqualTo(testValue);
    }

    @Test
    public void testStringListConstantWithNullValue() {
        when(localizationProvider.getStringList("test.string.list")).thenReturn(null);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        List<String> result = constants.testStringList();

        assertThat(result).isNull();
    }

    @Test(expected = RuntimeException.class)
    public void testStringListConstantWithException() {
        when(localizationProvider.getStringList("test.string.list")).thenThrow(new RuntimeException());
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        constants.testStringList();
    }

    @Test
    public void testStringMapConstant() {
        Map<String, String> testValue = new HashMap<String, String>();
        testValue.put("a", "1");
        testValue.put("b", "2");
        testValue = Collections.unmodifiableMap(testValue);
        when(localizationProvider.getStringMap("test.string.map")).thenReturn(testValue);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        Map<String, String> result = constants.testStringMap();

        assertThat(result).isNotNull().isEqualTo(testValue);
    }

    @Test
    public void testStringMapConstantWithNullValue() {
        when(localizationProvider.getStringMap("test.string.map")).thenReturn(null);
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        Map<String, String> result = constants.testStringMap();

        assertThat(result).isNull();
    }

    @Test(expected = RuntimeException.class)
    public void testStringMapConstantWithException() {
        when(localizationProvider.getStringMap("test.string.map")).thenThrow(new RuntimeException());
        TestConstants constants = localization.getLocalizable(TestConstants.class);

        constants.testStringMap();
    }

    @Test
    public void testConstantWithInvalidReturnTypeCharacter() {
        thrown.expect(InvalidReturnTypeException.class);
        String expectedMessage = "Invalid return type: java.lang.Character for method: testChar in " +
                TestConstantsWithChar.class.getName();
        thrown.expectMessage(expectedMessage);

        TestConstantsWithChar localizable = localization.getLocalizable(TestConstantsWithChar.class);
        localizable.testChar();

        verifyZeroInteractions(localizationProvider);
    }

    @Test
    public void testConstantWithInvalidReturnTypePrimitive() {
        thrown.expect(InvalidReturnTypeException.class);
        String expectedMessage = "Invalid return type: boolean for method: testBoolean in " +
                TestConstantsWithPrimitiveBoolean.class.getName();
        thrown.expectMessage(expectedMessage);

        TestConstantsWithPrimitiveBoolean localizable = localization.getLocalizable(TestConstantsWithPrimitiveBoolean.class);
        localizable.testBoolean();

        verifyZeroInteractions(localizationProvider);
    }

    @Test
    public void testSingleStringArgumentMessage() {
        String arg = "test arg";
        String message = "Hello, " + arg;
        when(localizationProvider.getMessage("single.string.argument", arg)).thenReturn(message);
        TestMessages messages = localization.getLocalizable(TestMessages.class);

        String result = messages.singleStringArgument(arg);

        assertThat(result).isNotNull().isEqualTo(message);
    }

    @Test
    public void testSingleBooleanArgumentMessage() {
        Boolean arg = Boolean.TRUE;
        String message = "Hello, " + arg;
        when(localizationProvider.getMessage("single.boolean.argument", arg)).thenReturn(message);
        TestMessages messages = localization.getLocalizable(TestMessages.class);

        String result = messages.singleBooleanArgument(arg);

        assertThat(result).isNotNull().isEqualTo(message);
    }

    @Test
    public void testSingleIntegerArgumentMessage() {
        Integer arg = Integer.MIN_VALUE;
        String message = "Hello, " + arg;
        when(localizationProvider.getMessage("single.integer.argument", arg)).thenReturn(message);
        TestMessages messages = localization.getLocalizable(TestMessages.class);

        String result = messages.singleIntegerArgument(arg);

        assertThat(result).isNotNull().isEqualTo(message);
    }

    @Test
    public void testSingleLongArgumentMessage() {
        Long arg = Long.MAX_VALUE;
        String message = "Hello, " + arg;
        when(localizationProvider.getMessage("single.long.argument", arg)).thenReturn(message);
        TestMessages messages = localization.getLocalizable(TestMessages.class);

        String result = messages.singleLongArgument(arg);

        assertThat(result).isNotNull().isEqualTo(message);
    }

    @Test
    public void testSingleFloatArgumentMessage() {
        Float arg = Float.MAX_VALUE;
        String message = "Hello, " + arg;
        when(localizationProvider.getMessage("single.float.argument", arg)).thenReturn(message);
        TestMessages messages = localization.getLocalizable(TestMessages.class);

        String result = messages.singleFloatArgument(arg);

        assertThat(result).isNotNull().isEqualTo(message);
    }

    @Test
    public void testSingleDoubleArgumentMessage() {
        Double arg = Double.MIN_VALUE;
        String message = "Hello, " + arg;
        when(localizationProvider.getMessage("single.double.argument", arg)).thenReturn(message);
        TestMessages messages = localization.getLocalizable(TestMessages.class);

        String result = messages.singleDoubleArgument(arg);

        assertThat(result).isNotNull().isEqualTo(message);
    }

    @Test
    public void testSinglePrimitiveArgumentMessage() {
        int arg = Integer.MIN_VALUE;
        String message = "Hello, " + arg;
        when(localizationProvider.getMessage("single.primitive.argument", arg)).thenReturn(message);
        TestMessages messages = localization.getLocalizable(TestMessages.class);

        String result = messages.singlePrimitiveArgument(arg);

        assertThat(result).isNotNull().isEqualTo(message);
    }

    @Test
    public void testMultipleArgumentsMessage() {
        String arg0 = "test";
        boolean arg1 = false;
        Integer arg2 = 547;
        long arg3 = 23534534;
        Float arg4 = 423543.0533F;
        double arg5 = -1.0432522;

        String message = "Test " + arg0 + ", " + arg1 + ", " + arg2 + ", " + arg3 + ", " + arg4 + ", " + arg5;
        when(localizationProvider.getMessage("multiple.arguments",
                arg0, arg1, arg2, arg3, arg4, arg5)).thenReturn(message);
        TestMessages messages = localization.getLocalizable(TestMessages.class);

        String result = messages.multipleArguments(arg0, arg1, arg2, arg3, arg4, arg5);

        assertThat(result).isNotNull().isEqualTo(message);
    }

    @Test
    public void testSingleSelectorArgumentMessage() {
        String selectorValue = "female";
        String message = "She likes cats";
        when(localizationProvider.getSelectedMessage("single.selector.argument", selectorValue)).thenReturn(message);
        TestMessages messages = localization.getLocalizable(TestMessages.class);

        String result = messages.singleSelectorArgument(new Selector(selectorValue));

        assertThat(result).isNotNull().isEqualTo(message);
    }

    @Test
    public void testMultipleSelectorArgumentsMessage() {
        String arg0 = "test";
        boolean arg1 = false;
        Integer arg2 = 547;
        String selector = "male";
        long arg4 = 23534534;
        Float arg5 = 423543.0533F;
        double arg6 = -1.0432522;

        String message = "He likes cats";
        when(localizationProvider.getSelectedMessage("multiple.selector.arguments",
                selector, arg0, arg1, arg2, arg4, arg5, arg6)).thenReturn(message);
        TestMessages messages = localization.getLocalizable(TestMessages.class);

        String result = messages.multipleSelectorArguments(arg0, arg1, arg2, selector, arg4, arg5, arg6);

        assertThat(result).isNotNull().isEqualTo(message);
    }

    @Test
    public void testMessageWithInvalidSelectorParameterType() {
        thrown.expect(InvalidParameterTypeException.class);
        String expectedMessage = "Invalid parameter type: java.lang.Boolean for method: message in " +
                TestMessagesWithIncorrectSelectorParameterType.class.getName();
        thrown.expectMessage(expectedMessage);

        try {
            TestMessagesWithIncorrectSelectorParameterType localizable = localization.getLocalizable(TestMessagesWithIncorrectSelectorParameterType.class);
            localizable.message(Boolean.TRUE);
        } finally {
            verifyZeroInteractions(localizationProvider);
        }
    }
    @Test
    public void testSinglePluralCountArgumentMessage() {
        int count = 101;
        String message = "101 horses";
        when(localizationProvider.getPluralMessage("single.plural.count.argument", count)).thenReturn(message);
        TestMessages messages = localization.getLocalizable(TestMessages.class);

        String result = messages.singlePluralCountArgument(count);

        assertThat(result).isNotNull().isEqualTo(message);
    }

    @Test
    public void testMultiplePluralCountArgumentsMessage() {
        String arg0 = "test";
        boolean arg1 = false;
        Integer arg2 = 547;
        int pluralCount = 1;
        long arg4 = 23534534;
        Float arg5 = 423543.0533F;
        double arg6 = -1.0432522;

        String message = "One cat";
        when(localizationProvider.getPluralMessage("multiple.plural.count.arguments",
                pluralCount, arg0, arg1, arg2, arg4, arg5, arg6)).thenReturn(message);
        TestMessages messages = localization.getLocalizable(TestMessages.class);

        String result = messages.multiplePluralCountArguments(arg0, arg1, arg2, pluralCount, arg4, arg5, arg6);

        assertThat(result).isNotNull().isEqualTo(message);
    }

    @Test
    public void testMessageWithInvalidPluralCountParameterType() {
        thrown.expect(InvalidParameterTypeException.class);
        String expectedMessage = "Invalid parameter type: float for method: message in " +
                TestMessagesWithIncorrectPluralCountParameterType.class.getName();
        thrown.expectMessage(expectedMessage);

        try {
            TestMessagesWithIncorrectPluralCountParameterType localizable = localization.getLocalizable(TestMessagesWithIncorrectPluralCountParameterType.class);
            localizable.message(10);
        } finally {
            verifyZeroInteractions(localizationProvider);
        }
    }

    @Test
    public void testMessageWithNullMessage() {
        String arg = "test";
        when(localizationProvider.getMessage("single.string.argument", arg)).thenReturn(null);
        TestMessages messages = localization.getLocalizable(TestMessages.class);

        String result = messages.singleStringArgument(arg);

        assertThat(result).isNull();
    }

    @Test(expected = RuntimeException.class)
    public void testMessageWithException() {
        String arg = "test";
        when(localizationProvider.getMessage("single.string.argument", arg)).thenThrow(new RuntimeException());
        TestMessages messages = localization.getLocalizable(TestMessages.class);

        messages.singleStringArgument(arg);
    }

    @Test
    public void testMessageWithInvalidReturnType() {
        thrown.expect(InvalidReturnTypeException.class);
        String expectedMessage = "Invalid return type: java.lang.Boolean for method: message in " +
                TestMessagesWithIncorrectReturnType.class.getName();
        thrown.expectMessage(expectedMessage);

        try {
            TestMessagesWithIncorrectReturnType localizable = localization.getLocalizable(TestMessagesWithIncorrectReturnType.class);
            localizable.message(Boolean.TRUE);
        } finally {
            verifyZeroInteractions(localizationProvider);
        }
    }

    @Test(expected = NullPointerException.class)
    public void testGetLocalizableWithNull() {
        localization.getLocalizable(null);
    }

    @Test
    public void testGetLocalizableWithClass() {
        thrown.expect(IllegalArgumentException.class);
        String expectedMessage = "Parameter 'localizable' must be an interface";
        thrown.expectMessage(expectedMessage);

        localization.getLocalizable(TestClass.class);
    }

    @SuppressWarnings("unchecked")
    @Test
    public void testGetLocalizableWithInvalidInterface() {
        thrown.expect(IllegalArgumentException.class);
        String expectedMessage = TestInvalidInterface.class.getName() + " must extend " + Localizable.class.getName();
        thrown.expectMessage(expectedMessage);

        Class<?> localizableClass = TestInvalidInterface.class;
        localization.getLocalizable((Class<Localizable>) localizableClass);
    }

    interface TestConstants extends Localizable {
        String testString();

        Boolean testBoolean();

        Integer testInt();

        Long testLong();

        Float testFloat();

        Double testDouble();

        List<String> testStringList();

        Map<String, String> testStringMap();
    }

    interface TestConstantsWithChar extends Localizable {
        Character testChar();
    }

    interface TestConstantsWithPrimitiveBoolean extends Localizable {
        boolean testBoolean();
    }

    interface TestMessages extends Localizable {
        String singleStringArgument(String arg);

        String singleBooleanArgument(Boolean arg);

        String singleIntegerArgument(Integer arg);

        String singleLongArgument(Long arg);

        String singleFloatArgument(Float arg);

        String singleDoubleArgument(Double arg);

        String singlePrimitiveArgument(int arg);

        String multipleArguments(String arg0, boolean arg1, Integer arg2, long arg3, Float arg4, double arg5);

        String singleSelectorArgument(@Select Selector arg);

        String multipleSelectorArguments(String arg0, boolean arg1, Integer arg2, @Select String arg3,
                                         long arg4, Float arg5, double arg6);

        String singlePluralCountArgument(@PluralCount int arg);

        String multiplePluralCountArguments(String arg0, boolean arg1, Integer arg2, @PluralCount Integer arg3,
                                            long arg4, Float arg5, double arg6);
    }

    interface TestMessagesWithIncorrectReturnType extends Localizable {
        Boolean message(Boolean arg);
    }

    interface TestMessagesWithIncorrectPluralCountParameterType extends Localizable {
        String message(@PluralCount float arg);
    }

    interface TestMessagesWithIncorrectSelectorParameterType extends Localizable {
        String message(@Select Boolean arg);
    }

    static class TestClass implements Localizable {
    }

    interface TestInvalidInterface {
    }

    private static class Selector {
        private final String value;

        public Selector(String value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return value.toString();
        }
    }
}


text:
<TS version="2.1" language="zh_Hans">
<context>
    <name>AddressBookPage</name>
    <message>
        <source>Right-click to edit address or label</source>
        <translation type="unfinished">右击编辑地址或标签</translation>
    </message>
    <message>
        <source>Create a new address</source>
        <translation>创建一个新的地址</translation>
    </message>
    <message>
        <source>&New</source>
        <translation type="unfinished">新建</translation>
    </message>
    <message>
        <source>Copy the currently selected address to the system clipboard</source>
        <translation>复制选定的地址到系统剪切板</translation>
    </message>
    <message>
        <source>&Copy</source>
        <translation type="unfinished">复制</translation>
    </message>
    <message>
        <source>C&lose</source>
        <translation type="unfinished">关闭</translation>
    </message>
    <message>
        <source>Delete the currently selected address from the list</source>
        <translation>从列表删除选定的地址</translation>
    </message>
    <message>
        <source>Enter address or label to search</source>
        <translation type="unfinished">输入地址或者标签进行搜索</translation>
    </message>
    <message>
        <source>Export the data in the current tab to a file</source>
        <translation>导出当前数据到文件</translation>
    </message>
    <message>
        <source>&Export</source>
        <translation>导出</translation>
    </message>
    <message>
        <source>&Delete</source>
        <translation>删除</translation>
    </message>
    <message>
        <source>Choose the address to send coins to</source>
        <translation type="unfinished">选择发送比特币地址</translation>
    </message>
    <message>
        <source>Choose the address to receive coins with</source>
        <translation type="unfinished">选择接收比特币地址</translation>
    </message>
    <message>
        <source>C&hoose</source>
        <translation type="unfinished">选择</translation>
    </message>
    <message>
        <source>Sending addresses</source>
        <translation type="unfinished">发送地址</translation>
    </message>
    <message>
        <source>Receiving addresses</source>
        <translation type="unfinished">接收地址</translation>
    </message>
    <message>
        <source>These are your Qtum addresses for sending payments. Always check the amount and the receiving address before sending coins.</source>
        <translation type="unfinished">这是你的比特币发币地址。发送前请确认发送数量和接收地址</translation>
    </message>
    <message>
        <source>These are your Qtum addresses for receiving payments. Use the 'Create new receiving address' button in the receive tab to create new addresses.
Signing is only possible with addresses of the type 'legacy'.</source>
        <translation type="unfinished">这是你的比特币接收地址。点击接收选项卡中"创建新的接收地址"按钮来创建新的地址。
签名只能使用"传统"类型的地址。</translation>
    </message>
    <message>
        <source>&Copy Address</source>
        <translation type="unfinished">复制地址</translation>
    </message>
    <message>
        <source>Copy &Label</source>
        <translation type="unfinished">复制标签</translation>
    </message>
    <message>
        <source>&Edit</source>
        <translation type="unfinished">编辑</translation>
    </message>
    <message>
        <source>Export Address List</source>
        <translation type="unfinished">导出地址列表</translation>
    </message>
    <message>
        <source>There was an error trying to save the address list to %1. Please try again.</source>
        <extracomment>An error message. %1 is a stand-in argument for the name of the file we attempted to save to.</extracomment>
        <translation type="unfinished">保存地址列表至%1时发生错误,请重试。</translation>
    </message>
    <message>
        <source>Exporting Failed</source>
        <translation type="unfinished">导出失败</translation>
    </message>
</context>
<context>
    <name>AddressTableModel</name>
    <message>
        <source>Label</source>
        <translation type="unfinished">标签</translation>
    </message>
    <message>
        <source>Address</source>
        <translation type="unfinished">地址</translation>
    </message>
    <message>
        <source>(no label)</source>
        <translation type="unfinished">(无标签)</translation>
    </message>
</context>
<context>
    <name>AskPassphraseDialog</name>
    <message>
        <source>Passphrase Dialog</source>
        <translation>密码对话框</translation>
    </message>
    <message>
        <source>Enter passphrase</source>
        <translation>输入密码</translation>
    </message>
    <message>
        <source>New passphrase</source>
        <translation>新密码</translation>
    </message>
    <message>
        <source>Repeat new passphrase</source>
        <translation>重复输入新密码</translation>
    </message>
    <message>
        <source>Show passphrase</source>
        <translation type="unfinished">显示密码</translation>
    </message>
    <message>
        <source>Encrypt wallet</source>
        <translation type="unfinished">加密钱包</translation>
    </message>
    <message>
        <source>This operation needs your wallet passphrase to unlock the wallet.</source>
        <translation type="unfinished">此操作需要您的钱包密码用来解锁钱包。</translation>
    </message>
    <message>
        <source>Unlock wallet</source>
        <translation type="unfinished">解锁钱包</translation>
    </message>
    </context>
<context>
    <name>QObject</name>
    <message numerus="yes">
        <source>%n second(s)</source>
        <translation>
            <numerusform />
        </translation>
    </message>
    <message numerus="yes">
        <source>%n minute(s)</source>
        <translation>
            <numerusform />
        </translation>
    </message>
    <message numerus="yes">
        <source>%n hour(s)</source>
        <translation type="unfinished">
            <numerusform />
        </translation>
    </message>
    <message numerus="yes">
        <source>%n day(s)</source>
        <translation type="unfinished">
            <numerusform />
        </translation>
    </message>
    <message numerus="yes">
        <source>%n week(s)</source>
        <translation type="unfinished">
            <numerusform />
        </translation>
    </message>
    <message numerus="yes">
        <source>%n year(s)</source>
        <translation type="unfinished">
            <numerusform />
        </translation>
    </message>
    </context>
<context>
    <name>QtumGUI</name>
    <message numerus="yes">
        <source>Processed %n block(s) of transaction history.</source>
        <translation>
            <numerusform />
        </translation>
    </message>
    <message numerus="yes">
        <source>%n active connection(s) to Qtum network.</source>
        <extracomment>A substring of the tooltip.</extracomment>
        <translation type="unfinished">
            <numerusform />
        </translation>
    </message>
    </context>
<context>
    <name>CoinControlDialog</name>
    <message>
        <source>(no label)</source>
        <translation type="unfinished">(无标签)</translation>
    </message>
    </context>
<context>
    <name>Intro</name>
    <message numerus="yes">
        <source>(sufficient to restore backups %n day(s) old)</source>
        <extracomment>Explanatory text on the capability of the current prune target.</extracomment>
        <translation type="unfinished">
            <numerusform />
        </translation>
    </message>
    </context>
<context>
    <name>PeerTableModel</name>
    <message>
        <source>Address</source>
        <extracomment>Title of Peers Table column which contains the IP/Onion/I2P address of the connected peer.</extracomment>
        <translation type="unfinished">地址</translation>
    </message>
    </context>
<context>
    <name>RecentRequestsTableModel</name>
    <message>
        <source>Label</source>
        <translation type="unfinished">标签</translation>
    </message>
    <message>
        <source>(no label)</source>
        <translation type="unfinished">(无标签)</translation>
    </message>
    </context>
<context>
    <name>SendCoinsDialog</name>
    <message numerus="yes">
        <source>Estimated to begin confirmation within %n block(s).</source>
        <translation>
            <numerusform />
        </translation>
    </message>
    <message>
        <source>(no label)</source>
        <translation type="unfinished">(无标签)</translation>
    </message>
</context>
<context>
    <name>TransactionDesc</name>
    <message numerus="yes">
        <source>Open for %n more block(s)</source>
        <translation>
            <numerusform />
        </translation>
    </message>
    <message numerus="yes">
        <source>matures in %n more block(s)</source>
        <translation>
            <numerusform />
        </translation>
    </message>
    </context>
<context>
    <name>TransactionTableModel</name>
    <message>
        <source>Label</source>
        <translation type="unfinished">标签</translation>
    </message>
    <message numerus="yes">
        <source>Open for %n more block(s)</source>
        <translation>
            <numerusform />
        </translation>
    </message>
    <message>
        <source>(no label)</source>
        <translation type="unfinished">(无标签)</translation>
    </message>
    </context>
<context>
    <name>TransactionView</name>
    <message>
        <source>Label</source>
        <translation type="unfinished">标签</translation>
    </message>
    <message>
        <source>Address</source>
        <translation type="unfinished">地址</translation>
    </message>
    <message>
        <source>Exporting Failed</source>
        <translation type="unfinished">导出失败</translation>
    </message>
    </context>
<context>
    <name>WalletView</name>
    <message>
        <source>&Export</source>
        <translation type="unfinished">导出</translation>
    </message>
    <message>
        <source>Export the data in the current tab to a file</source>
        <translation type="unfinished">导出当前数据到文件</translation>
    </message>
    </context>
</TS>


text:
mkdir -p /home/danlyke/websites/flutterby.net/public_html_new/wiki/
rsync -avz danlyke@www.flutterby.net:websites/flutterby.net/public_html_static/files ~/websites/flutterby.net/public_html_new/
rsync -avz danlyke@www.flutterby.net:/home/danlyke/websites/flutterby.net/mediawiki/images /home/danlyke/websites/flutterby.net/public_html_new/wiki/
dropdb flutterbynet
createdb flutterbynet
ssh www.flutterby.net 'pg_dump flutterbynet' | psql flutterbynet


text:
/**
 * Styles for Multi-Screen.js
 * @author Ian de Vries <ian@ian-devries.com>
 * @license MIT License <http://opensource.org/licenses/MIT>
 */

.ms-container {
	position: fixed;
	z-index: 1;
	display: none;
}

.ms-default {
	position: absolute;
	z-index: 2;
	display: block;
}


text:
// Copyright (c) MOSA Project. Licensed under the New BSD License.

using Mosa.Compiler.MosaTypeSystem;
using System;

namespace Mosa.Compiler.Framework.CIL
{
	/* FIXME:
	 * - Schedule compilation of invocation target
	 * - Scheduling puts the target method on the jit or aot compilers work list
	 * - This allows the jit to run async ahead of time in the same process
	 * - This may not turn the jit into a full aot, but is used to prepare MethodCompilers and jit stubs
	 *   for invoked methods.
	 */

	/// <summary>
	/// Base class for instructions, which invoke other functions.
	/// </summary>
	public abstract class InvokeInstruction : BaseCILInstruction
	{
		#region Types

		/// <summary>
		/// Specifies a set of flags used to control invocation target metadata decoding.
		/// </summary>
		[Flags]
		protected enum InvokeSupportFlags
		{
			/// <summary>
			/// Specifies that the invoke instruction supports member references.
			/// </summary>
			MemberRef = 1,

			/// <summary>
			/// Specifies that the invoke instruction supports member definitions.
			/// </summary>
			MethodDef = 2,

			/// <summary>
			/// Specifies that the invoke instruction supports member specifications.
			/// </summary>
			MethodSpec = 4,

			/// <summary>
			/// Specifies that the invoke instruction supports call site invocations.
			/// </summary>
			CallSite = 8,

			/// <summary>
			/// Specifies support for all method invocation targets.
			/// </summary>
			All = MemberRef | MethodDef | MethodSpec | CallSite
		}

		#endregion Types

		#region Construction

		/// <summary>
		/// Initializes a new instance of the <see cref="InvokeInstruction"/> class.
		/// </summary>
		/// <param name="opcode">The opcode.</param>
		public InvokeInstruction(OpCode opcode)
			: base(opcode, 0)
		{
		}

		#endregion Construction

		#region Properties

		/// <summary>
		/// Determines flow behavior of this instruction.
		/// </summary>
		/// <value></value>
		/// <remarks>
		/// Knowledge of control flow is required for correct basic block
		/// building. Any instruction that alters the control flow must override
		/// this property and correctly identify its control flow modifications.
		/// </remarks>
		public override FlowControl FlowControl { get { return FlowControl.Call; } }

		/// <summary>
		/// Gets the supported immediate metadata tokens in the instruction.
		/// </summary>
		protected abstract InvokeSupportFlags InvokeSupport { get; }

		#endregion Properties

		#region Methods

		/// <summary>
		/// Decodes the specified instruction.
		/// </summary>
		/// <param name="ctx">The context.</param>
		/// <param name="decoder">The instruction decoder, which holds the code stream.</param>
		public override void Decode(InstructionNode ctx, IInstructionDecoder decoder)
		{
			DecodeInvocationTarget(ctx, decoder, InvokeSupport);
		}

		/// <summary>
		/// Validates the instruction operands and creates a matching variable for the result.
		/// </summary>
		/// <param name="ctx">The context.</param>
		/// <param name="compiler">The compiler.</param>
		public override void Resolve(Context ctx, BaseMethodCompiler compiler)
		{
			base.Resolve(ctx, compiler);
		}

		/// <summary>
		/// Decodes the invocation target.
		/// </summary>
		/// <param name="ctx">The context.</param>
		/// <param name="decoder">The IL decoder, which provides decoding functionality.</param>
		/// <param name="flags">Flags, which control the</param>
		/// <returns></returns>
		protected static MosaMethod DecodeInvocationTarget(InstructionNode ctx, IInstructionDecoder decoder, InvokeSupportFlags flags)
		{
			var method = (MosaMethod)decoder.Instruction.Operand;

			decoder.Compiler.Scheduler.TrackMethodInvoked(method);

			SetInvokeTarget(ctx, decoder.Compiler, method);

			return method;
		}

		/// <summary>
		/// Sets the invoke target.
		/// </summary>
		/// <param name="context">The context.</param>
		/// <param name="compiler">The compiler.</param>
		/// <param name="method">The method.</param>
		private static void SetInvokeTarget(InstructionNode context, BaseMethodCompiler compiler, MosaMethod method)
		{
			context.InvokeMethod = method;

			// Fix the parameter list
			int paramCount = method.Signature.Parameters.Count;

			if (method.HasThis && !method.HasExplicitThis)
				paramCount++;

			// Setup operands for parameters and the return value
			if (!method.Signature.ReturnType.IsVoid)
			{
				context.ResultCount = 1;
				context.Result = compiler.CreateVirtualRegister(method.Signature.ReturnType.GetStackType());
			}
			else
			{
				context.ResultCount = 0;
			}

			context.OperandCount = (byte)paramCount;
		}

		#endregion Methods
	}
}


text:
module FastlaneCore
  class UI
    class << self
      def current
        @current ||= Shell.new
      end
    end

    def self.method_missing(method_sym, *args, &_block)
      # not using `responds` because we don't care about methods like .to_s and so on
      interface_methods = Interface.instance_methods - Object.instance_methods
      UI.user_error!("Unknown method '#{method_sym}', supported #{interface_methods}") unless interface_methods.include?(method_sym)

      self.current.send(method_sym, *args)
    end
  end
end

require 'fastlane_core/ui/interface'

# Import all available implementations
Dir[File.expand_path('implementations/*.rb', File.dirname(__FILE__))].each do |file|
  require file
end

require 'fastlane_core/ui/disable_colors' if FastlaneCore::Helper.colors_disabled?


text:
package ru.eustas.zopfli;

import ru.eustas.zopfli.Options.BlockSplitting;
import ru.eustas.zopfli.Options.OutputFormat;

import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * Zopfli compression command line interface.
 */
class Main {

  public static void main(String[] args) {
    OutputFormat outputType = OutputFormat.GZIP;
    BlockSplitting blockSplitting = BlockSplitting.FIRST;
    int numIterations = 15;

    boolean outputToStdOut = false;

    for (int i = 0; i < args.length; ++i) {
      String arg = args[i];
      if ("-c".equals(arg)) {
        outputToStdOut = true;
      } else if ("--deflate".equals(arg)) {
        outputType = OutputFormat.DEFLATE;
      } else if ("--zlib".equals(arg)) {
        outputType = OutputFormat.ZLIB;
      } else if ("--gzip".equals(arg)) {
        outputType = OutputFormat.GZIP;
      } else if ("--splitlast".equals(arg)) {
        blockSplitting = BlockSplitting.LAST;
      } else if (arg.startsWith("--i")) {
        try {
          numIterations = Integer.parseInt(arg.substring(3));
        } catch (NumberFormatException e) {
          System.err.println("Can't parse number of iterations option.");
          return;
        }
      } else if ("-h".equals(arg)) {
        printHelp();
        return;
      }
    }

    if (numIterations < 1) {
      System.err.println("Error: must have 1 or more iterations");
    }

    Zopfli compressor = new Zopfli(8 << 20);
    byte[] buffer = new byte[65536];
    Options options = new Options(outputType, blockSplitting, numIterations);

    String fileName = null;
    for (int i = 0; i < args.length; ++i) {
      String arg = args[i];
      if (arg.charAt(0) == '-') {
        continue;
      }
      fileName = arg;
      String outFileName;
      if (outputToStdOut) {
        outFileName = null;
      } else if (outputType == OutputFormat.GZIP) {
        outFileName = fileName + ".gz";
      } else if (outputType == OutputFormat.ZLIB) {
        outFileName = fileName + ".zlib";
      } else {
        outFileName = fileName + ".deflate";
      }
      try {
        compressFile(compressor, options, fileName, outFileName, buffer);
      } catch (IOException ex) {
        ex.printStackTrace();
        return;
      }
    }

    if (fileName == null) {
      System.err.println(""
          + "Please provide filename\n"
          + "For help, try -h");
    }
  }

  private static void silentlyClose(Closeable stream) {
    try {
      stream.close();
    } catch (IOException ex) {
      // We don't care.
    }
  }

  private static byte[] readFile(String fileName, byte[] buffer) throws IOException {
    FileInputStream inputStream = new FileInputStream(fileName);
    try {
      ByteArrayOutputStream baos = new ByteArrayOutputStream(inputStream.available());
      baos.reset();
      int len;
      while ((len = inputStream.read(buffer)) != -1) {
        baos.write(buffer, 0, len);
      }
      return baos.toByteArray();
    } finally {
      silentlyClose(inputStream);
    }
  }

  /**
   * Compress single file.
   *
   * @param options Options.
   * @param fileName Input file name.
   * @param outFileName Output file name; {@code null} to output to stdout.
   */
  private static void compressFile(Zopfli compressor, Options options,
      String fileName, String outFileName, byte[] buffer) throws IOException {
    byte[] input = readFile(fileName, buffer);
    if (input == null) {
      return;
    }

    OutputStream output;
    if (outFileName != null) {
      output = new FileOutputStream(outFileName);
    } else {
      output = System.out;
    }

    try {
      compressor.compress(options, input, output);
    } finally {
      if (outFileName != null) {
        silentlyClose(output);
      }
    }
  }

  private static void printHelp() {
    System.err.println(""
        + "Usage: zopfli [OPTION]... FILE\n"
        + "  -h    gives this help\n"
        + "  -c    write the result on standard output, instead of disk"
        + " filename + '.gz'\n"
        + "  --i#  perform # iterations (default 15). More gives"
        + " more compression but is slower."
        + " Examples: --i10, --i50, --i1000\n"
        + "  --gzip        output to gzip format (default)\n"
        + "  --zlib        output to zlib format instead of gzip\n"
        + "  --deflate     output to deflate format instead of gzip\n"
        + "  --splitlast   do block splitting last instead of first");
  }
}