text:
test = {
  'name': 'shopping-cart',
  'points': 0,
  'suites': [
    {
      'cases': [
        {
          'code': r"""
          sqlite> SELECT * FROM shopping_cart LIMIT 15;
          CAKE!|0
          cornbread, cornbread, cornbread, cornbread, cornbread|0
          cranberries, cranberries, cranberries, cornbread, cornbread, pumpkin pie|0
          cranberries, cranberries, cranberries, cranberries, cornbread, tofurky|0
          cranberries, cranberries, cranberries, cranberries, cranberries, potatoes, pumpkin pie|0
          cranberries, cranberries, cranberries, cranberries, potatoes, potatoes, cornbread|0
          cranberries, cranberries, potatoes, cornbread, cornbread, cornbread|0
          potatoes, potatoes, potatoes, potatoes, potatoes, potatoes|0
          potatoes, potatoes, potatoes, potatoes, tofurky|0
          potatoes, potatoes, potatoes, pumpkin pie, pumpkin pie|0
          potatoes, potatoes, potatoes, turkey|0
          potatoes, potatoes, tofurky, tofurky|0
          potatoes, pumpkin pie, pumpkin pie, tofurky|0
          potatoes, tofurky, turkey|0
          pumpkin pie, pumpkin pie, pumpkin pie, pumpkin pie|0
          """,
          'hidden': False,
          'locked': False
        },
        {
          'code': r"""
          sqlite> SELECT * FROM shopping_cart;
          CAKE!|0
          cornbread, cornbread, cornbread, cornbread, cornbread|0
          cranberries, cranberries, cranberries, cornbread, cornbread, pumpkin pie|0
          cranberries, cranberries, cranberries, cranberries, cornbread, tofurky|0
          cranberries, cranberries, cranberries, cranberries, cranberries, potatoes, pumpkin pie|0
          cranberries, cranberries, cranberries, cranberries, potatoes, potatoes, cornbread|0
          cranberries, cranberries, potatoes, cornbread, cornbread, cornbread|0
          potatoes, potatoes, potatoes, potatoes, potatoes, potatoes|0
          potatoes, potatoes, potatoes, potatoes, tofurky|0
          potatoes, potatoes, potatoes, pumpkin pie, pumpkin pie|0
          potatoes, potatoes, potatoes, turkey|0
          potatoes, potatoes, tofurky, tofurky|0
          potatoes, pumpkin pie, pumpkin pie, tofurky|0
          potatoes, tofurky, turkey|0
          pumpkin pie, pumpkin pie, pumpkin pie, pumpkin pie|0
          pumpkin pie, pumpkin pie, turkey|0
          tofurky, tofurky, tofurky|0
          turkey, turkey|0
          cornbread, cornbread, pumpkin pie, tofurky|1
          cranberries, cornbread, tofurky, tofurky|1
          cranberries, cranberries, cranberries, cranberries, cranberries, cornbread, cornbread|1
          cranberries, cranberries, cranberries, cranberries, cranberries, cranberries, cranberries, potatoes|1
          cranberries, cranberries, potatoes, potatoes, potatoes, pumpkin pie|1
          cranberries, cranberries, potatoes, pumpkin pie, tofurky|1
          cranberries, cranberries, pumpkin pie, pumpkin pie, pumpkin pie|1
          cranberries, cranberries, pumpkin pie, turkey|1
          cranberries, potatoes, cornbread, pumpkin pie, pumpkin pie|1
          cranberries, potatoes, cornbread, turkey|1
          cranberries, potatoes, potatoes, cornbread, tofurky|1
          cranberries, potatoes, potatoes, potatoes, potatoes, cornbread|1
          potatoes, potatoes, cornbread, cornbread, pumpkin pie|1
          cranberries, cornbread, cornbread, cornbread, pumpkin pie|2
          cranberries, cranberries, cornbread, cornbread, tofurky|2
          cranberries, cranberries, cranberries, cranberries, potatoes, potatoes, potatoes|2
          cranberries, cranberries, cranberries, cranberries, potatoes, tofurky|2
          cranberries, cranberries, cranberries, cranberries, pumpkin pie, pumpkin pie|2
          cranberries, cranberries, cranberries, cranberries, turkey|2
          cranberries, cranberries, cranberries, potatoes, cornbread, pumpkin pie|2
          cranberries, cranberries, potatoes, potatoes, cornbread, cornbread|2
          potatoes, cornbread, cornbread, cornbread, cornbread|2
          cornbread, pumpkin pie, pumpkin pie, pumpkin pie|3
          cornbread, pumpkin pie, turkey|3
          cranberries, cranberries, cranberries, cornbread, cornbread, cornbread|3
          cranberries, cranberries, cranberries, cranberries, cranberries, cranberries, pumpkin pie|3
          cranberries, cranberries, cranberries, cranberries, cranberries, potatoes, cornbread|3
          cranberries, potatoes, potatoes, potatoes, potatoes, potatoes|3
          cranberries, potatoes, potatoes, potatoes, tofurky|3
          cranberries, potatoes, potatoes, pumpkin pie, pumpkin pie|3
          cranberries, potatoes, potatoes, turkey|3
          cranberries, potatoes, tofurky, tofurky|3
          cranberries, pumpkin pie, pumpkin pie, tofurky|3
          cranberries, tofurky, turkey|3
          potatoes, cornbread, pumpkin pie, tofurky|3
          potatoes, potatoes, potatoes, cornbread, pumpkin pie|3
          cornbread, cornbread, cornbread, tofurky|4
          cranberries, cranberries, cornbread, pumpkin pie, pumpkin pie|4
          cranberries, cranberries, cornbread, turkey|4
          cranberries, cranberries, cranberries, cranberries, cranberries, cranberries, cranberries, cranberries|4
          cranberries, cranberries, cranberries, potatoes, potatoes, pumpkin pie|4
          cranberries, cranberries, cranberries, pumpkin pie, tofurky|4
          cranberries, cranberries, potatoes, cornbread, tofurky|4
          cranberries, cranberries, potatoes, potatoes, potatoes, cornbread|4
          cranberries, potatoes, cornbread, cornbread, pumpkin pie|4
          potatoes, potatoes, cornbread, cornbread, cornbread|4
          cranberries, cornbread, cornbread, cornbread, cornbread|5
          cranberries, cranberries, cranberries, cranberries, cornbread, pumpkin pie|5
          cranberries, cranberries, cranberries, cranberries, cranberries, potatoes, potatoes|5
          cranberries, cranberries, cranberries, cranberries, cranberries, tofurky|5
          cranberries, cranberries, cranberries, potatoes, cornbread, cornbread|5
          potatoes, potatoes, potatoes, potatoes, pumpkin pie|5
          potatoes, potatoes, pumpkin pie, tofurky|5
          potatoes, pumpkin pie, pumpkin pie, pumpkin pie|5
          potatoes, pumpkin pie, turkey|5
          pumpkin pie, tofurky, tofurky|5
          cornbread, cornbread, pumpkin pie, pumpkin pie|6
          cornbread, cornbread, turkey|6
          cranberries, cornbread, pumpkin pie, tofurky|6
          cranberries, cranberries, cranberries, cranberries, cranberries, cranberries, cornbread|6
          cranberries, cranberries, potatoes, potatoes, potatoes, potatoes|6
          cranberries, cranberries, potatoes, potatoes, tofurky|6
          cranberries, cranberries, potatoes, pumpkin pie, pumpkin pie|6
          cranberries, cranberries, potatoes, turkey|6
          cranberries, cranberries, tofurky, tofurky|6
          cranberries, potatoes, potatoes, cornbread, pumpkin pie|6
          potatoes, cornbread, cornbread, tofurky|6
          potatoes, potatoes, potatoes, cornbread, cornbread|6
          cranberries, cranberries, cornbread, cornbread, pumpkin pie|7
          cranberries, cranberries, cranberries, cornbread, tofurky|7
          cranberries, cranberries, cranberries, cranberries, potatoes, pumpkin pie|7
          cranberries, cranberries, cranberries, potatoes, potatoes, cornbread|7
          cranberries, potatoes, cornbread, cornbread, cornbread|7
          cornbread, tofurky, tofurky|8
          cranberries, cranberries, cranberries, cranberries, cornbread, cornbread|8
          cranberries, cranberries, cranberries, cranberries, cranberries, cranberries, potatoes|8
          cranberries, potatoes, potatoes, potatoes, pumpkin pie|8
          cranberries, potatoes, pumpkin pie, tofurky|8
          cranberries, pumpkin pie, pumpkin pie, pumpkin pie|8
          cranberries, pumpkin pie, turkey|8
          potatoes, cornbread, pumpkin pie, pumpkin pie|8
          potatoes, cornbread, turkey|8
          potatoes, potatoes, cornbread, tofurky|8
          potatoes, potatoes, potatoes, potatoes, cornbread|8
          cornbread, cornbread, cornbread, pumpkin pie|9
          cranberries, cornbread, cornbread, tofurky|9
          cranberries, cranberries, cranberries, potatoes, potatoes, potatoes|9
          cranberries, cranberries, cranberries, potatoes, tofurky|9
          cranberries, cranberries, cranberries, pumpkin pie, pumpkin pie|9
          cranberries, cranberries, cranberries, turkey|9
          cranberries, cranberries, potatoes, cornbread, pumpkin pie|9
          cranberries, potatoes, potatoes, cornbread, cornbread|9
          cranberries, cranberries, cornbread, cornbread, cornbread|10
          cranberries, cranberries, cranberries, cranberries, cranberries, pumpkin pie|10
          cranberries, cranberries, cranberries, cranberries, potatoes, cornbread|10
          potatoes, potatoes, potatoes, potatoes, potatoes|10
          potatoes, potatoes, potatoes, tofurky|10
          potatoes, potatoes, pumpkin pie, pumpkin pie|10
          potatoes, potatoes, turkey|10
          potatoes, tofurky, tofurky|10
          pumpkin pie, pumpkin pie, tofurky|10
          tofurky, turkey|10
          cranberries, cornbread, pumpkin pie, pumpkin pie|11
          cranberries, cornbread, turkey|11
          cranberries, cranberries, cranberries, cranberries, cranberries, cranberries, cranberries|11
          cranberries, cranberries, potatoes, potatoes, pumpkin pie|11
          cranberries, cranberries, pumpkin pie, tofurky|11
          cranberries, potatoes, cornbread, tofurky|11
          cranberries, potatoes, potatoes, potatoes, cornbread|11
          potatoes, cornbread, cornbread, pumpkin pie|11
          cornbread, cornbread, cornbread, cornbread|12
          cranberries, cranberries, cranberries, cornbread, pumpkin pie|12
          cranberries, cranberries, cranberries, cranberries, potatoes, potatoes|12
          cranberries, cranberries, cranberries, cranberries, tofurky|12
          cranberries, cranberries, potatoes, cornbread, cornbread|12
          cornbread, pumpkin pie, tofurky|13
          cranberries, cranberries, cranberries, cranberries, cranberries, cornbread|13
          cranberries, potatoes, potatoes, potatoes, potatoes|13
          cranberries, potatoes, potatoes, tofurky|13
          cranberries, potatoes, pumpkin pie, pumpkin pie|13
          cranberries, potatoes, turkey|13
          cranberries, tofurky, tofurky|13
          potatoes, potatoes, cornbread, pumpkin pie|13
          cranberries, cornbread, cornbread, pumpkin pie|14
          cranberries, cranberries, cornbread, tofurky|14
          cranberries, cranberries, cranberries, potatoes, pumpkin pie|14
          cranberries, cranberries, potatoes, potatoes, cornbread|14
          potatoes, cornbread, cornbread, cornbread|14
          cranberries, cranberries, cranberries, cornbread, cornbread|15
          cranberries, cranberries, cranberries, cranberries, cranberries, potatoes|15
          potatoes, potatoes, potatoes, pumpkin pie|15
          potatoes, pumpkin pie, tofurky|15
          pumpkin pie, pumpkin pie, pumpkin pie|15
          pumpkin pie, turkey|15
          cornbread, cornbread, tofurky|16
          cranberries, cranberries, potatoes, potatoes, potatoes|16
          cranberries, cranberries, potatoes, tofurky|16
          cranberries, cranberries, pumpkin pie, pumpkin pie|16
          cranberries, cranberries, turkey|16
          cranberries, potatoes, cornbread, pumpkin pie|16
          potatoes, potatoes, cornbread, cornbread|16
          cranberries, cornbread, cornbread, cornbread|17
          cranberries, cranberries, cranberries, cranberries, pumpkin pie|17
          cranberries, cranberries, cranberries, potatoes, cornbread|17
          cornbread, pumpkin pie, pumpkin pie|18
          cornbread, turkey|18
          cranberries, cranberries, cranberries, cranberries, cranberries, cranberries|18
          cranberries, potatoes, potatoes, pumpkin pie|18
          cranberries, pumpkin pie, tofurky|18
          potatoes, cornbread, tofurky|18
          potatoes, potatoes, potatoes, cornbread|18
          cranberries, cranberries, cornbread, pumpkin pie|19
          cranberries, cranberries, cranberries, potatoes, potatoes|19
          cranberries, cranberries, cranberries, tofurky|19
          cranberries, potatoes, cornbread, cornbread|19
          cranberries, cranberries, cranberries, cranberries, cornbread|20
          potatoes, potatoes, potatoes, potatoes|20
          potatoes, potatoes, tofurky|20
          potatoes, pumpkin pie, pumpkin pie|20
          potatoes, turkey|20
          tofurky, tofurky|20
          cornbread, cornbread, pumpkin pie|21
          cranberries, cornbread, tofurky|21
          cranberries, cranberries, potatoes, pumpkin pie|21
          cranberries, potatoes, potatoes, cornbread|21
          cranberries, cranberries, cornbread, cornbread|22
          cranberries, cranberries, cranberries, cranberries, potatoes|22
          cranberries, potatoes, potatoes, potatoes|23
          cranberries, potatoes, tofurky|23
          cranberries, pumpkin pie, pumpkin pie|23
          cranberries, turkey|23
          potatoes, cornbread, pumpkin pie|23
          cornbread, cornbread, cornbread|24
          cranberries, cranberries, cranberries, pumpkin pie|24
          cranberries, cranberries, potatoes, cornbread|24
          cranberries, cranberries, cranberries, cranberries, cranberries|25
          potatoes, potatoes, pumpkin pie|25
          pumpkin pie, tofurky|25
          cranberries, cornbread, pumpkin pie|26
          cranberries, cranberries, potatoes, potatoes|26
          cranberries, cranberries, tofurky|26
          potatoes, cornbread, cornbread|26
          cranberries, cranberries, cranberries, cornbread|27
          cornbread, tofurky|28
          cranberries, potatoes, pumpkin pie|28
          potatoes, potatoes, cornbread|28
          cranberries, cornbread, cornbread|29
          cranberries, cranberries, cranberries, potatoes|29
          potatoes, potatoes, potatoes|30
          potatoes, tofurky|30
          pumpkin pie, pumpkin pie|30
          turkey|30
          cranberries, cranberries, pumpkin pie|31
          cranberries, potatoes, cornbread|31
          cranberries, cranberries, cranberries, cranberries|32
          cornbread, pumpkin pie|33
          cranberries, potatoes, potatoes|33
          cranberries, tofurky|33
          cranberries, cranberries, cornbread|34
          potatoes, pumpkin pie|35
          cornbread, cornbread|36
          cranberries, cranberries, potatoes|36
          cranberries, pumpkin pie|38
          potatoes, cornbread|38
          cranberries, cranberries, cranberries|39
          potatoes, potatoes|40
          tofurky|40
          cranberries, cornbread|41
          cranberries, potatoes|43
          pumpkin pie|45
          cranberries, cranberries|46
          cornbread|48
          potatoes|50
          cranberries|53
          """,
          'hidden': False,
          'locked': False
        }
      ],
      'ordered': True,
      'scored': True,
      'setup': r"""
      sqlite> .read lab13.sql
      """,
      'teardown': '',
      'type': 'sqlite'
    }
  ]
}


text:
show_active_pseudo_terminals
============================

Shows pts sessions that have been active in the last $maxtime minutes, call from your bashrc

Example usage (show users active in the last 5 minutes excuding the terminal calling this script):

    tty=$(tty); w -h | awk -vtty=${tty#/*/} -vmaxtime=5 -f getusers -

redpajama_set_name: RedPajamaGithub


text:
<?php

require_once 'actionsbase.class.php';
require_once 'urltranslator.class.php';
require_once 'helpers.inc.php';

class Controller
{
    private static $MVC_CONTROLLER = null;
    private $options;

    private $actions;

    /*
     * Wybrany modul
     */
    private $module_name;

    /*
     * Wybrana akcja
     */
    private $action_name;

    /*
     * Lista wszystkich poprawnych modulow
     */
    private $module_names;

    /*
     * Lista wszystkich poprawnych akcji
     */
    private $action_names;

    /*
     * Wynik przetwarzania szablonu przed translacjami wyjściowymi
     */
    protected $output;

    /*
     * Klasa konwertująca URL-e przyjazne <==> wewnętrzne
     * Konwersja dwukierunkowa
     */
    private $urlTranslator;

    private $outputStringTranslations;

    public function setOptions($options)
    {
        $this->options = array();
        $this->options['viewClass'] = 'PHPView';
        $this->options['outputTranslations'] = true;

        if (!is_null($options)) {

            if (isset($options['viewClass'])) {
                $this->options['viewClass'] = $options['viewClass'];
            }

            if (isset($options['outputTranslations'])) {
                $this->options['outputTranslations'] = $options['outputTranslations'];
            }

        }
    }

    public function getOption($name)
    {
        return $this->options[$name];
    }

    public function __construct($options = null)
    {
        $this->setOptions($options);

        $this->urlTranslator = new URLTranslator($options);
        $this->outputStringTranslations = array(
            'src' => array(),
            'dest' => array(),
        );

        $this->resolveAllowedModules();
        $this->resolveCurrentModule();

        require_once 'modules/' . $this->module_name . '/actions.class.php';
        $this->actions = new Actions($this, $this->options['viewClass']);

        $this->resolveAllowedActions();
        $this->resolveCurrentAction();

        self::$MVC_CONTROLLER = $this;
    }

    public function dispatch()
    {
        $this->preActions();
        $this->executeCurrentAction();
        $this->postActions();

        if ($this->actions->hasLayout()) {
            $this->output = $this->actions->display();
            $this->outputTranslations();
            echo $this->output;
        }
    }

    private function outputTranslations()
    {
        if ($this->options['outputTranslations']) {

            $this->output = preg_replace(
                $this->urlTranslator->getOutputRoutes(),
                $this->urlTranslator->getOutputTranslatedRoutes(),
                $this->output
            );

            $this->addOutputStringTranslations('###PATH_PREFIX###', $this->getPathPrefix());

            $this->output = str_replace(
                $this->outputStringTranslations['src'],
                $this->outputStringTranslations['dest'],
                $this->output
            );

            $this->customOutputTranslations();

        }
    }

    public function addOutputStringTranslations($src, $dest)
    {
        $this->outputStringTranslations['src'][] =   $src;
        $this->outputStringTranslations['dest'][] =  $dest;
    }

    public function preActions()
    {
    }

    public function postActions()
    {

    }

    public function customOutputTranslations()
    {

    }

    private function resolveAllowedModules()
    {
        $this->module_names = glob('../scripts/modules/*');
        $tmp = count($this->module_names);
        for ($i = 0; $i < $tmp; $i++) {
            $this->module_names[$i] =
            str_replace('../scripts/modules/', '', $this->module_names[$i]);
        }
    }

    private function resolveAllowedActions()
    {
        $methods = get_class_methods('Actions');
        $this->action_names = array();
        foreach ($methods as $method) {
            if (preg_match('/^execute_([a-zA-Z0-9_]+)$/', $method, $m)) {
                $this->action_names[] = $m[1];
            }
        }
    }

    private function resolveCurrentModule()
    {
        $this->module_name = 'main';
        if (
            isset($_GET['module']) &&
            in_array($_GET['module'], $this->module_names)
        ) {
            $this->module_name = $_GET['module'];
        };
    }

    private function resolveCurrentAction()
    {
        if (
            isset($_GET['action']) &&
            in_array($_GET['action'], $this->action_names)
        ) {
            $this->action_name = $_GET['action'];
        } else {
            $this->module_name = 'main';
            $this->action_name = '404';
        }
    }

    private function executeCurrentAction()
    {
        $method_name = 'execute_' . $this->action_name;
        $this->actions->$method_name();
    }

    public function getModule()
    {
        return $this->module_name;
    }

    public function setModule($module)
    {
        $this->module_name = $module;
    }

    public function getAction()
    {
        return $this->action_name;
    }

    public function setAction($action)
    {
        $this->action_name = $action;
    }

    public function getPathPrefix()
    {
        return $this->urlTranslator->getPathPrefix();
    }

	public function getUrl($u, $type = null)
	{
        return $this->urlTranslator->getUrl($u, $type);
	}

	public static function autoload($className)
	{
        require_once $className . '.class.php';
	}

	public function set($name, $value)
	{
	    $this->actions->set($name, $value);
	}

	public static function getInstance()
	{
	    return self::$MVC_CONTROLLER;
	}

}

spl_autoload_register(array('Controller', 'autoload'));


text:
package com.google.android.exoplayer2.ext.mediaplayer;

import android.content.Context;
import android.os.Handler;

import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.audio.AudioCapabilities;
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
import com.google.android.exoplayer2.audio.MediaCodecAudioRenderer;
import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
import com.google.android.exoplayer2.metadata.MetadataDecoderFactory;
import com.google.android.exoplayer2.metadata.MetadataRenderer;
import com.google.android.exoplayer2.text.TextRenderer;
import com.google.android.exoplayer2.video.MediaCodecVideoRenderer;
import com.google.android.exoplayer2.video.VideoRendererEventListener;

import java.util.ArrayList;
import java.util.List;

public class DefaultRendererProvider implements RendererProvider {
    protected Context context;
    protected Handler handler;

    protected TextRenderer.Output captionListener;
    protected MetadataRenderer.Output metadataListener;
    protected AudioRendererEventListener audioRendererEventListener;
    protected VideoRendererEventListener videoRendererEventListener;

    protected DrmSessionManager<FrameworkMediaCrypto> drmSessionManager;
    protected int droppedFrameNotificationAmount = 50;
    protected int allowedJoiningTimeMs = 5000;

    public DefaultRendererProvider(Context context, Handler handler, TextRenderer.Output captionListener, MetadataRenderer.Output metadataListener,
                                   AudioRendererEventListener audioRendererEventListener, VideoRendererEventListener videoRendererEventListener) {
        this.context = context;
        this.handler = handler;
        this.captionListener = captionListener;
        this.metadataListener = metadataListener;
        this.audioRendererEventListener = audioRendererEventListener;
        this.videoRendererEventListener = videoRendererEventListener;
    }

    public void setDrmSessionManager(DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
        this.drmSessionManager = drmSessionManager;
    }

    public void setDroppedFrameNotificationAmount(int droppedFrameNotificationAmount) {
        this.droppedFrameNotificationAmount = droppedFrameNotificationAmount;
    }

    public void setAllowedVideoJoiningTimeMs(int videoJoiningTimeMs) {
        this.allowedJoiningTimeMs = videoJoiningTimeMs;
    }

    @Override
    public List<Renderer> generate() {
        List<Renderer> renderers = new ArrayList<>();

        renderers.addAll(buildAudioRenderers());
        renderers.addAll(buildVideoRenderers());
        renderers.addAll(buildCaptionRenderers());
        renderers.addAll(buildMetadataRenderers());

        return renderers;
    }

    protected List<Renderer> buildAudioRenderers() {
        List<Renderer> renderers = new ArrayList<>();

        renderers.add(new MediaCodecAudioRenderer(MediaCodecSelector.DEFAULT, drmSessionManager, true, handler, audioRendererEventListener, AudioCapabilities.getCapabilities(context)));

        return renderers;
    }

    protected List<Renderer> buildVideoRenderers() {
        List<Renderer> renderers = new ArrayList<>();

        renderers.add(new MediaCodecVideoRenderer(context, MediaCodecSelector.DEFAULT, allowedJoiningTimeMs, drmSessionManager, false, handler, videoRendererEventListener, droppedFrameNotificationAmount));

        return renderers;
    }

    protected List<Renderer> buildCaptionRenderers() {
        List<Renderer> renderers = new ArrayList<>();

        renderers.add(new TextRenderer(captionListener, handler.getLooper()));

        return renderers;
    }

    protected List<Renderer> buildMetadataRenderers() {
        List<Renderer> renderers = new ArrayList<>();

        renderers.add(new MetadataRenderer(metadataListener, handler.getLooper(), MetadataDecoderFactory.DEFAULT));

        return renderers;
    }
}


text:
/*	$NetBSD: history.c,v 1.46 2011/11/18 20:39:18 christos Exp $	*/

/*-
 * Copyright (c) 1992, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * This code is derived from software contributed to Berkeley by
 * Christos Zoulas of Cornell University.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#ifndef NARROWCHAR
#include "config.h"
#endif

#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)history.c	8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: history.c,v 1.46 2011/11/18 20:39:18 christos Exp $");
#endif
#endif /* not lint && not SCCSID */

/*
 * hist.c: TYPE(History) access functions
 */
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <vis.h>
#include <sys/stat.h>

static const char hist_cookie[] = "_HiStOrY_V2_\n";

#include "histedit.h"
#include "chartype.h"

typedef int (*history_gfun_t)(void *, TYPE(HistEvent) *);
typedef int (*history_efun_t)(void *, TYPE(HistEvent) *, const Char *);
typedef void (*history_vfun_t)(void *, TYPE(HistEvent) *);
typedef int (*history_sfun_t)(void *, TYPE(HistEvent) *, const int);

struct TYPE(history) {
	void *h_ref;		/* Argument for history fcns	 */
	int h_ent;		/* Last entry point for history	 */
	history_gfun_t h_first;	/* Get the first element	 */
	history_gfun_t h_next;	/* Get the next element		 */
	history_gfun_t h_last;	/* Get the last element		 */
	history_gfun_t h_prev;	/* Get the previous element	 */
	history_gfun_t h_curr;	/* Get the current element	 */
	history_sfun_t h_set;	/* Set the current element	 */
	history_sfun_t h_del;	/* Set the given element	 */
	history_vfun_t h_clear;	/* Clear the history list	 */
	history_efun_t h_enter;	/* Add an element		 */
	history_efun_t h_add;	/* Append to an element		 */
};

#define	HNEXT(h, ev)		(*(h)->h_next)((h)->h_ref, ev)
#define	HFIRST(h, ev)		(*(h)->h_first)((h)->h_ref, ev)
#define	HPREV(h, ev)		(*(h)->h_prev)((h)->h_ref, ev)
#define	HLAST(h, ev)		(*(h)->h_last)((h)->h_ref, ev)
#define	HCURR(h, ev)		(*(h)->h_curr)((h)->h_ref, ev)
#define	HSET(h, ev, n)		(*(h)->h_set)((h)->h_ref, ev, n)
#define	HCLEAR(h, ev)		(*(h)->h_clear)((h)->h_ref, ev)
#define	HENTER(h, ev, str)	(*(h)->h_enter)((h)->h_ref, ev, str)
#define	HADD(h, ev, str)	(*(h)->h_add)((h)->h_ref, ev, str)
#define	HDEL(h, ev, n)		(*(h)->h_del)((h)->h_ref, ev, n)

#define	h_strdup(a)	Strdup(a)
#define	h_malloc(a)	malloc(a)
#define	h_realloc(a, b)	realloc((a), (b))
#define	h_free(a)	free(a)

typedef struct {
    int		num;
    Char	*str;
} HistEventPrivate;

private int history_setsize(TYPE(History) *, TYPE(HistEvent) *, int);
private int history_getsize(TYPE(History) *, TYPE(HistEvent) *);
private int history_setunique(TYPE(History) *, TYPE(HistEvent) *, int);
private int history_getunique(TYPE(History) *, TYPE(HistEvent) *);
private int history_set_fun(TYPE(History) *, TYPE(History) *);
private int history_load(TYPE(History) *, const char *);
private int history_save(TYPE(History) *, const char *);
private int history_prev_event(TYPE(History) *, TYPE(HistEvent) *, int);
private int history_next_event(TYPE(History) *, TYPE(HistEvent) *, int);
private int history_next_string(TYPE(History) *, TYPE(HistEvent) *, const Char *);
private int history_prev_string(TYPE(History) *, TYPE(HistEvent) *, const Char *);

/***********************************************************************/

/*
 * Builtin- history implementation
 */
typedef struct hentry_t {
	TYPE(HistEvent) ev;		/* What we return		 */
	void *data;		/* data				 */
	struct hentry_t *next;	/* Next entry			 */
	struct hentry_t *prev;	/* Previous entry		 */
} hentry_t;

typedef struct history_t {
	hentry_t list;		/* Fake list header element	*/
	hentry_t *cursor;	/* Current element in the list	*/
	int max;		/* Maximum number of events	*/
	int cur;		/* Current number of events	*/
	int eventid;		/* For generation of unique event id	 */
	int flags;		/* TYPE(History) flags		*/
#define H_UNIQUE	1	/* Store only unique elements	*/
} history_t;

private int history_def_next(void *, TYPE(HistEvent) *);
private int history_def_first(void *, TYPE(HistEvent) *);
private int history_def_prev(void *, TYPE(HistEvent) *);
private int history_def_last(void *, TYPE(HistEvent) *);
private int history_def_curr(void *, TYPE(HistEvent) *);
private int history_def_set(void *, TYPE(HistEvent) *, const int);
private void history_def_clear(void *, TYPE(HistEvent) *);
private int history_def_enter(void *, TYPE(HistEvent) *, const Char *);
private int history_def_add(void *, TYPE(HistEvent) *, const Char *);
private int history_def_del(void *, TYPE(HistEvent) *, const int);

private int history_def_init(void **, TYPE(HistEvent) *, int);
private int history_def_insert(history_t *, TYPE(HistEvent) *, const Char *);
private void history_def_delete(history_t *, TYPE(HistEvent) *, hentry_t *);

private int history_deldata_nth(history_t *, TYPE(HistEvent) *, int, void **);
private int history_set_nth(void *, TYPE(HistEvent) *, int);

#define	history_def_setsize(p, num)(void) (((history_t *)p)->max = (num))
#define	history_def_getsize(p)  (((history_t *)p)->cur)
#define	history_def_getunique(p) (((((history_t *)p)->flags) & H_UNIQUE) != 0)
#define	history_def_setunique(p, uni) \
    if (uni) \
	(((history_t *)p)->flags) |= H_UNIQUE; \
    else \
	(((history_t *)p)->flags) &= ~H_UNIQUE

#define	he_strerror(code)	he_errlist[code]
#define	he_seterrev(evp, code)	{\
				    evp->num = code;\
				    evp->str = he_strerror(code);\
				}

/* error messages */
static const Char *const he_errlist[] = {
	STR("OK"),
	STR("unknown error"),
	STR("malloc() failed"),
	STR("first event not found"),
	STR("last event not found"),
	STR("empty list"),
	STR("no next event"),
	STR("no previous event"),
	STR("current event is invalid"),
	STR("event not found"),
	STR("can't read history from file"),
	STR("can't write history"),
	STR("required parameter(s) not supplied"),
	STR("history size negative"),
	STR("function not allowed with other history-functions-set the default"),
	STR("bad parameters")
};
/* error codes */
#define	_HE_OK                   0
#define	_HE_UNKNOWN		 1
#define	_HE_MALLOC_FAILED        2
#define	_HE_FIRST_NOTFOUND       3
#define	_HE_LAST_NOTFOUND        4
#define	_HE_EMPTY_LIST           5
#define	_HE_END_REACHED          6
#define	_HE_START_REACHED	 7
#define	_HE_CURR_INVALID	 8
#define	_HE_NOT_FOUND		 9
#define	_HE_HIST_READ		10
#define	_HE_HIST_WRITE		11
#define	_HE_PARAM_MISSING	12
#define	_HE_SIZE_NEGATIVE	13
#define	_HE_NOT_ALLOWED		14
#define	_HE_BAD_PARAM		15

/* history_def_first():
 *	Default function to return the first event in the history.
 */
private int
history_def_first(void *p, TYPE(HistEvent) *ev)
{
	history_t *h = (history_t *) p;

	h->cursor = h->list.next;
	if (h->cursor != &h->list)
		*ev = h->cursor->ev;
	else {
		he_seterrev(ev, _HE_FIRST_NOTFOUND);
		return -1;
	}

	return 0;
}

/* history_def_last():
 *	Default function to return the last event in the history.
 */
private int
history_def_last(void *p, TYPE(HistEvent) *ev)
{
	history_t *h = (history_t *) p;

	h->cursor = h->list.prev;
	if (h->cursor != &h->list)
		*ev = h->cursor->ev;
	else {
		he_seterrev(ev, _HE_LAST_NOTFOUND);
		return -1;
	}

	return 0;
}

/* history_def_next():
 *	Default function to return the next event in the history.
 */
private int
history_def_next(void *p, TYPE(HistEvent) *ev)
{
	history_t *h = (history_t *) p;

	if (h->cursor == &h->list) {
		he_seterrev(ev, _HE_EMPTY_LIST);
		return -1;
	}

	if (h->cursor->next == &h->list) {
		he_seterrev(ev, _HE_END_REACHED);
		return -1;
	}

        h->cursor = h->cursor->next;
        *ev = h->cursor->ev;

	return 0;
}

/* history_def_prev():
 *	Default function to return the previous event in the history.
 */
private int
history_def_prev(void *p, TYPE(HistEvent) *ev)
{
	history_t *h = (history_t *) p;

	if (h->cursor == &h->list) {
		he_seterrev(ev,
		    (h->cur > 0) ? _HE_END_REACHED : _HE_EMPTY_LIST);
		return -1;
	}

	if (h->cursor->prev == &h->list) {
		he_seterrev(ev, _HE_START_REACHED);
		return -1;
	}

        h->cursor = h->cursor->prev;
        *ev = h->cursor->ev;

	return 0;
}

/* history_def_curr():
 *	Default function to return the current event in the history.
 */
private int
history_def_curr(void *p, TYPE(HistEvent) *ev)
{
	history_t *h = (history_t *) p;

	if (h->cursor != &h->list)
		*ev = h->cursor->ev;
	else {
		he_seterrev(ev,
		    (h->cur > 0) ? _HE_CURR_INVALID : _HE_EMPTY_LIST);
		return -1;
	}

	return 0;
}

/* history_def_set():
 *	Default function to set the current event in the history to the
 *	given one.
 */
private int
history_def_set(void *p, TYPE(HistEvent) *ev, const int n)
{
	history_t *h = (history_t *) p;

	if (h->cur == 0) {
		he_seterrev(ev, _HE_EMPTY_LIST);
		return -1;
	}
	if (h->cursor == &h->list || h->cursor->ev.num != n) {
		for (h->cursor = h->list.next; h->cursor != &h->list;
		    h->cursor = h->cursor->next)
			if (h->cursor->ev.num == n)
				break;
	}
	if (h->cursor == &h->list) {
		he_seterrev(ev, _HE_NOT_FOUND);
		return -1;
	}
	return 0;
}

/* history_set_nth():
 *	Default function to set the current event in the history to the
 *	n-th one.
 */
private int
history_set_nth(void *p, TYPE(HistEvent) *ev, int n)
{
	history_t *h = (history_t *) p;

	if (h->cur == 0) {
		he_seterrev(ev, _HE_EMPTY_LIST);
		return -1;
	}
	for (h->cursor = h->list.prev; h->cursor != &h->list;
	    h->cursor = h->cursor->prev)
		if (n-- <= 0)
			break;
	if (h->cursor == &h->list) {
		he_seterrev(ev, _HE_NOT_FOUND);
		return -1;
	}
	return 0;
}

/* history_def_add():
 *	Append string to element
 */
private int
history_def_add(void *p, TYPE(HistEvent) *ev, const Char *str)
{
	history_t *h = (history_t *) p;
	size_t len;
	Char *s;
	HistEventPrivate *evp = (void *)&h->cursor->ev;

	if (h->cursor == &h->list)
		return history_def_enter(p, ev, str);
	len = Strlen(evp->str) + Strlen(str) + 1;
	s = h_malloc(len * sizeof(*s));
	if (s == NULL) {
		he_seterrev(ev, _HE_MALLOC_FAILED);
		return -1;
	}
	(void) Strncpy(s, h->cursor->ev.str, len);
        s[len - 1] = '\0';
	(void) Strncat(s, str, len - Strlen(s) - 1);
	h_free(evp->str);
	evp->str = s;
	*ev = h->cursor->ev;
	return 0;
}

private int
history_deldata_nth(history_t *h, TYPE(HistEvent) *ev,
    int num, void **data)
{
	if (history_set_nth(h, ev, num) != 0)
		return -1;
	/* magic value to skip delete (just set to n-th history) */
	if (data == (void **)-1)
		return 0;
	ev->str = Strdup(h->cursor->ev.str);
	ev->num = h->cursor->ev.num;
	if (data)
		*data = h->cursor->data;
	history_def_delete(h, ev, h->cursor);
	return 0;
}

/* history_def_del():
 *	Delete element hp of the h list
 */
/* ARGSUSED */
private int
history_def_del(void *p, TYPE(HistEvent) *ev __attribute__((__unused__)),
    const int num)
{
	history_t *h = (history_t *) p;
	if (history_def_set(h, ev, num) != 0)
		return -1;
	ev->str = Strdup(h->cursor->ev.str);
	ev->num = h->cursor->ev.num;
	history_def_delete(h, ev, h->cursor);
	return 0;
}

/* history_def_delete():
 *	Delete element hp of the h list
 */
/* ARGSUSED */
private void
history_def_delete(history_t *h,
		   TYPE(HistEvent) *ev __attribute__((__unused__)), hentry_t *hp)
{
	HistEventPrivate *evp = (void *)&hp->ev;
	if (hp == &h->list)
		abort();
	if (h->cursor == hp) {
		h->cursor = hp->prev;
		if (h->cursor == &h->list)
			h->cursor = hp->next;
	}
	hp->prev->next = hp->next;
	hp->next->prev = hp->prev;
	h_free(evp->str);
	h_free(hp);
	h->cur--;
}

/* history_def_insert():
 *	Insert element with string str in the h list
 */
private int
history_def_insert(history_t *h, TYPE(HistEvent) *ev, const Char *str)
{
	hentry_t *c;

	c = h_malloc(sizeof(*c));
	if (c == NULL)
		goto oomem;
	if ((c->ev.str = h_strdup(str)) == NULL) {
		h_free(c);
		goto oomem;
	}
	c->data = NULL;
	c->ev.num = ++h->eventid;
	c->next = h->list.next;
	c->prev = &h->list;
	h->list.next->prev = c;
	h->list.next = c;
	h->cur++;
	h->cursor = c;

	*ev = c->ev;
	return 0;
oomem:
	he_seterrev(ev, _HE_MALLOC_FAILED);
	return -1;
}

/* history_def_enter():
 *	Default function to enter an item in the history
 */
private int
history_def_enter(void *p, TYPE(HistEvent) *ev, const Char *str)
{
	history_t *h = (history_t *) p;

	if ((h->flags & H_UNIQUE) != 0 && h->list.next != &h->list &&
	    Strcmp(h->list.next->ev.str, str) == 0)
	    return 0;

	if (history_def_insert(h, ev, str) == -1)
		return -1;	/* error, keep error message */

	/*
         * Always keep at least one entry.
         * This way we don't have to check for the empty list.
         */
	while (h->cur > h->max && h->cur > 0)
		history_def_delete(h, ev, h->list.prev);

	return 1;
}

/* history_def_init():
 *	Default history initialization function
 */
/* ARGSUSED */
private int
history_def_init(void **p, TYPE(HistEvent) *ev __attribute__((__unused__)), int n)
{
	history_t *h = (history_t *) h_malloc(sizeof(*h));
	if (h == NULL)
		return -1;

	if (n <= 0)
		n = 0;
	h->eventid = 0;
	h->cur = 0;
	h->max = n;
	h->list.next = h->list.prev = &h->list;
	h->list.ev.str = NULL;
	h->list.ev.num = 0;
	h->cursor = &h->list;
	h->flags = 0;
	*p = h;
	return 0;
}

/* history_def_clear():
 *	Default history cleanup function
 */
private void
history_def_clear(void *p, TYPE(HistEvent) *ev)
{
	history_t *h = (history_t *) p;

	while (h->list.prev != &h->list)
		history_def_delete(h, ev, h->list.prev);
	h->cursor = &h->list;
	h->eventid = 0;
	h->cur = 0;
}

/************************************************************************/

/* history_init():
 *	Initialization function.
 */
public TYPE(History) *
FUN(history,init)(void)
{
	TYPE(HistEvent) ev;
	TYPE(History) *h = (TYPE(History) *) h_malloc(sizeof(*h));
	if (h == NULL)
		return NULL;

	if (history_def_init(&h->h_ref, &ev, 0) == -1) {
		h_free(h);
		return NULL;
	}
	h->h_ent = -1;
	h->h_next = history_def_next;
	h->h_first = history_def_first;
	h->h_last = history_def_last;
	h->h_prev = history_def_prev;
	h->h_curr = history_def_curr;
	h->h_set = history_def_set;
	h->h_clear = history_def_clear;
	h->h_enter = history_def_enter;
	h->h_add = history_def_add;
	h->h_del = history_def_del;

	return h;
}

/* history_end():
 *	clean up history;
 */
public void
FUN(history,end)(TYPE(History) *h)
{
	TYPE(HistEvent) ev;

	if (h->h_next == history_def_next)
		history_def_clear(h->h_ref, &ev);
	h_free(h->h_ref);
	h_free(h);
}

/* history_setsize():
 *	Set history number of events
 */
private int
history_setsize(TYPE(History) *h, TYPE(HistEvent) *ev, int num)
{

	if (h->h_next != history_def_next) {
		he_seterrev(ev, _HE_NOT_ALLOWED);
		return -1;
	}
	if (num < 0) {
		he_seterrev(ev, _HE_BAD_PARAM);
		return -1;
	}
	history_def_setsize(h->h_ref, num);
	return 0;
}

/* history_getsize():
 *      Get number of events currently in history
 */
private int
history_getsize(TYPE(History) *h, TYPE(HistEvent) *ev)
{
	if (h->h_next != history_def_next) {
		he_seterrev(ev, _HE_NOT_ALLOWED);
		return -1;
	}
	ev->num = history_def_getsize(h->h_ref);
	if (ev->num < -1) {
		he_seterrev(ev, _HE_SIZE_NEGATIVE);
		return -1;
	}
	return 0;
}

/* history_setunique():
 *	Set if adjacent equal events should not be entered in history.
 */
private int
history_setunique(TYPE(History) *h, TYPE(HistEvent) *ev, int uni)
{

	if (h->h_next != history_def_next) {
		he_seterrev(ev, _HE_NOT_ALLOWED);
		return -1;
	}
	history_def_setunique(h->h_ref, uni);
	return 0;
}

/* history_getunique():
 *	Get if adjacent equal events should not be entered in history.
 */
private int
history_getunique(TYPE(History) *h, TYPE(HistEvent) *ev)
{
	if (h->h_next != history_def_next) {
		he_seterrev(ev, _HE_NOT_ALLOWED);
		return -1;
	}
	ev->num = history_def_getunique(h->h_ref);
	return 0;
}

/* history_set_fun():
 *	Set history functions
 */
private int
history_set_fun(TYPE(History) *h, TYPE(History) *nh)
{
	TYPE(HistEvent) ev;

	if (nh->h_first == NULL || nh->h_next == NULL || nh->h_last == NULL ||
	    nh->h_prev == NULL || nh->h_curr == NULL || nh->h_set == NULL ||
	    nh->h_enter == NULL || nh->h_add == NULL || nh->h_clear == NULL ||
	    nh->h_del == NULL || nh->h_ref == NULL) {
		if (h->h_next != history_def_next) {
			if (history_def_init(&h->h_ref, &ev, 0) == -1)
				return -1;
			h->h_first = history_def_first;
			h->h_next = history_def_next;
			h->h_last = history_def_last;
			h->h_prev = history_def_prev;
			h->h_curr = history_def_curr;
			h->h_set = history_def_set;
			h->h_clear = history_def_clear;
			h->h_enter = history_def_enter;
			h->h_add = history_def_add;
			h->h_del = history_def_del;
		}
		return -1;
	}
	if (h->h_next == history_def_next)
		history_def_clear(h->h_ref, &ev);

	h->h_ent = -1;
	h->h_first = nh->h_first;
	h->h_next = nh->h_next;
	h->h_last = nh->h_last;
	h->h_prev = nh->h_prev;
	h->h_curr = nh->h_curr;
	h->h_set = nh->h_set;
	h->h_clear = nh->h_clear;
	h->h_enter = nh->h_enter;
	h->h_add = nh->h_add;
	h->h_del = nh->h_del;

	return 0;
}

/* history_load():
 *	TYPE(History) load function
 */
private int
history_load(TYPE(History) *h, const char *fname)
{
	FILE *fp;
	char *line;
	size_t sz, max_size;
	char *ptr;
	int i = -1;
	TYPE(HistEvent) ev;
#ifdef WIDECHAR
	static ct_buffer_t conv;
#endif

	if ((fp = fopen(fname, "r")) == NULL)
		return i;

	if ((line = fgetln(fp, &sz)) == NULL)
		goto done;

	if (strncmp(line, hist_cookie, sz) != 0)
		goto done;

	ptr = h_malloc((max_size = 1024) * sizeof(*ptr));
	if (ptr == NULL)
		goto done;
	for (i = 0; (line = fgetln(fp, &sz)) != NULL; i++) {
		char c = line[sz];

		if (sz != 0 && line[sz - 1] == '\n')
			line[--sz] = '\0';
		else
			line[sz] = '\0';

		if (max_size < sz) {
			char *nptr;
			max_size = (sz + 1024) & (size_t)~1023;
			nptr = h_realloc(ptr, max_size * sizeof(*ptr));
			if (nptr == NULL) {
				i = -1;
				goto oomem;
			}
			ptr = nptr;
		}
		(void) strunvis(ptr, line);
		line[sz] = c;
		if (HENTER(h, &ev, ct_decode_string(ptr, &conv)) == -1) {
			i = -1;
			goto oomem;
		}
	}
oomem:
	h_free(ptr);
done:
	(void) fclose(fp);
	return i;
}

/* history_save():
 *	TYPE(History) save function
 */
private int
history_save(TYPE(History) *h, const char *fname)
{
	FILE *fp;
	TYPE(HistEvent) ev;
	int i = -1, retval;
	size_t len, max_size;
	char *ptr;
	const char *str;
#ifdef WIDECHAR
	static ct_buffer_t conv;
#endif

	if ((fp = fopen(fname, "w")) == NULL)
		return -1;

	if (fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1)
		goto done;
	if (fputs(hist_cookie, fp) == EOF)
		goto done;
	ptr = h_malloc((max_size = 1024) * sizeof(*ptr));
	if (ptr == NULL)
		goto done;
	for (i = 0, retval = HLAST(h, &ev);
	    retval != -1;
	    retval = HPREV(h, &ev), i++) {
		str = ct_encode_string(ev.str, &conv);
		len = strlen(str) * 4;
		if (len >= max_size) {
			char *nptr;
			max_size = (len + 1024) & (size_t)~1023;
			nptr = h_realloc(ptr, max_size * sizeof(*ptr));
			if (nptr == NULL) {
				i = -1;
				goto oomem;
			}
			ptr = nptr;
		}
		(void) strvis(ptr, str, VIS_WHITE);
		(void) fprintf(fp, "%s\n", ptr);
	}
oomem:
	h_free(ptr);
done:
	(void) fclose(fp);
	return i;
}

/* history_prev_event():
 *	Find the previous event, with number given
 */
private int
history_prev_event(TYPE(History) *h, TYPE(HistEvent) *ev, int num)
{
	int retval;

	for (retval = HCURR(h, ev); retval != -1; retval = HPREV(h, ev))
		if (ev->num == num)
			return 0;

	he_seterrev(ev, _HE_NOT_FOUND);
	return -1;
}

private int
history_next_evdata(TYPE(History) *h, TYPE(HistEvent) *ev, int num, void **d)
{
	int retval;

	for (retval = HCURR(h, ev); retval != -1; retval = HPREV(h, ev))
		if (ev->num == num) {
			if (d)
				*d = ((history_t *)h->h_ref)->cursor->data;
			return 0;
		}

	he_seterrev(ev, _HE_NOT_FOUND);
	return -1;
}

/* history_next_event():
 *	Find the next event, with number given
 */
private int
history_next_event(TYPE(History) *h, TYPE(HistEvent) *ev, int num)
{
	int retval;

	for (retval = HCURR(h, ev); retval != -1; retval = HNEXT(h, ev))
		if (ev->num == num)
			return 0;

	he_seterrev(ev, _HE_NOT_FOUND);
	return -1;
}

/* history_prev_string():
 *	Find the previous event beginning with string
 */
private int
history_prev_string(TYPE(History) *h, TYPE(HistEvent) *ev, const Char *str)
{
	size_t len = Strlen(str);
	int retval;

	for (retval = HCURR(h, ev); retval != -1; retval = HNEXT(h, ev))
		if (Strncmp(str, ev->str, len) == 0)
			return 0;

	he_seterrev(ev, _HE_NOT_FOUND);
	return -1;
}

/* history_next_string():
 *	Find the next event beginning with string
 */
private int
history_next_string(TYPE(History) *h, TYPE(HistEvent) *ev, const Char *str)
{
	size_t len = Strlen(str);
	int retval;

	for (retval = HCURR(h, ev); retval != -1; retval = HPREV(h, ev))
		if (Strncmp(str, ev->str, len) == 0)
			return 0;

	he_seterrev(ev, _HE_NOT_FOUND);
	return -1;
}

/* history():
 *	User interface to history functions.
 */
int
FUNW(history)(TYPE(History) *h, TYPE(HistEvent) *ev, int fun, ...)
{
	va_list va;
	const Char *str;
	int retval;

	va_start(va, fun);

	he_seterrev(ev, _HE_OK);

	switch (fun) {
	case H_GETSIZE:
		retval = history_getsize(h, ev);
		break;

	case H_SETSIZE:
		retval = history_setsize(h, ev, va_arg(va, int));
		break;

	case H_GETUNIQUE:
		retval = history_getunique(h, ev);
		break;

	case H_SETUNIQUE:
		retval = history_setunique(h, ev, va_arg(va, int));
		break;

	case H_ADD:
		str = va_arg(va, const Char *);
		retval = HADD(h, ev, str);
		break;

	case H_DEL:
		retval = HDEL(h, ev, va_arg(va, const int));
		break;

	case H_ENTER:
		str = va_arg(va, const Char *);
		if ((retval = HENTER(h, ev, str)) != -1)
			h->h_ent = ev->num;
		break;

	case H_APPEND:
		str = va_arg(va, const Char *);
		if ((retval = HSET(h, ev, h->h_ent)) != -1)
			retval = HADD(h, ev, str);
		break;

	case H_FIRST:
		retval = HFIRST(h, ev);
		break;

	case H_NEXT:
		retval = HNEXT(h, ev);
		break;

	case H_LAST:
		retval = HLAST(h, ev);
		break;

	case H_PREV:
		retval = HPREV(h, ev);
		break;

	case H_CURR:
		retval = HCURR(h, ev);
		break;

	case H_SET:
		retval = HSET(h, ev, va_arg(va, const int));
		break;

	case H_CLEAR:
		HCLEAR(h, ev);
		retval = 0;
		break;

	case H_LOAD:
		retval = history_load(h, va_arg(va, const char *));
		if (retval == -1)
			he_seterrev(ev, _HE_HIST_READ);
		break;

	case H_SAVE:
		retval = history_save(h, va_arg(va, const char *));
		if (retval == -1)
			he_seterrev(ev, _HE_HIST_WRITE);
		break;

	case H_PREV_EVENT:
		retval = history_prev_event(h, ev, va_arg(va, int));
		break;

	case H_NEXT_EVENT:
		retval = history_next_event(h, ev, va_arg(va, int));
		break;

	case H_PREV_STR:
		retval = history_prev_string(h, ev, va_arg(va, const Char *));
		break;

	case H_NEXT_STR:
		retval = history_next_string(h, ev, va_arg(va, const Char *));
		break;

	case H_FUNC:
	{
		TYPE(History) hf;

		hf.h_ref = va_arg(va, void *);
		h->h_ent = -1;
		hf.h_first = va_arg(va, history_gfun_t);
		hf.h_next = va_arg(va, history_gfun_t);
		hf.h_last = va_arg(va, history_gfun_t);
		hf.h_prev = va_arg(va, history_gfun_t);
		hf.h_curr = va_arg(va, history_gfun_t);
		hf.h_set = va_arg(va, history_sfun_t);
		hf.h_clear = va_arg(va, history_vfun_t);
		hf.h_enter = va_arg(va, history_efun_t);
		hf.h_add = va_arg(va, history_efun_t);
		hf.h_del = va_arg(va, history_sfun_t);

		if ((retval = history_set_fun(h, &hf)) == -1)
			he_seterrev(ev, _HE_PARAM_MISSING);
		break;
	}

	case H_END:
		FUN(history,end)(h);
		retval = 0;
		break;

	case H_NEXT_EVDATA:
	{
		int num = va_arg(va, int);
		void **d = va_arg(va, void **);
		retval = history_next_evdata(h, ev, num, d);
		break;
	}

	case H_DELDATA:
	{
		int num = va_arg(va, int);
		void **d = va_arg(va, void **);
		retval = history_deldata_nth((history_t *)h->h_ref, ev, num, d);
		break;
	}

	case H_REPLACE: /* only use after H_NEXT_EVDATA */
	{
		const Char *line = va_arg(va, const Char *);
		void *d = va_arg(va, void *);
		const Char *s;
		if(!line || !(s = Strdup(line))) {
			retval = -1;
			break;
		}
		((history_t *)h->h_ref)->cursor->ev.str = s;
		((history_t *)h->h_ref)->cursor->data = d;
		retval = 0;
		break;
	}

	default:
		retval = -1;
		he_seterrev(ev, _HE_UNKNOWN);
		break;
	}
	va_end(va);
	return retval;
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel.DataAnnotations;

namespace Risersoft.API.GSTN.GSTR3
{
    public class GSTR3Total
    {

        [Required]
        [Display(Name = "Supplier GSTIN")]
        [MaxLength(15)]
        [MinLength(15)]
        [RegularExpression("^[a-zA-Z0-9]+$")]
        public string gstin { get; set; }

        [Required]
        [Display(Name = "Return Period")]
        [RegularExpression("^((0[1-9]|1[012])((19|20)\\d\\d))*$")]
        public string ret_period { get; set; }

        [Required]
        [Display(Name = "Turn Over Details")]
        public Tod tod { get; set; }

        [Required]
        [Display(Name = "Outward Supplies")]
        public Out osup { get; set; }

        [Required]
        [Display(Name = "Inward Supplies")]
        public InS isup { get; set; }

        [Required]
        [Display(Name = "Total Tax Liability")]
        public Ttl ttxl { get; set; }

        [Required]
        [Display(Name = "TCS Credit")]
        public TcsCredit tcs_cr { get; set; }

        [Required]
        [Display(Name = "TDS Credit")]
        public TdsCredit tds_cr { get; set; }

        [Required]
        [Display(Name = "ITC Credit")]
        public ItcCredit itc_cr { get; set; }

        [Required]
        [Display(Name = "Tax Paid")]
        public Tpm tpm { get; set; }

        [Required]
        [Display(Name = "Refund Claim")]
        public RfClm rf_clm { get; set; }
    }
}


text:
These days we rarely want to convert data back
and forth between EBCDIC and ASCII. What `dd` means
for us is not anymore a
[joke on JCL](http://catb.org/jargon/html/D/dd.html),
rather Dump Data (in particular, Dump
Disks) -- and we would like to be enabled to do it
in a robust way.

Unfortunately, as it shockingly dawned on me upon
trying to migrate my data off of an errant disk,
`dd` falls short of this. It either gives up on
facing a read error, or keeps going on nonchalantly,
screwing up offsets (ie. after an unreadable region
of one megabytes, the consequential data will be
shifted one megabyte backwards on the target media,
instead of leaving a one megabyte hole).

So then, in order:
- I cobbled together this program
- I successfully applied it to migrate over my data
  (call unit test)
- I read after [dd on Wikipedia](http://en.wikipedia.org/wiki/Dd_(Unix\))
  upon which I realized that there is a bunch of post-`dd`
  [attempts](http://www.kalysto.org/utilities/dd_rhelp/index.en.html)
  [born](http://garloff.de/kurt/linux/ddrescue/)
  [out](http://gnu.org/software/ddrescue/ddrescue.html)
  [of](http://seed7.sourceforge.net/scrshots/savehd7.htm) the very same
  frustration.

So I could have applied any of these very fine tools... at this
point I would be happy if I could say that this program took less
time to put together than look after prior art on Wikipedia, but
that's not true. Nevertheless, _almost_ true!

- `dead` is dead simple small and stupid, does not try to be
  clever like those tools (I believe you are better at it,
  so I don't try to compete with you)
- `dead` continues in presence of errors, leaving an appropriately
  sized hole in the target media and a log message
- `dead` makes use of the Linux
  [sendfile(2)](http://man7.org/linux/man-pages/man2/sendfile.2.html)
  system call (which has been rewritten to use the
  [splice](http://lwn.net/Articles/178199/) backend
  [as of 2.6.23](http://kernelnewbies.org/Linux_2_6_23#head-c8fd2455c44d9559429c0f72dbc85cd54a62470d)),
  and that makes it _fast_ by direct end-to-end in-kernel data copy.
  ~~I bet aforementioned utils are too old farty to do
  this, although I haven't checked~~. Well actually
  `dd_rescue` supports
  [splice(2)](http://man7.org/linux/man-pages/man2/splice.2.html),
  but that's a rather contrived construct enforcing a sandwich of
  pipe in between two splices, `splice(2)` needing to have a pipe
  as one end.

Note that the the `sendfile(2)` manpage claims that _sendfile()_ also
demands a socket end pre-2.6.33 (most likely in reference to
[v2.6.33-rc1~379^2~71](http://github.com/torvalds/linux/commit/v2.6.33-rc1~379%5E2~71)),
however `dead` works just fine for me on (vanillish) 2.6.32.

## How to dance with `dead`

    $ make dead
    $ ./dead -h

    dead does what dd(1) eventually aspired to do...
    Usage: dead [-opt=val...] [--] [progressbar helper...] < infile > outfile
    Data is transferred from infile to outfile using
    Linux sendfile(2) (yeh, so it's Linux only).

    Options (with values taking case insensitive k,m,g postfixes):
    -size=N		transfer N bytes (default: size of infile)
    -blksize=N	blocksize (default: 4194304)
    -offset=N	start transfer at offset N (default: 0)
    -targetoffset=N	position target file to N (default:
    			same as offset)
    -logfile=F	(default: stderr)

    If progressbar helper utility is given, it will
    be spawned and fed with data describing the
    progress of the operation.

This should be almost clear, with logfile and progressbar worth
for some words.

You are suggested to specify a logfile, that will have a record
of all intervals where error occurred. Now those intervals still
might have some useful data, which does not get transferred due
to the coarse blocksize. So then you should check your disk's
blocksize (

    hdparm -I /dev/<disk> | grep -i 'phys.*sector'

) and re-run `dead` on the reported intervals (making use of
`-offset` and `-size` options) with `-blksize` set to the disk's
blocksize. Then you are covered.

As of progressbar, `dead` does not implement it, rather outsources.
Some progressbar script is provided (`sambar.rb`) that can be specified
as the progressbar helper argument and that will produce you a simple
progress bar; however, you can write a better one. The progress feed
consists of 64 bit signed integers; the very first one specifies the
size of the whole data to be transferred, and the consecutive ones tell
the number of bytes transferred up to that point. In case of error
`dead` sends a negated value so that the progress bar can mark errors.

## ... and the mysterious dead sambar!

[![dead sambar](deadsambar.jpg)](https://web.archive.org/web/20121112192200/http://tribuneindia.com/2012/20120425/himachal.htm#8)


text:
// Copyright (c) 2013 Arista Networks, Inc.  All rights reserved.
// Arista Networks, Inc. Confidential and Proprietary.

#ifndef EOS_IP_ROUTE_H
#define EOS_IP_ROUTE_H

#include <eos/intf.h>
#include <eos/ip.h>
#include <eos/iterator.h>
#include <eos/mpls.h>

#include <eos/types/ip_route.h>

namespace eos {

class ip_route_iter_impl;

/// An IP route iterator
class EOS_SDK_PUBLIC ip_route_iter_t : public iter_base<ip_route_t,
                                                        ip_route_iter_impl> {
 private:
   friend class ip_route_iter_impl;
   explicit ip_route_iter_t(ip_route_iter_impl * const) EOS_SDK_PRIVATE;
};

class ip_route_via_iter_impl;

/// A route via iterator
class EOS_SDK_PUBLIC ip_route_via_iter_t : public iter_base<ip_route_via_t,
                                                            ip_route_via_iter_impl> {
 private:
   friend class ip_route_via_iter_impl;
   explicit ip_route_via_iter_t(ip_route_via_iter_impl * const) EOS_SDK_PRIVATE;
};

/// The manager for IP static route configuration
class EOS_SDK_PUBLIC ip_route_mgr {
 public:
    virtual ~ip_route_mgr();

   /**
    * Set the manager to only interact with routes with the given tag.
    *
    * If this tag is set to a non-zero number, then methods on this
    * class will only affect or expose routes with the given tag.
    */
   virtual void tag_is(uint32_t) = 0;

   /// Returns the current tag, or 0 if no tag is set.
   virtual uint32_t tag() const = 0;

   /**
    * Resync provides a mechanism to set routes to a known state.
    *
    * To start a resync, call resync_init() and then use
    * ip_route_set() and ip_route_via_set() to populate the static
    * routing table with the known entries. After all entries have
    * been set, call resync_complete(), which will delete all existing
    * routes and vias that were not added or modified during resync.
    * If a tag is set, resync will only delete routes and vias
    * corresponding to the current tag.
    *
    * During resync, this manager will act like it is referencing a
    * temporary table that starts off empty. Thus, methods like exist,
    * del, and getters will act only on that temporary table,
    * regardless of the real values in Sysdb. The one exception is
    * iteration; they will traverse the table stored in Sysdb,
    * regardless of whether or not the manager is in resync mode.
    */
   virtual void resync_init() = 0;
   /// Completes any underway resync operation.
   virtual void resync_complete() = 0;

   /**
    * Iterates across all configured static routes.
    * If a tag is set, only return routes that have match the current tag.
    */
   virtual ip_route_iter_t ip_route_iter() const = 0;

   /**
    * Iterates across configured nexthops for a given route key,
    * i.e., emit all ip_route_via_t's for a given route key. If a tag
    * is set, only return vias on routes that match the current tag.
    */
   virtual ip_route_via_iter_t ip_route_via_iter(ip_route_key_t const &) const = 0;

   /**
    * Tests for existence of any routes matching the route key in the config.
    * If a tag is set and the route belongs to a different tag, this
    * function returns false.
    */
   virtual bool exists(ip_route_key_t const &) const = 0;
   /// Tests if the given via exists.
   virtual bool exists(ip_route_via_t const &) const = 0;

   // Route management functions

   /// Gets a static route, or panics if the route key does not exist.
   virtual ip_route_t ip_route(ip_route_key_t const &) = 0;
   /// Inserts or updates a static route into the switch configuration.
   virtual void ip_route_set(ip_route_t const &) = 0;
   /// Removes all ECMP vias matching the route key, and the route itself.
   virtual void ip_route_del(ip_route_key_t const &) = 0;

   /**
    * Adds a via to an ip_route_t.
    * Will call panic() if the corresponding route does not match the
    * currently configured tag.
    *
    * @throws eos::invalid_argument_error If the passed via has no IP
    * address, interface or nexthop group set.
    */
   virtual void ip_route_via_set(ip_route_via_t const &) = 0;
   /**
    * Removes a via from an ip_route_t.
    * When all vias are removed, the route still exists with no
    * nexthop information.
    */
   virtual void ip_route_via_del(ip_route_via_t const &) = 0;

 protected:
   ip_route_mgr() EOS_SDK_PRIVATE;
 private:
   EOS_SDK_DISALLOW_COPY_CTOR(ip_route_mgr);
};

}  // end namespace eos

#endif // EOS_IP_ROUTE_H


text:
import React, { Component } from 'react'
import Immutable from 'immutable'
import classNames from 'classnames'

/* ================================================================================
 * 按钮组件
 * qq group: 582452342
 * email   : 2091938785@qq.com
 * author  : 美丽的地球啊 - mliu
 * ================================================================================ */
class SxButton extends Component {
    constructor(props, context) {
        super(props, context)

        this.state = {
            title: props.title,
            activatingTitle: props.activatingTitle,
            info: props.info,
            isHovering: false,
            isActivating: false,
            isChecked: false,
            isValidate: props.isValidate
        }
    }

    componentWillReceiveProps = (nextProps)=>{
        this.setState({title: nextProps.title})
        this.setState({info: nextProps.info})
        this.setState({activatingTitle: nextProps.activatingTitle})
        this.setState({isActivating: nextProps.isActivating})
        this.setState({isValidate: nextProps.isValidate})
    }

    shouldComponentUpdate = (nextProps, nextState)=>{
        let isChanged = nextState.title != this.state.title
        || nextState.activatingTitle != this.state.activatingTitle
        || nextState.info != this.state.info
        || nextState.isHovering != this.state.isHovering
        || nextState.isActivating != this.state.isActivating
        || nextState.isChecked != this.state.isChecked
        || nextState.isValidate != this.state.isValidate

        return isChanged
    }

    componentDidUpdate = (prevProps, prevState)=>{
        this.onValidate(this.state.isValidate)
    }

    setTitle = (value)=>{
        this.setState({title: value})
    }

    setActivatingTitle = (value)=>{
        this.setState({activatingTitle: value})
    }

    setActivating = (value)=>{
        this.setState({isActivating: value})
    }

    setValidate = (value)=>{
        this.setState( { isValidate: value } )
    }

    getButtonClass = ()=>{
        let type = this.props.type
        let cssClass = classNames({
            "sx-btn": true,
            "sx-box-r": this.props.isRow,
            "sx-box-c": !this.props.isRow,
            "sx-btn-default": type == "default",
            "sx-btn-simple": type == "simple",
            "sx-btn-small": type == "small",
            "sx-btn-medium": type == "medium",
            "sx-btn-large": type == "large",
            "sx-btn-selected": this.props.isDecorate && this.state.isActivating && this.state.isValidate,
            "sx-btn-active": this.props.isDecorate && this.state.isHovering && !this.state.isActivating && this.state.isValidate,
            "sx-btn-valid":  this.props.isDecorate && !this.state.isActivating && !this.state.isHovering && this.state.isValidate,
            "sx-btn-invalid": this.props.isDecorate &&!this.state.isValidate,
        })

        let { className } = this.props
        if(className){
            cssClass = cssClass + " " + className
        }

        return cssClass
    }

    onMouseOver = ()=>{
        if(this.state.isValidate){
            this.setState({ isHovering: true })
        }
    }

    onMouseOut = ()=>{
        if(this.state.isValidate){
            this.setState({ isHovering: false })
        }
    }

    onValidate = (isValidate)=>{
        if(this.props.onValidate){
            this.props.onValidate(isValidate)
        }

        return isValidate
    }

    onButton = ()=>{
        if(!this.state.isValidate || this.state.isActivating){
            return
        }

        let isChecked = !this.state.isChecked

        this.setState({isChecked: isChecked})

        if(this.props.onButton){
            this.props.onButton({tag:this.props.tag, isChecked: isChecked})
        }
    }

    renderIcon = ()=>{
        // 0: valid | 1: hover | 2: activating | 3: invalid
        let icons = this.props.icons
        if(icons.length == 0){
            return ""
        }

        //必须四个icon元素
        while(icons.length < 4){
            icons.push(icons[0])
        }

        //当前的icon
        let icon = icons[0]
        if(this.state.isValidate){
            if(this.state.isActivating){
                icon = icons[2]
            }else{
                if(this.state.isHovering){
                    icon = icons[1]
                }
            }
        }else{
            icon = icons[3]
        }

        if(icon){
            return

        }

        return null
    }

    renderTitle = (icon)=>{
        let title = this.state.title

        if(this.state.isActivating){
            let activatingTitle = this.state.activatingTitle
            if(!activatingTitle && !icon){
                activatingTitle = title
            }

            title = activatingTitle
        }

        if(title){
            return { title }
        }

        return null
    }

    render = ()=>{
        let btnClassName = this.getButtonClass()

        let icon = this.renderIcon()
        let title = this.renderTitle(icon)

        return
this.onMouseOver() }
            onMouseOut = { ()=>this.onMouseOut() }
            onClick = { ()=>this.onButton() } >
                { icon }
                { title }

    }
}

SxButton.propTypes = {
    title: React.PropTypes.string,
    activatingTitle: React.PropTypes.string,
    info: React.PropTypes.string,
    tag: React.PropTypes.string,
    icons: React.PropTypes.array,
    type: React.PropTypes.string,
    isRow: React.PropTypes.bool,
    isValidate: React.PropTypes.bool,
    isDecorate: React.PropTypes.bool,
    onValidate: React.PropTypes.func,
    onButton: React.PropTypes.func
};

SxButton.defaultProps = {
    title: "",
    activatingTitle: "",
    info: "",
    tag: "",
    icons: [],
    type: "default",
    isRow: true,
    isValidate: false,
    isDecorate: true,
    onValidate: null,
    onButton: null
};

export default SxButton


text:
import {
    pushNavigator,
    popNavigator,
    popToNavigator,
    replaceNavigator,
    resetNavigator
} from "actions/navigation";

describe("`navigation` action", () => {

    describe("`pushNavigator` action", () => {

        it("returns the correct object with `scene` as payload", () => {
            const scene = "home";
            const ret = pushNavigator(scene);
            expect(ret).to.deep.equal({
                type: "PUSH_SCENE",
                payload: scene
            });
        });

        it("throw if isn't passed a string as parameter", () => {
            const scene = {scene: "home"};
            function troublemaker () {
                pushNavigator(scene);
            }
            expect(troublemaker).to.throw(Error);
            expect(troublemaker).to.throw(`Invalid value ${JSON.stringify(scene, null, 2)} supplied to String`);
        });

    });

    describe("`replaceNavigator` function", () => {

        it("returns the correct object with `scene` as payload", () => {
            const scene = "home";
            const ret = replaceNavigator(scene);
            expect(ret).to.deep.equal({
                type: "REPLACE_SCENE",
                payload: scene
            });
        });

        it("throw if isn't passed a string as parameter", () => {
            const scene = {key: "home"};
            function troublemaker () {
                replaceNavigator(scene);
            }
            expect(troublemaker).to.throw(Error);
            expect(troublemaker).to.throw(`Invalid value ${JSON.stringify(scene, null, 2)} supplied to String`);
        });

    });

    describe("`resetNavigator` function", () => {

        it("returns an object with type `RESET_SCENE`", () => {
            const ret = resetNavigator();
            expect(ret).to.deep.equal({
                type: "RESET_SCENE"
            });
        });

    });

    describe("`popToNavigator` function", () => {

        it("returns the correct object with `scene` as payload", () => {
            const scene = "home";
            const ret = popToNavigator(scene);
            expect(ret).to.deep.equal({
                type: "POP_TO_SCENE",
                payload: scene
            });
        });

        it("throw if isn't passed a string as parameter", () => {
            const scene = {key: "home"};
            function troublemaker () {
                popToNavigator(scene);
            }
            expect(troublemaker).to.throw(Error);
            expect(troublemaker).to.throw(`Invalid value ${JSON.stringify(scene, null, 2)} supplied to String`);
        });

    });

    describe("`popNavigator` function", () => {

        it("returns an object with type `POP_SCENE`", () => {
            const ret = popNavigator();
            expect(ret).to.deep.equal({
                type: "POP_SCENE"
            });
        });

    });

});


text:
layout: relation
title:  'expl'
shortdef : 'expletive'
udver: '2'
---

This relation captures an existential *there* or *it* in extraposition constructions. There is further discussion and examples on the universal dependency page ([u-dep/expl]()).

~~~ sdparse
There is a ghost in the room
expl(is, There)
~~~
<!-- Interlanguage links updated Po lis 14 15:35:25 CET 2022 -->


text:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';

import { PocComponent } from './poc.component';

@NgModule({
  imports: [
    CommonModule,
    RouterModule.forChild([
      {
        path: '',
        component: PocComponent,
        data: {
          title: 'POC管理'
        }
      }
    ])
  ],
  declarations: [
    PocComponent
  ]
})
export class PocModule { }


text:
React = require('react/addons');
TestUtils = React.addons.TestUtils;
ReactTabs = require('../lib/main');
Tab = ReactTabs.Tab;
Tabs = ReactTabs.Tabs;
TabList = ReactTabs.TabList;
TabPanel = ReactTabs.TabPanel;

assert = require('assert');
ok = assert.ok;
equal = assert.equal;
strictEqual = assert.strictEqual;
throws = assert.throws;


text:
module VividSeatApi
  class Resource < Base
    def list(options = {})
      get_query_api("getListings", options)
    end

    def update(options = {})
      post_query_api("updateListing", options)
    end

    def delete(options = {})
      get_query_api("deleteListing", options)
    end

    def create(options = {})
      post_query_api("insertListing", options)
    end

    def insert_or_update(options = {})
      post_query_api("insertOrUpdateListing", options)
    end
  end
end


text:
package com.google.javascript.refactoring.testing;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.SetMultimap;
import com.google.javascript.refactoring.ApplySuggestedFixes;
import com.google.javascript.refactoring.CodeReplacement;
import com.google.javascript.refactoring.SuggestedFix;
import java.util.List;
import java.util.Set;

/** Utilities for testing SuggestedFix-related code. */
public final class SuggestedFixes {
  private SuggestedFixes() {}

  public static void assertReplacement(SuggestedFix fix, CodeReplacement expectedReplacement) {
    assertReplacements(fix, ImmutableSet.of(expectedReplacement));
  }

  private static void assertReplacements(
      SuggestedFix fix, Set<CodeReplacement> expectedReplacements) {
    SetMultimap<String, CodeReplacement> replacementMap = fix.getReplacements();
    assertThat(replacementMap).hasSize(1);
    Set<CodeReplacement> replacements = replacementMap.get("test");
    assertThat(replacements).hasSize(expectedReplacements.size());
    assertEquals(expectedReplacements, replacements);
  }

  public static void assertChanges(
      SuggestedFix fix, String externs, String originalCode, String expectedCode) {
    assertChanges(ImmutableList.of(fix), externs, originalCode, expectedCode);
  }

  public static void assertChanges(
      List<SuggestedFix> fixes, String externs, String originalCode, String expectedCode) {
    assertThat(fixes).isNotEmpty();
    String newCode =
        ApplySuggestedFixes.applySuggestedFixesToCode(fixes, ImmutableMap.of("test", originalCode))
            .get("test");
    assertEquals(expectedCode, newCode);
  }
}


text:
/*
Exercise 7.4 Implement an engine for pricing when the spot price
is normal instead of log-normal.

Re: Chapter 7, problem 4

Postby mj » Sun Jan 23, 2011 10:29 pm
in the Black-Scholes stock price increments are lognormal in any measure.

However, there are many other models.

The Bachelier model has normal increments.

*/

#ifndef EXOTIC_NORMAL_ENGINE_H
#define EXOTIC_NORMAL_ENGINE_H
#include <ExoticEngine.h>
#include <Random2.h>

class ExoticNormalEngine : public ExoticEngine
{
public:

      ExoticNormalEngine(const Wrapper<PathDependent>& TheProduct_,
                     const Parameters& R_,
                     const Parameters& D_,
                     const Parameters& Vol_,
                     const Wrapper<RandomBase>& TheGenerator_,
                     double Spot_);

      virtual void GetOnePath(MJArray& SpotValues);
      virtual ~ExoticNormalEngine(){}

private:

    Wrapper<RandomBase> TheGenerator;
    MJArray Drifts;
    MJArray StandardDeviations;
    double Spot;
    unsigned long NumberOfTimes;
    MJArray Variates;
};

#endif


text:
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2015 The Android Open Source Project

     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.
-->
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <padding
        android:bottom="4dp"
        android:left="4dp"
        android:right="4dp"
        android:top="4dp"></padding>
    <solid android:color="#FFEEEEEE"></solid>
</shape>


text:
@interface HYThreeTVC_Photo : UIViewController
@property (nonatomic, strong) UITableView *tableView;
@end