text:
package org.infiniquery.model.decoder;

import static org.infiniquery.util.Utils.isEntity;
import static org.infiniquery.util.Utils.resolveClass;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.infiniquery.model.EntityAttributeOperator;

/**
 * Decoder class intended to map the relationship between JPA entity attribute types and their applicable operators.
 * @author Daniel Doboga
 * @since 1.0.0
 */
public class Type2OperatorMap {

    @SuppressWarnings({ "serial", "rawtypes"})
	private static Map<Class, EntityAttributeOperator[]> map = new HashMap<Class, EntityAttributeOperator[]>() {{
        put(int.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.EQUALS,
                EntityAttributeOperator.GREATER_THAN,
                EntityAttributeOperator.LOWER_THAN,
                EntityAttributeOperator.GREATER_THAN_OR_EQUALS,
                EntityAttributeOperator.LOWER_THAN_OR_EQUALS
        } );
        put(long.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.EQUALS,
                EntityAttributeOperator.GREATER_THAN,
                EntityAttributeOperator.LOWER_THAN,
                EntityAttributeOperator.GREATER_THAN_OR_EQUALS,
                EntityAttributeOperator.LOWER_THAN_OR_EQUALS
        } );
        put(short.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.EQUALS,
                EntityAttributeOperator.GREATER_THAN,
                EntityAttributeOperator.LOWER_THAN,
                EntityAttributeOperator.GREATER_THAN_OR_EQUALS,
                EntityAttributeOperator.LOWER_THAN_OR_EQUALS
        } );
        put(float.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.EQUALS,
                EntityAttributeOperator.GREATER_THAN,
                EntityAttributeOperator.LOWER_THAN,
                EntityAttributeOperator.GREATER_THAN_OR_EQUALS,
                EntityAttributeOperator.LOWER_THAN_OR_EQUALS
        } );
        put(double.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.EQUALS,
                EntityAttributeOperator.GREATER_THAN,
                EntityAttributeOperator.LOWER_THAN,
                EntityAttributeOperator.GREATER_THAN_OR_EQUALS,
                EntityAttributeOperator.LOWER_THAN_OR_EQUALS
        } );
        put(Integer.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.EQUALS,
                EntityAttributeOperator.GREATER_THAN,
                EntityAttributeOperator.LOWER_THAN,
                EntityAttributeOperator.GREATER_THAN_OR_EQUALS,
                EntityAttributeOperator.LOWER_THAN_OR_EQUALS
        } );
        put(Long.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.EQUALS,
                EntityAttributeOperator.GREATER_THAN,
                EntityAttributeOperator.LOWER_THAN,
                EntityAttributeOperator.GREATER_THAN_OR_EQUALS,
                EntityAttributeOperator.LOWER_THAN_OR_EQUALS
        } );
        put(Short.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.EQUALS,
                EntityAttributeOperator.GREATER_THAN,
                EntityAttributeOperator.LOWER_THAN,
                EntityAttributeOperator.GREATER_THAN_OR_EQUALS,
                EntityAttributeOperator.LOWER_THAN_OR_EQUALS
        } );
        put(Float.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.EQUALS,
                EntityAttributeOperator.GREATER_THAN,
                EntityAttributeOperator.LOWER_THAN,
                EntityAttributeOperator.GREATER_THAN_OR_EQUALS,
                EntityAttributeOperator.LOWER_THAN_OR_EQUALS
        } );
        put(Double.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.EQUALS,
                EntityAttributeOperator.GREATER_THAN,
                EntityAttributeOperator.LOWER_THAN,
                EntityAttributeOperator.GREATER_THAN_OR_EQUALS,
                EntityAttributeOperator.LOWER_THAN_OR_EQUALS
        } );
        put(BigInteger.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.EQUALS,
                EntityAttributeOperator.GREATER_THAN,
                EntityAttributeOperator.LOWER_THAN,
                EntityAttributeOperator.GREATER_THAN_OR_EQUALS,
                EntityAttributeOperator.LOWER_THAN_OR_EQUALS
        } );
        put(BigDecimal.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.EQUALS,
                EntityAttributeOperator.GREATER_THAN,
                EntityAttributeOperator.LOWER_THAN,
                EntityAttributeOperator.GREATER_THAN_OR_EQUALS,
                EntityAttributeOperator.LOWER_THAN_OR_EQUALS
        } );
        put(String.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.EQUALS,
                EntityAttributeOperator.CONTAINS,
                EntityAttributeOperator.LIKE,
                EntityAttributeOperator.IN
        } );
        put(java.util.Date.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.BEFORE,
                EntityAttributeOperator.AFTER,
                EntityAttributeOperator.EQUALS
        } );
        put(java.sql.Date.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.BEFORE,
                EntityAttributeOperator.AFTER,
                EntityAttributeOperator.EQUALS
        } );
        put(java.time.LocalDate.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.BEFORE,
                EntityAttributeOperator.AFTER,
                EntityAttributeOperator.EQUALS
        } );
        put(java.sql.Timestamp.class, new EntityAttributeOperator[] {
                EntityAttributeOperator.BEFORE,
                EntityAttributeOperator.AFTER,
                EntityAttributeOperator.EQUALS
        } );
        Class<?> jodaDateTimeClass = resolveClass("org.joda.time.DateTime");
        if(jodaDateTimeClass != null) {
            put(jodaDateTimeClass, new EntityAttributeOperator[]{
                    EntityAttributeOperator.BEFORE,
                    EntityAttributeOperator.AFTER,
                    EntityAttributeOperator.EQUALS
            });
        }
        put(Collection.class, new EntityAttributeOperator[] {
                //EntityAttributeOperator.EQUALS,
                //EntityAttributeOperator.LIKE,
                EntityAttributeOperator.IN
        } );
    }};

    /**
     * Get the applicable operators for an entity attribute of the given type.
     * @param attributeType the java {@link java.lang.Class} representing the type of the entity attribute to reolve applicable operators for.
     * @return an array of {@link org.infiniquery.model.EntityAttributeOperator} representing the applicable operators that can be used between an attribute of the given type and the values we want to filter it for.
     */
    public static EntityAttributeOperator[] getApplicableOperatorsForType(Class<?> attributeType) {
        if(map.containsKey(attributeType)) {
            return map.get(attributeType);
        } else if(Collection.class.isAssignableFrom(attributeType)) {
            //this covers Collection and any subclass of it
            return map.get(Collection.class);
        } else if(isEntity(attributeType)){
            //any possible entity;
        	//the same operators are applicable as for collections of entities
        	return map.get(Collection.class);
        } else {
            throw new RuntimeException("Not implemented entity types yet");
        }
    }

}


text:
<?php

namespace Symfony\Bridge\Monolog\Tests\Handler;

use Monolog\Logger;
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Tests the ConsoleHandler and also the ConsoleFormatter.
 *
 * @author Tobias Schultze <http://tobion.de>
 */
class ConsoleHandlerTest extends \PHPUnit_Framework_TestCase
{
    public function testConstructor()
    {
        $handler = new ConsoleHandler(null, false);
        $this->assertFalse($handler->getBubble(), 'the bubble parameter gets propagated');
    }

    public function testIsHandling()
    {
        $handler = new ConsoleHandler();
        $this->assertFalse($handler->isHandling(array()), '->isHandling returns false when no output is set');
    }

    /**
     * @dataProvider provideVerbosityMappingTests
     */
    public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = array())
    {
        $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
        $output
            ->expects($this->atLeastOnce())
            ->method('getVerbosity')
            ->will($this->returnValue($verbosity))
        ;
        $handler = new ConsoleHandler($output, true, $map);
        $this->assertSame($isHandling, $handler->isHandling(array('level' => $level)),
            '->isHandling returns correct value depending on console verbosity and log level'
        );
    }

    public function provideVerbosityMappingTests()
    {
        return array(
            array(OutputInterface::VERBOSITY_QUIET, Logger::ERROR, false),
            array(OutputInterface::VERBOSITY_NORMAL, Logger::WARNING, true),
            array(OutputInterface::VERBOSITY_NORMAL, Logger::NOTICE, false),
            array(OutputInterface::VERBOSITY_VERBOSE, Logger::NOTICE, true),
            array(OutputInterface::VERBOSITY_VERBOSE, Logger::INFO, false),
            array(OutputInterface::VERBOSITY_VERY_VERBOSE, Logger::INFO, true),
            array(OutputInterface::VERBOSITY_VERY_VERBOSE, Logger::DEBUG, false),
            array(OutputInterface::VERBOSITY_DEBUG, Logger::DEBUG, true),
            array(OutputInterface::VERBOSITY_DEBUG, Logger::EMERGENCY, true),
            array(OutputInterface::VERBOSITY_NORMAL, Logger::NOTICE, true, array(
                OutputInterface::VERBOSITY_NORMAL => Logger::NOTICE
            )),
            array(OutputInterface::VERBOSITY_DEBUG, Logger::NOTICE, true, array(
                OutputInterface::VERBOSITY_NORMAL => Logger::NOTICE
            )),
        );
    }

    public function testVerbosityChanged()
    {
        $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
        $output
            ->expects($this->at(0))
            ->method('getVerbosity')
            ->will($this->returnValue(OutputInterface::VERBOSITY_QUIET))
        ;
        $output
            ->expects($this->at(1))
            ->method('getVerbosity')
            ->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG))
        ;
        $handler = new ConsoleHandler($output);
        $this->assertFalse($handler->isHandling(array('level' => Logger::NOTICE)),
            'when verbosity is set to quiet, the handler does not handle the log'
        );
        $this->assertTrue($handler->isHandling(array('level' => Logger::NOTICE)),
            'since the verbosity of the output increased externally, the handler is now handling the log'
        );
    }

    public function testGetFormatter()
    {
        $handler = new ConsoleHandler();
        $this->assertInstanceOf('Symfony\Bridge\Monolog\Formatter\ConsoleFormatter', $handler->getFormatter(),
            '-getFormatter returns ConsoleFormatter by default'
        );
    }

    public function testWritingAndFormatting()
    {
        $output = $this->getMock('Symfony\Component\Console\Output\ConsoleOutputInterface');
        $output
            ->expects($this->any())
            ->method('getVerbosity')
            ->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG))
        ;
        $output
            ->expects($this->once())
            ->method('write')
            ->with('<info>[2013-05-29 16:21:54] app.INFO:</info> My info message [] []'."\n")
        ;

        $errorOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
        $errorOutput
            ->expects($this->once())
            ->method('write')
            ->with('<error>[2013-05-29 16:21:54] app.ERROR:</error> My error message [] []'."\n")
        ;

        $output
            ->expects($this->any())
            ->method('getErrorOutput')
            ->will($this->returnValue($errorOutput))
        ;

        $handler = new ConsoleHandler(null, false);
        $handler->setOutput($output);

        $infoRecord = array(
            'message' => 'My info message',
            'context' => array(),
            'level' => Logger::INFO,
            'level_name' => Logger::getLevelName(Logger::INFO),
            'channel' => 'app',
            'datetime' => new \DateTime('2013-05-29 16:21:54'),
            'extra' => array(),
        );

        $this->assertTrue($handler->handle($infoRecord), 'The handler finished handling the log as bubble is false.');

        $errorRecord = array(
            'message' => 'My error message',
            'context' => array(),
            'level' => Logger::ERROR,
            'level_name' => Logger::getLevelName(Logger::ERROR),
            'channel' => 'app',
            'datetime' => new \DateTime('2013-05-29 16:21:54'),
            'extra' => array(),
        );

        $this->assertTrue($handler->handle($errorRecord), 'The handler finished handling the log as bubble is false.');
    }
}

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>nlocks</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">

Overview

nlocks

Copyright © 2016 Guilherme Andrade

Version: 1.1.2

Authors: Guilherme Andrade (<tt>nlocks(at)gandrade(dot)net</tt>).

nlocks: Native spinlocks for Erlang

An experiment on Erlang native spinlocks:
* Able to guarantee exclusive access to shared resources
* Not dependent on a single process (no flooded mailbox as a bottleneck)
* Able to deal with brutally killed processes that still held unreleased locks (more below)

Lock = nlocks:new(),
Transaction = fun() ->
    io:format("hello from ~p at ~p~n", [self(), os:timestamp()]),
    timer:sleep(100)
end,

[spawn(fun () -> nlocks:transaction(Lock, Transaction) end) || _ <- lists:seq(1, 4)].
% hello from <0.66.0> at {1465,509871,454813}
% hello from <0.69.0> at {1465,509871,555028}
% hello from <0.67.0> at {1465,509871,656021}
% hello from <0.68.0> at {1465,509871,757031}

Brutal kills and unreleased locks

Hackish solution. Other than setting up some sort of monitor in the Erlang land, I found no practical way to deal with these other than making use of _ownership_ objects, references to which should never leave the process under which they were created; the release therefore becomes dependent on the garbage collector calling their destructor, but this also makes it more convenient for regularly terminated processes that forget to clean up.

Ownership objects

struct Ownership {
    ERL_NIF_TERM pid;
    Lock** lockResource;
};

* They're created for lock acquisition in order to deal with the above problem
* They should never leave their owning process
* On successful acquisition, they link themselves to the lock and force it to live as long as they live
* They guarantee only the lock owner can release the lock
* No explicit destruction needed

Lock objects

struct Lock {
    std::atomic<Ownership*> ownership;
};

* They keep an atomic pointer either set to null (free) or to the ownership object's address (locked)
* Can be shared between local processes through messages, ETS tables, etc.
* No explicit destruction needed

The spinning

* It uses C++ 11 compare_exchange_weak
* For each attempt, a new NIF call is scheduled; this brings some overhead to the table but it's crucial to play nice with the VM
* If the timeout is other than 'infinity', for each attempt it compares the deadline against the current steady_clock value; this feels excessive and might hurt performance.

Internal metrics

% nlocks:info()
[{allocated_locks,2},
 {allocated_ownerships,6},
 {acquired_locks,1},
 {contention,5}, % amount of processes attempting lock acquisition
 {has_lockfree_counters,true},
 {has_lockfree_ownership,true}]

Overview

Generated by EDoc, May 1 2017, 02:21:31.


text:
In order to run the performance tests, the `azure-devtools` package must be installed. This is done as part of the `dev_requirements` install.
Start by creating a new virtual environment for your perf tests. This will need to be a Python 3 environment, preferably >=3.7.

### Setup for test resources

The following environment variable will need to be set for the tests to access the live resources:

```
TRANSLATION_DOCUMENT_TEST_ENDPOINT=<translation-endpoint>
TRANSLATION_DOCUMENT_TEST_API_KEY=<translation-key>
TRANSLATION_DOCUMENT_STORAGE_NAME=<storage-blob-account-name>
TRANSLATION_DOCUMENT_STORAGE_KEY=<storage-shared-key>
```

### Setup for perf test runs

```cmd
(env) ~/azure-ai-translation-document> pip install -r dev_requirements.txt
(env) ~/azure-ai-translation-document> pip install -e .
```

## Test commands

When `azure-devtools` is installed, you will have access to the `perfstress` command line tool, which will scan the current module for runable perf tests. Only a specific test can be run at a time (i.e. there is no "run all" feature).

```cmd
(env) ~/azure-ai-translation-document> cd tests/perfstress_tests/
(env) ~/azure-ai-translation-document/tests/perfstress_tests> perfstress
```
Using the `perfstress` command alone will list the available perf tests found.

### Common perf command line options
These options are available for all perf tests:
- `--duration=10` Number of seconds to run as many operations (the "run" function) as possible. Default is 10.
- `--iterations=1` Number of test iterations to run. Default is 1.
- `--parallel=1` Number of tests to run in parallel. Default is 1.
- `--warm-up=5` Number of seconds to spend warming up the connection before measuring begins. Default is 5.
- `--sync` Whether to run the tests in sync or async. Default is False (async). This flag must be used for Storage legacy tests, which do not support async.
- `--no-cleanup` Whether to keep newly created resources after test run. Default is False (resources will be deleted).

## Example command
```cmd
(env) ~/azure-ai-translation-document/tests/perfstress_tests> perfstress TranslationPerfStressTest
```


text:
package org.apache.jena.shex.expressions;

/** Visitor for NodeConstainComponents. */
public interface NodeConstraintVisitor {

    public default void visit(NodeKindConstraint constraint) {}

    public default void visit(DatatypeConstraint constraint) {}

    public default void visit(NumLengthConstraint constraint) {}
    public default void visit(NumRangeConstraint constraint) {}

    public default void visit(StrRegexConstraint constraint) {}
    public default void visit(StrLengthConstraint constraint) {}

    public default void visit(ValueConstraint constraint) {}

}


text:
import numpy as np
from ..abstract_plotting_library import AbstractPlottingLibrary
from .. import Tango
from . import defaults
import plotly
from plotly import tools
from plotly.graph_objs import Scatter, Scatter3d, Line,\
    Marker, ErrorX, ErrorY, Bar, Heatmap, Trace,\
    Annotations, Annotation, Contour, Font, Surface
from plotly.exceptions import PlotlyDictKeyError

SYMBOL_MAP = {
    'o': 'circle-dot',
    'v': 'triangle-down',
    '^': 'triangle-up',
    '<': 'triangle-left',
    '>': 'triangle-right',
    's': 'square',
    '+': 'cross',
    'x': 'x',
    '*': 'star',
    'D': 'diamond',
    'd': 'diamond',
}

class PlotlyPlotsBase(AbstractPlottingLibrary):
    def __init__(self):
        super(PlotlyPlotsBase, self).__init__()
        self._defaults = defaults.__dict__
        self.current_states = dict()

    def figure(self, rows=1, cols=1, specs=None, is_3d=False, **kwargs):
        if specs is None:
            specs = [[{'is_3d': is_3d}]*cols]*rows
        figure = tools.make_subplots(rows, cols, specs=specs, **kwargs)
        return figure

    def new_canvas(self, figure=None, row=1, col=1, projection='2d',
                   xlabel=None, ylabel=None, zlabel=None,
                   title=None, xlim=None,
                   ylim=None, zlim=None, **kwargs):
        #if 'filename' not in kwargs:
        #    print('PlotlyWarning: filename was not given, this may clutter your plotly workspace')
        #    filename = None
        #else:
        #    filename = kwargs.pop('filename')
        if figure is None:
            figure = self.figure(is_3d=projection=='3d')
            figure.layout.font = Font(family="Raleway, sans-serif")
        if projection == '3d':
            figure.layout.legend.x=.5
            figure.layout.legend.bgcolor='#DCDCDC'
        return (figure, row, col), kwargs

    def add_to_canvas(self, canvas, traces, legend=False, **kwargs):
        figure, row, col = canvas
        def append_annotation(a, xref, yref):
            if 'xref' not in a:
                a['xref'] = xref
            if 'yref' not in a:
                a['yref'] = yref
            figure.layout.annotations.append(a)
        def append_trace(t, row, col):
            figure.append_trace(t, row, col)
        def recursive_append(traces):
            if isinstance(traces, Annotations):
                xref, yref = figure._grid_ref[row-1][col-1]
                for a in traces:
                    append_annotation(a, xref, yref)
            # elif isinstance(traces, (Trace)):  # doesn't work
            # elif type(traces) in [v for k,v in go.__dict__.iteritems()]:
            elif isinstance(traces, (Scatter, Scatter3d, ErrorX,
                        ErrorY, Bar, Heatmap, Trace, Contour, Surface)):
                try:
                    append_trace(traces, row, col)
                except PlotlyDictKeyError:
                    # Its a dictionary of plots:
                    for t in traces:
                        recursive_append(traces[t])
            elif isinstance(traces, (dict)):
                for t in traces:
                    recursive_append(traces[t])
            elif isinstance(traces, (tuple, list)):
                for t in traces:
                    recursive_append(t)
        recursive_append(traces)
        figure.layout['showlegend'] = legend
        return canvas

    def show_canvas(self, canvas, filename=None, **kwargs):
        return NotImplementedError

    def scatter(self, ax, X, Y, Z=None, color=Tango.colorsHex['mediumBlue'], cmap=None, label=None, marker='o', marker_kwargs=None, **kwargs):
        try:
            marker = SYMBOL_MAP[marker]
        except:
            #not matplotlib marker
            pass
        marker_kwargs = marker_kwargs or {}
        if 'symbol' not in marker_kwargs:
            marker_kwargs['symbol'] = marker
        X, Y = np.squeeze(X), np.squeeze(Y)
        if Z is not None:
            Z = np.squeeze(Z)
            return Scatter3d(x=X, y=Y, z=Z, mode='markers',
                             showlegend=label is not None,
                             marker=Marker(color=color, colorscale=cmap, **marker_kwargs),
                             name=label, **kwargs)
        return Scatter(x=X, y=Y, mode='markers', showlegend=label is not None,
                       marker=Marker(color=color, colorscale=cmap, **marker_kwargs),
                       name=label, **kwargs)

    def plot(self, ax, X, Y, Z=None, color=None, label=None, line_kwargs=None, **kwargs):
        if 'mode' not in kwargs:
            kwargs['mode'] = 'lines'
        X, Y = np.squeeze(X), np.squeeze(Y)
        if Z is not None:
            Z = np.squeeze(Z)
            return Scatter3d(x=X, y=Y, z=Z, showlegend=label is not None, line=Line(color=color, **line_kwargs or {}), name=label, **kwargs)
        return Scatter(x=X, y=Y, showlegend=label is not None, line=Line(color=color, **line_kwargs or {}), name=label, **kwargs)

    def plot_axis_lines(self, ax, X, color=Tango.colorsHex['mediumBlue'], label=None, marker_kwargs=None, **kwargs):
        if X.shape[1] == 1:
            annotations = Annotations()
            for i, row in enumerate(X):
                annotations.append(
                    Annotation(
                        text='',
                        x=row[0], y=0,
                        yref='paper',
                        ax=0, ay=20,
                        arrowhead=2,
                        arrowsize=1,
                        arrowwidth=2,
                        arrowcolor=color,
                        showarrow=True,
                        #showlegend=i==0,
                        #label=label,
                        ))
            return annotations
        elif X.shape[1] == 2:
            marker_kwargs.setdefault('symbol', 'diamond')
            opacity = kwargs.pop('opacity', .8)
            return Scatter3d(x=X[:, 0], y=X[:, 1], z=np.zeros(X.shape[0]),
                             mode='markers',
                             projection=dict(z=dict(show=True, opacity=opacity)),
                             marker=Marker(color=color, **marker_kwargs or {}),
                             opacity=0,
                             name=label,
                             showlegend=label is not None, **kwargs)

    def barplot(self, canvas, x, height, width=0.8, bottom=0, color=Tango.colorsHex['mediumBlue'], label=None, **kwargs):
        figure, _, _ = canvas
        if 'barmode' in kwargs:
            figure.layout['barmode'] = kwargs.pop('barmode')
        return Bar(x=x, y=height, marker=Marker(color=color), name=label)

    def xerrorbar(self, ax, X, Y, error, Z=None, color=Tango.colorsHex['mediumBlue'], label=None, error_kwargs=None, **kwargs):
        error_kwargs = error_kwargs or {}
        if (error.shape[0] == 2) and (error.ndim == 2):
            error_kwargs.update(dict(array=error[1], arrayminus=error[0], symmetric=False))
        else:
            error_kwargs.update(dict(array=error, symmetric=True))
        X, Y = np.squeeze(X), np.squeeze(Y)
        if Z is not None:
            Z = np.squeeze(Z)
            return Scatter3d(x=X, y=Y, z=Z, mode='markers',
                             error_x=ErrorX(color=color, **error_kwargs or {}),
                             marker=Marker(size='0'), name=label,
                             showlegend=label is not None, **kwargs)
        return Scatter(x=X, y=Y, mode='markers',
                       error_x=ErrorX(color=color, **error_kwargs or {}),
                       marker=Marker(size='0'), name=label,
                      showlegend=label is not None,
                       **kwargs)

    def yerrorbar(self, ax, X, Y, error, Z=None, color=Tango.colorsHex['mediumBlue'], label=None, error_kwargs=None, **kwargs):
        error_kwargs = error_kwargs or {}
        if (error.shape[0] == 2) and (error.ndim == 2):
            error_kwargs.update(dict(array=error[1], arrayminus=error[0], symmetric=False))
        else:
            error_kwargs.update(dict(array=error, symmetric=True))
        X, Y = np.squeeze(X), np.squeeze(Y)
        if Z is not None:
            Z = np.squeeze(Z)
            return Scatter3d(x=X, y=Y, z=Z, mode='markers',
                             error_y=ErrorY(color=color, **error_kwargs or {}),
                             marker=Marker(size='0'), name=label,
                             showlegend=label is not None, **kwargs)
        return Scatter(x=X, y=Y, mode='markers',
                       error_y=ErrorY(color=color, **error_kwargs or {}),
                       marker=Marker(size='0'), name=label,
                      showlegend=label is not None,
                       **kwargs)

    def imshow(self, ax, X, extent=None, label=None, vmin=None, vmax=None, **imshow_kwargs):
        if not 'showscale' in imshow_kwargs:
            imshow_kwargs['showscale'] = False
        return Heatmap(z=X, name=label,
                       x0=extent[0], dx=float(extent[1]-extent[0])/(X.shape[0]-1),
                       y0=extent[2], dy=float(extent[3]-extent[2])/(X.shape[1]-1),
                       zmin=vmin, zmax=vmax,
                       showlegend=label is not None,
                       hoverinfo='z',
                       **imshow_kwargs)

    def imshow_interact(self, ax, plot_function, extent=None, label=None, resolution=None, vmin=None, vmax=None, **imshow_kwargs):
        # TODO stream interaction?
        super(PlotlyPlotsBase, self).imshow_interact(ax, plot_function)

    def annotation_heatmap(self, ax, X, annotation, extent=None, label='Gradient', imshow_kwargs=None, **annotation_kwargs):
        imshow_kwargs.setdefault('label', label)
        imshow_kwargs.setdefault('showscale', True)
        imshow = self.imshow(ax, X, extent, **imshow_kwargs)
        X = X-X.min()
        X /= X.max()/2.
        X -= 1
        x = np.linspace(extent[0], extent[1], X.shape[0])
        y = np.linspace(extent[2], extent[3], X.shape[1])
        annotations = Annotations()
        for n, row in enumerate(annotation):
            for m, val in enumerate(row):
                var = X[n][m]
                annotations.append(
                    Annotation(
                        text=str(val),
                        x=x[m], y=y[n],
                        xref='x1', yref='y1',
                        font=dict(color='white' if np.abs(var) > 0.8 else 'black', size=10),
                        opacity=.5,
                        showarrow=False,
                        ))
        return imshow, annotations

    def annotation_heatmap_interact(self, ax, plot_function, extent, label=None, resolution=15, imshow_kwargs=None, **annotation_kwargs):
        super(PlotlyPlotsBase, self).annotation_heatmap_interact(ax, plot_function, extent)

    def contour(self, ax, X, Y, C, levels=20, label=None, **kwargs):
        return Contour(x=X, y=Y, z=C,
                       #ncontours=levels, contours=Contours(start=C.min(), end=C.max(), size=(C.max()-C.min())/levels),
                       name=label, **kwargs)

    def surface(self, ax, X, Y, Z, color=None, label=None, **kwargs):
        return Surface(x=X, y=Y, z=Z, name=label, showlegend=label is not None, **kwargs)

    def fill_between(self, ax, X, lower, upper, color=Tango.colorsHex['mediumBlue'], label=None, line_kwargs=None, **kwargs):
        if not 'line' in kwargs:
            kwargs['line'] = Line(**line_kwargs or {})
        else:
            kwargs['line'].update(line_kwargs or {})
        if color.startswith('#'):
            fcolor = 'rgba({c[0]}, {c[1]}, {c[2]}, {alpha})'.format(c=Tango.hex2rgb(color), alpha=kwargs.get('opacity', 1.0))
        else: fcolor = color
        u = Scatter(x=X, y=upper, fillcolor=fcolor, showlegend=label is not None, name=label, fill='tonextx', legendgroup='{}_fill_({},{})'.format(label, ax[1], ax[2]), **kwargs)
        #fcolor = '{}, {alpha})'.format(','.join(fcolor.split(',')[:-1]), alpha=0.0)
        l = Scatter(x=X, y=lower, fillcolor=fcolor, showlegend=False, name=label, legendgroup='{}_fill_({},{})'.format(label, ax[1], ax[2]), **kwargs)
        return l, u

    def fill_gradient(self, canvas, X, percentiles, color=Tango.colorsHex['mediumBlue'], label=None, **kwargs):
        if color.startswith('#'):
            colarray = Tango.hex2rgb(color)
            opacity = .9
        else:
            colarray = map(float(color.strip(')').split('(')[1]))
            if len(colarray) == 4:
                colarray, opacity = colarray[:3] ,colarray[3]

        alpha = opacity*(1.-np.abs(np.linspace(-1,1,len(percentiles)-1)))

        def pairwise(iterable):
            "s -> (s0,s1), (s1,s2), (s2, s3), ..."
            from itertools import tee
            a, b = tee(iterable)
            next(b, None)
            return zip(a, b)

        polycol = []
        for i, y1, a in zip(range(len(percentiles)), percentiles, alpha):
            fcolor = 'rgba({}, {}, {}, {alpha})'.format(*colarray, alpha=a)
            if i ==  len(percentiles)/2:
                polycol.append(Scatter(x=X, y=y1, fillcolor=fcolor, showlegend=True,
                                       name=label, line=Line(width=0, smoothing=0), mode='none', fill='tonextx',
                                       legendgroup='density', hoverinfo='none', **kwargs))
            else:
                polycol.append(Scatter(x=X, y=y1, fillcolor=fcolor, showlegend=False,
                                       name=None, line=Line(width=1, smoothing=0, color=fcolor), mode='none', fill='tonextx',
                                       legendgroup='density', hoverinfo='none', **kwargs))
        return polycol

class PlotlyPlotsOnline(PlotlyPlotsBase):
    def __init__(self):
        super(PlotlyPlotsOnline, self).__init__()

    def show_canvas(self, canvas, filename=None, **kwargs):
        figure, _, _ = canvas
        if len(figure.data) == 0:
            # add mock data
            figure.append_trace(Scatter(x=[], y=[], name='', showlegend=False), 1, 1)
        from ..gpy_plot.plot_util import in_ipynb
        if in_ipynb():
            return plotly.plotly.iplot(figure, filename=filename, **kwargs)
        else:
            return plotly.plotly.plot(figure, filename=filename, **kwargs)#self.current_states[hex(id(figure))]['filename'])

class PlotlyPlotsOffline(PlotlyPlotsBase):
    def __init__(self):
        super(PlotlyPlotsOffline, self).__init__()

    def show_canvas(self, canvas, filename=None, **kwargs):
        figure, _, _ = canvas
        if len(figure.data) == 0:
            # add mock data
            figure.append_trace(Scatter(x=[], y=[], name='', showlegend=False), 1, 1)
        from ..gpy_plot.plot_util import in_ipynb
        if in_ipynb():
            plotly.offline.init_notebook_mode(connected=True)
            return plotly.offline.iplot(figure, filename=filename, **kwargs)#self.current_states[hex(id(figure))]['filename'])
        else:
            return plotly.offline.plot(figure, filename=filename, **kwargs)


text:
%INCLUDE "Core_Includes.inc"
[BITS 16]
mov byte [bootDisk],DL
mov AX,0x7000
mov SS,AX
xor AX,AX
mov SP,0xFFFF
mov SI, loadMessage
call Print
mov SI,payLoadLocation
call Print

mov AX,[payLoadLocation]
sub AL,0x30
cmp AH,0x2F; Is the location in a valid format
je LocationChecked

InvalidLocation:
mov SI,errorLocationCheck
call Print
jmp hang

LocationChecked:
cmp AL,4
jge InvalidLocation
xor AH,AH
mov BX,AX
mov ebp,RBP,B
shl BX,4
add BX,0x7DBE
mov AX,[BX+4] ;load partition bx type
test AL,0xB; check for fat32
je PartitionChecked
mov SI,errorLocationCheck
call Print
PartitionChecked:
hang:
	cli
	hlt
	jmp hang

[SECTION .data]
bootDisk db 0x80
errorLocationCheck db "Invalid package location format",13,10,0
errorInvalidPartitionType db "Invalid partition type",13,10,0
loadMessage db 'Loading package ', 0
payLoadLocation db '0/payload.hbl',13,10,0
ALIGN 4
DiskPacket:
db 16
db 0
TransferSectors:
dw 1
PacketOffset:
dw 00
PacketSegment:
dw 0
StartLBA:
dd 0
UpperLBA:
dd 0
[SECTION .bss]
numberBuffer resd 1


text:
var nw = require('nw.gui');

var UI = new UIManager();
var dataManager = new DataManager();
var torrentManager = new TorrentManager();


text:
#ifndef SSTRING_H
#define SSTRING_H
#ifdef __cplusplus
extern "C" {
#endif

#include "saux/scommon.h"
#include "saux/sdata.h"
#include "saux/shash.h"
#include "svector.h"

/*
 * String base structure
 *
 * Observations:
 * - The small string container is implemented using struct SDataSmall,
 *   defined in sdata.h. The compatibility is possible because both
 *   struct SDataSmall and struct SDataFull share the header, where
 *   is defined if using the smaller container or the full one.
 * - Usage of struct SDataFlags type-specific elements:
 *	flag1: Unicode size is cached
 *	flag2: string has UTF-8 encoding errors (e.g. after some operation)
 *	flag3: string reference (built using ss_cref[a]() or ss_ref[a]())
 *	flag4: string reference with C terminator (built using ss_cref[a]())
 */

struct SString {
	struct SDataFull d;
	size_t unicode_size;
};

struct SStringRef {
	struct SString s;
	const char *cstr;
};

struct SStringRefRW {
	struct SString s;
	char *str;
};

#define SS_RANGE \
	(((size_t)-1) - S_MAX(sizeof(struct SString),	\
			      sizeof(struct SStringRef)))
#define EMPTY_SS                                                               \
	{                                                                      \
		EMPTY_SDataFull, 0                                             \
	}

/*
 * Types
 */

/* Opaque structures (accessors are provided) */
typedef struct SString srt_string;
typedef struct SStringRef srt_string_ref;

/*
 * Aux
 */

extern srt_string *ss_void;

/*
 * Variable argument functions
 */

#ifdef S_USE_VA_ARGS
#define ss_free(...) ss_free_aux(__VA_ARGS__, S_INVALID_PTR_VARG_TAIL)
#define ss_cpy_c(s, ...) ss_cpy_c_aux(s, __VA_ARGS__, S_INVALID_PTR_VARG_TAIL)
#define ss_cpy_w(s, ...) ss_cpy_w_aux(s, __VA_ARGS__, S_INVALID_PTR_VARG_TAIL)
#define ss_cat(s, ...) ss_cat_aux(s, __VA_ARGS__, S_INVALID_PTR_VARG_TAIL)
#define ss_cat_c(s, ...) ss_cat_c_aux(s, __VA_ARGS__, S_INVALID_PTR_VARG_TAIL)
#define ss_cat_w(s, ...) ss_cat_w_aux(s, __VA_ARGS__, S_INVALID_PTR_VARG_TAIL)
#else
#define ss_free(s) ss_free_aux(s, S_INVALID_PTR_VARG_TAIL)
#define ss_cpy_c(s, a) ss_cpy_c_aux(s, a, S_INVALID_PTR_VARG_TAIL)
#define ss_cpy_w(s, a) ss_cpy_w_aux(s, a, S_INVALID_PTR_VARG_TAIL)
#define ss_cat(s, a) ss_cat_aux(s, a, S_INVALID_PTR_VARG_TAIL)
#define ss_cat_c(s, a) ss_cat_c_aux(s, a, S_INVALID_PTR_VARG_TAIL)
#define ss_cat_w(s, a) ss_cat_w_aux(s, a, S_INVALID_PTR_VARG_TAIL)
#endif

/*
 * Generated from template
 */

SD_BUILDFUNCS_DYN(ss, srt_string, 1)

size_t ss_grow(srt_string **c, size_t extra_elems);
size_t ss_reserve(srt_string **c, size_t max_elems);

/*
#API: |Free one or more strings (heap)|string;more strings (optional)|-|O(1)|1;2|
void ss_free(srt_string **s, ...)

#API: |Reserve space for extra elements (relative to current string size)|string;number of extra elements|extra size allocated|O(1)|1;2|
size_t ss_grow(srt_string **s, size_t extra_elems)

#API: |Reserve space for at least N bytes (absolute reserve)|string;absolute element reserve|reserved elements|O(1)|1;2|
size_t ss_reserve(srt_string **s, size_t max_elems)

#API: |Free unused space|string|same string (optional usage)|O(1)|1;2|
srt_string *ss_shrink(srt_string **s)

#API: |Get string size|string|string bytes used in UTF8 format|O(1)|1;2|
size_t ss_size(const srt_string *s)

#NOTAPI: |Set string size (bytes used in UTF8 format)|string;new size|-|O(1)|1;2|
void ss_set_size(srt_string *s, size_t s)

#API: |Equivalent to ss_size|string|Number of bytes (UTF-8 string length)|O(1)|1;2|
size_t ss_len(const srt_string *s)

#API: |Get allocated space|vector|current allocated space (in bytes)|O(1)|1;2|
size_t ss_capacity(const srt_string *s);

#API: |Get preallocated space left|string|allocated space left (in bytes)|O(1)|1;2|
size_t ss_capacity_left(const srt_string *s);

#API: |Tells if a string is empty (zero elements)|string|S_TRUE: empty string; S_FALSE: not empty|O(1)|1;2|
srt_bool ss_empty(const srt_string *s)

#API: |Get string buffer access|string|pointer to the insternal string buffer (UTF-8 or raw data)|O(1)|1;2|
char *ss_get_buffer(srt_string *s);

#API: |Get string buffer access (read-only)|string|pointer to the internal string buffer (UTF-8 or raw data)|O(1)|1;2|
const char *ss_get_buffer_r(const srt_string *s);

#API: |Get string buffer size|string|Number of bytes in use for storing all string characters|O(1)|1;2|
size_t ss_get_buffer_size(const srt_string *v);
*/

/*
 * Allocation
 */

/* #API: |Allocate string (heap)|space preallocated to store n elements|allocated string|O(1)|1;2| */
srt_string *ss_alloc(size_t initial_heap_reserve);

/*
#API: |Allocate string (stack)|space preallocated to store n elements|allocated string|O(1)|1;2|
srt_string *ss_alloca(size_t max_size)
 */
/*
 * +1 extra byte allocated for the \0 required by ss_to_c()
 */
#define ss_alloca(max_size)                                                    \
	ss_alloc_into_ext_buf(s_alloca(sd_alloc_size_raw(sizeof(srt_string),   \
							 1, max_size, S_TRUE)  \
				       + 1),                                   \
			      max_size)

srt_string *ss_alloc_into_ext_buf(void *buf, size_t max_size);

/* #API: |Create a reference from C string. This is intended for avoid duplicating C strings when working with srt_string functions|string reference to be built (can be on heap or stack, it is a small structure); input C string (0 terminated ASCII or UTF-8 string)|srt_string string derived from srt_string_ref|O(1)|1;2| */
const srt_string *ss_cref(srt_string_ref *s_ref, const char *c_str);

/* #API: |Create a reference from C string using implicit stack allocation for the reference handling (be cafeful not using this inside a loop -for loops you can e.g. use ss_build_ref() instead of this, using a local variable allocated in the stack for the reference-)|input C string (0 terminated ASCII or UTF-8 string)|srt_string string derived from srt_string_ref|O(1)|1;2|
const srt_string *ss_crefa(const char *c_str)
*/
#define ss_crefa(c_str)                                                        \
	ss_cref((srt_string_ref *)s_alloca(sizeof(srt_string_ref)), c_str)

/* #API: |Create a reference from raw data, i.e. not assuming is 0 terminated. WARNING: when using raw references when calling ss_to_c() will return a "" string (safety)), so, if you need a reference to the internal raw buffer use ss_get_buffer_r() instead|string reference to be built (can be on heap or stack, it is a small structure);input raw data buffer;input buffer size (bytes)|srt_string string derived from srt_string_ref|O(1)|1;2| */
const srt_string *ss_ref_buf(srt_string_ref *s_ref, const char *buf, size_t buf_size);

/* #API: |Create a reference from raw data, i.e. not 0 terminated, using implicit stack allocation for the reference handling (be cafeful not using this inside a loop -for loops you can e.g. use ss_build_ref() instead of this, using a local variable allocated in the stack for the reference-). WARNING: when using raw references when calling ss_to_c() will return a "" string (safety), so, if you need a reference to the internal raw buffer use ss_get_buffer_r() instead|input raw data buffer;input buffer size (bytes)|srt_string string derived from srt_string_ref|O(1)|1;2|
const srt_string *ss_refa_buf(const char *buf, size_t buf_size)
*/
#define ss_refa_buf(buf, buf_size)                                             \
	ss_ref_buf((srt_string_ref *)s_alloca(sizeof(srt_string_ref)), buf,    \
		   buf_size)

/* #API: |Get string reference from string reference container|string reference container|srt_string string derived from srt_string_ref|O(1)|1;2| */
S_INLINE const srt_string *ss_ref(const srt_string_ref *s_ref)
{
	RETURN_IF(!s_ref, ss_void);
	return &s_ref->s;
}

/*
 * Accessors
 */

/* #API: |Random access to byte|string; offset (bytes)|0..255: byte retrieved ok; < 0: out of range|O(1)|1;2| */
int ss_at(const srt_string *s, size_t off);

/* #API: |String length (Unicode)|string|number of Unicode characters|O(1) if cached, O(n) if not previously computed|1;2| */
size_t ss_len_u(const srt_string *s);

/* #API: |Get the maximum possible string size|string|max string size (bytes)|O(1)|1;2| */
size_t ss_max(const srt_string *s);

/* #NOTAPI: |Normalize offset: cut offset if bigger than string size|string; offset|Normalized offset (range: 0..string size)|O(1)|1;2|
size_t ss_real_off(const srt_string *s, size_t off);
*/

/* #API: |Check if string had allocation errors|string|S_TRUE: has errors; S_FALSE: no errors|O(1)|1;2|
srt_bool ss_alloc_errors(const srt_string *s);
*/

/* #API: |Check if string had UTF8 encoding errors|string|S_TRUE: has errors; S_FALSE: no errors|O(1)|1;2| */
srt_bool ss_encoding_errors(const srt_string *s);

/* #API: |Clear allocation/encoding error flags|string|-|O(1)|1;2| */
void ss_clear_errors(srt_string *s);

/*
 * Allocation from other sources: "dup"
 */

/* #API: |Duplicate string|string|Output result|O(n)|1;2| */
srt_string *ss_dup(const srt_string *src);

/* #API: |Duplicate from substring|string;byte offset;number of bytes|output result|O(n)|1;2| */
srt_string *ss_dup_substr(const srt_string *src, size_t off, size_t n);

/* #API: |Duplicate from substring|string;character offset;number of characters|output result|O(n)|1;2| */
srt_string *ss_dup_substr_u(const srt_string *src, size_t char_off, size_t n);

/* #API: |Duplicate from C string|C string buffer;number of bytes|output result|O(n)|1;2| */
srt_string *ss_dup_cn(const char *src, size_t src_size);

/* #API: |Duplicate from C String (ASCII-z)|C string|output result|O(n)|1;2| */
srt_string *ss_dup_c(const char *src);

/* #API: |Duplicate from Unicode "wide char" string (UTF-16 for 16-bit wchar_t, and UTF-32 for 32-bit wchar_t)|"wide char" string; number of characters|output result|O(n)|1;2| */
srt_string *ss_dup_wn(const wchar_t *src, size_t src_size);

/* #API: |Duplicate from "wide char" Unicode string (UTF-16 for 16-bit wchar_t, and UTF-32 for 32-bit wchar_t)|"wide char" string|output result|O(n)|1;2| */
srt_string *ss_dup_w(const wchar_t *src);

/* #API: |Duplicate from integer|integer|output result|O(1)|1;2| */
srt_string *ss_dup_int(int64_t num);

/* #API: |Duplicate string with lowercase conversion|string|output result|O(n)|1;2| */
srt_string *ss_dup_tolower(const srt_string *src);

/* #API: |Duplicate string with uppercase conversion|string|output result|O(n)|1;2| */
srt_string *ss_dup_toupper(const srt_string *src);

/* #API: |Duplicate string with base64 encoding|string|output result|O(n)|1;2| */
srt_string *ss_dup_enc_b64(const srt_string *src);

/* #API: |Duplicate string with hex encoding|string|output result|O(n)|1;2| */
srt_string *ss_dup_enc_hex(const srt_string *src);

/* #API: |Duplicate string with hex encoding|string|output result|O(n)|1;2| */
srt_string *ss_dup_enc_HEX(const srt_string *src);

/* #API: |Duplicate string with LZ encoding|string|output result|O(n)|1;2| */
srt_string *ss_dup_enc_lz(const srt_string *src);

/* #API: |Duplicate string with LZ encoding (high compession)|string|output result|O(n)|1;2| */
srt_string *ss_dup_enc_lzh(const srt_string *src);

/* #API: |Duplicate string with JSON escape encoding|string|output result|O(n)|1;2| */
srt_string *ss_dup_enc_esc_json(const srt_string *src);

/* #API: |Duplicate string with XML escape encoding|string|output result|O(n)|1;2| */
srt_string *ss_dup_enc_esc_xml(const srt_string *src);

/* #API: |Duplicate string with URL escape encoding|string|output result|O(n)|1;2| */
srt_string *ss_dup_enc_esc_url(const srt_string *src);

/* #API: |Duplicate string escaping " as ""|string|output result|O(n)|1;2| */
srt_string *ss_dup_enc_esc_dquote(const srt_string *src);

/* #API: |Duplicate string escaping ' as ''|string|output result|O(n)|1;2| */
srt_string *ss_dup_enc_esc_squote(const srt_string *src);

/* #API: |Duplicate string with base64 decoding|string|output result|O(n)|1;2| */
srt_string *ss_dup_dec_b64(const srt_string *src);

/* #API: |Duplicate string with hex decoding|string|output result|O(n)|1;2| */
srt_string *ss_dup_dec_hex(const srt_string *src);

/* #API: |Duplicate string with LZ decoding|string|output result|O(n)|1;2| */
srt_string *ss_dup_dec_lz(const srt_string *src);

/* #API: |Duplicate string with JSON escape decoding|string|output result|O(n)|1;2| */
srt_string *ss_dup_dec_esc_json(const srt_string *src);

/* #API: |Duplicate string with XML escape decoding|string|output result|O(n)|1;2| */
srt_string *ss_dup_dec_esc_xml(const srt_string *src);

/* #API: |Duplicate string with URL escape decoding|string|output result|O(n)|1;2| */
srt_string *ss_dup_dec_esc_url(const srt_string *src);

/* #API: |Duplicate string unescaping "" as "|string|output result|O(n)|1;2| */
srt_string *ss_dup_dec_esc_dquote(const srt_string *src);

/* #API: |Duplicate string unescaping '' as '|string|output result|O(n)|1;2| */
srt_string *ss_dup_dec_esc_squote(const srt_string *src);

/* #API: |Duplicate from string erasing portion from input|string;byte offset;number of bytes|output result|O(n)|1;2| */
srt_string *ss_dup_erase(const srt_string *src, size_t off, size_t n);

/* #API: |Duplicate from Unicode "wide char" string erasing portion from input|string;character offset;number of characters|output result|O(n)|1;2| */
srt_string *ss_dup_erase_u(const srt_string *src, size_t char_off, size_t n);

/* #API: |Duplicate and apply replace operation after offset|string; offset (bytes); needle; needle replacement|output result|O(n)|1;2| */
srt_string *ss_dup_replace(const srt_string *src, size_t off, const srt_string *s1, const srt_string *s2);

/* #API: |Duplicate and resize (byte addressing)|string; new size (bytes); fill byte|output result|O(n)|1;2| */
srt_string *ss_dup_resize(const srt_string *src, size_t n, char fill_byte);

/* #API: |Duplicate and resize (Unicode addressing)|string; new size (characters); fill character|output result|O(n)|1;2| */
srt_string *ss_dup_resize_u(srt_string *src, size_t n, int fill_char);

/* #API: |Duplicate and trim string|string|output result|O(n)|1;2| */
srt_string *ss_dup_trim(const srt_string *src);

/* #API: |Duplicate and apply trim at left side|string|output result|O(n)|1;2| */
srt_string *ss_dup_ltrim(const srt_string *src);

/* #API: |Duplicate and apply trim at right side|string|output result|O(n)|1;2| */
srt_string *ss_dup_rtrim(const srt_string *src);

/* #API: |Duplicate from printf formatting|printf space (bytes); printf format; optional printf parameters|output result|O(n)|1;2| */
srt_string *ss_dup_printf(size_t size, const char *fmt, ...);

/* #API: |Duplicate from printf_va formatting|printf_va space (bytes); printf format; variable argument reference|output result|O(n)|1;2| */
srt_string *ss_dup_printf_va(size_t size, const char *fmt, va_list ap);

/* #API: |Duplicate string from character|Unicode character|output result|O(1)|1;2| */
srt_string *ss_dup_char(int c);

/* #API: |Duplicate from reading from file handle|file handle; read max size (in bytes)|output result|O(n): WARNING: involves external file I/O|1;2| */
srt_string *ss_dup_read(FILE *handle, size_t max_bytes);

/*
 * Assignment
 */

/* #API: |Overwrite string with a string copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with a substring copy (byte mode)|output string; input string; input string start offset (bytes); number of bytes to be copied|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_substr(srt_string **s, const srt_string *src, size_t off, size_t n);

/* #API: |Overwrite string with a substring copy (character mode)|output string; input string; input string start offset (characters); number of characters to be copied|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_substr_u(srt_string **s, const srt_string *src, size_t char_off, size_t n);

/* #API: |Overwrite string with C string copy (strict aliasing is assumed)|output string; input string; input string bytes|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_cn(srt_string **s, const char *src, size_t src_size);

/*
#API: |Overwrite string with multiple C string copy (strict aliasing is assumed)|output string; input strings (one or more C strings)|output string reference (optional usage)|O(n)|1;2|
srt_string *ss_cpy_c(srt_string **s, ...)
*/
srt_string *ss_cpy_c_aux(srt_string **s, const char *s1, ...);

/* #API: |Overwrite string with "wide char" Unicode string copy (strict aliasing is assumed) (UTF-16 for 16-bit wchar_t, and UTF-32 for 32-bit wchar_t)|output string; input string ("wide char" Unicode); input string number of characters|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_wn(srt_string **s, const wchar_t *src, size_t src_size);

/* #API: |Overwrite string with integer to string copy|output string; integer (any signed integer size)|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_int(srt_string **s, int64_t num);

/* #API: |Overwrite string with input string lowercase conversion copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_tolower(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string uppercase conversion copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_toupper(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string base64 encoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_enc_b64(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string hexadecimal (lowercase) encoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_enc_hex(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string hexadecimal (uppercase) encoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_enc_HEX(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string LZ encoded copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_enc_lz(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string LZ encoded copy (high compression)|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_enc_lzh(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string JSON escape encoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_enc_esc_json(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string XML escape encoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_enc_esc_xml(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string URL escape encoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_enc_esc_url(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string escaping " as ""|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_enc_esc_dquote(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string escaping ' as ''|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_enc_esc_squote(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string base64 decoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_dec_b64(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string hexadecimal (lowercase) decoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_dec_hex(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string LZ decoded copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_dec_lz(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string JSON escape decoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_dec_esc_json(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string XML escape decoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_dec_esc_xml(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string URL escape decoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_dec_esc_url(srt_string **s, const srt_string *src);

/* #API: |Overwrite string unescaping "" as "|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_dec_esc_dquote(srt_string **s, const srt_string *src);

/* #API: |Overwrite string unescaping '' as '|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_dec_esc_squote(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string copy applying a erase operation (byte/UTF-8 mode)|output string; input string; input string erase start byte offset; number of bytes to erase|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_erase(srt_string **s, const srt_string *src, size_t off, size_t n);

/* #API: |Overwrite string with input string copy applying a erase operation (character mode)|output string; input string; input string erase start character offset; number of characters to erase|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_erase_u(srt_string **s, const srt_string *src, size_t char_off, size_t n);

/* #API: |Overwrite string with input string plus replace operation|output string; input string; offset for starting the replace operation (0 for the whole input string); pattern to be replaced; patter replacement|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_replace(srt_string **s, const srt_string *src, size_t off, const srt_string *s1, const srt_string *s2);

/* #API: |Overwrite string with input string copy plus resize operation (byte/UTF-8 mode)|output string; input string; number of bytes of input string; byte for refill|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_resize(srt_string **s, const srt_string *src, size_t n, char fill_byte);

/* #API: |Overwrite string with input string copy plus resize operation (byte/UTF-8 mode)|output string; input string; number of bytes of input string; byte for refill|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_resize_u(srt_string **s, srt_string *src, size_t n, int fill_char);

/* #API: |Overwrite string with input string plus trim (left and right) space removal operation|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_trim(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string plus left-trim space removal operation|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_ltrim(srt_string **s, const srt_string *src);

/* #API: |Overwrite string with input string plus right-trim space removal operation|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_rtrim(srt_string **s, const srt_string *src);

/*
#API: |Overwrite string with multiple C "wide char" Unicode string copy (strict aliasing is assumed) (UTF-16 for 16-bit wchar_t, and UTF-32 for 32-bit wchar_t)|output string; input strings (one or more C "wide char" strings)|output string reference (optional usage)|O(n)|1;2|
srt_string *ss_cpy_w(srt_string **s, ...)
*/
srt_string *ss_cpy_w_aux(srt_string **s, const wchar_t *s1, ...);

/* #API: |Overwrite string with printf operation|output string; printf output size (bytes); printf format; printf parameters|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_printf(srt_string **s, size_t size, const char *fmt, ...);

/* #API: |Overwrite string with printf_va operation|output string; printf output size (bytes); printf format; printf_va parameters|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_printf_va(srt_string **s, size_t size, const char *fmt, va_list ap);

/* #API: |Overwrite string with a string with just one character|output string; input character|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cpy_char(srt_string **s, int c);

/* #API: |Read from file handle|output string; file handle; read max size (in bytes)|output result|O(n): WARNING: involves external file I/O|1;2| */
srt_string *ss_cpy_read(srt_string **s, FILE *handle, size_t max_bytes);

/*
 * Append
 */

/*
#API: |Concatenate to string one or more strings|output string; input string; optional input strings|output string reference (optional usage)|O(n)|1;2|
srt_string *ss_cat(srt_string **s, const srt_string *s1, ...)
*/
srt_string *ss_cat_aux(srt_string **s, const srt_string *s1, ...);

/* #API: |Concatenate substring (byte/UTF-8 mode)|output string; input string; input string substring byte offset; input string substring size (bytes)|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_substr(srt_string **s, const srt_string *src, size_t off, size_t n);

/* #API: |Concatenate substring (Unicode character mode)|output string; input string; input substring character offset; input string substring size (characters)|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_substr_u(srt_string **s, const srt_string *src, size_t char_off, size_t n);

/* #API: |Concatenate C substring (byte/UTF-8 mode)|output string; input C string; input string size (bytes)|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_cn(srt_string **s, const char *src, size_t src_size);

/*
#API: |Concatenate multiple C strings (byte/UTF-8 mode)|output string; input string; optional input strings|output string reference (optional usage)|O(n)|1;2|
srt_string *ss_cat_c(srt_string **s, const char *s1, ...)
*/
srt_string *ss_cat_c_aux(srt_string **s, const char *s1, ...);

/*
#API: |Concatenate multiple "wide char" C strings (Unicode character mode)|output string; input "wide char" C string (UTF-16 for 16-bit wchar_t, and UTF-32 for 32-bit wchar_t); optional input "wide char" C strings|output string reference (optional usage)|O(n)|1;2|
srt_string *ss_cat_w(srt_string **s, const char *s1, ...)
*/
srt_string *ss_cat_w_aux(srt_string **s, const wchar_t *s1, ...);

/* #API: |Concatenate "wide char" C substring (Unicode character mode)|output string; input "wide char" C string; input string size (characters) (UTF-16 for 16-bit wchar_t, and UTF-32 for 32-bit wchar_t)|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_wn(srt_string **s, const wchar_t *src, size_t src_size);

/* #API: |Concatenate integer|output string; integer (any signed integer size)|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_int(srt_string **s, int64_t num);

/* #API: |Concatenate "lowercased" string|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_tolower(srt_string **s, const srt_string *src);

/* #API: |Concatenate "uppercased" string|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_toupper(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string base64 encoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_enc_b64(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string hexadecimal (lowercase) encoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_enc_hex(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string hexadecimal (uppercase) encoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_enc_HEX(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string LZ encoded copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_enc_lz(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string LZ encoded copy (high compression)|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_enc_lzh(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string JSON escape encoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_enc_esc_json(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string XML escape encoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_enc_esc_xml(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string URL escape encoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_enc_esc_url(srt_string **s, const srt_string *src);

/* #API: |Concatenate string escaping " as ""|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_enc_esc_dquote(srt_string **s, const srt_string *src);

/* #API: |Concatenate string escaping ' as ''|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_enc_esc_squote(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string base64 decoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_dec_b64(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string hexadecimal (lowercase) decoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_dec_hex(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string LZ decoded copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_dec_lz(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string JSON escape decoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_dec_esc_json(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string XML escape decoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_dec_esc_xml(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string URL escape decoding copy|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_dec_esc_url(srt_string **s, const srt_string *src);

/* #API: |Concatenate string unescaping "" as "|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_dec_esc_dquote(srt_string **s, const srt_string *src);

/* #API: |Concatenate string unescaping '' as '|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_dec_esc_squote(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with erase operation (byte/UTF-8 mode)|output string; input string; input string byte offset for erase start; erase count (bytes)|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_erase(srt_string **s, const srt_string *src, size_t off, size_t n);

/* #API: |Concatenate string with erase operation (Unicode character mode)|output string; input string; input character string offset for erase start; erase count (characters)|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_erase_u(srt_string **s, const srt_string *src, size_t char_off, size_t n);

/* #API: |Concatenate string with replace operation|output string; input string; offset for starting the replace operation (0 for the whole input string); pattern to be replaced; patter replacement|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_replace(srt_string **s, const srt_string *src, size_t off, const srt_string *s1, const srt_string *s2);

/* #API: |Concatenate string with input string copy plus resize operation (byte/UTF-8 mode)|output string; input string; number of bytes of input string; byte for refill|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_resize(srt_string **s, const srt_string *src, size_t n, char fill_byte);

/* #API: |Concatenate string with input string copy plus resize operation (Unicode character)|output string; input string; number of characters of input string; character for refill|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_resize_u(srt_string **s, srt_string *src, size_t n, int fill_char);

/* #API: |Concatenate string with input string plus trim (left and right) space removal operation|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_trim(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string plus left-trim space removal operation|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_ltrim(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with input string plus right-trim space removal operation|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_rtrim(srt_string **s, const srt_string *src);

/* #API: |Concatenate string with printf operation|output string; printf output size (bytes); printf format; printf parameters|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_printf(srt_string **s, size_t size, const char *fmt, ...);

/* #API: |Concatenate string with printf_va operation|output string; printf output size (bytes); printf format; printf_va parameters|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_cat_printf_va(srt_string **s, size_t size, const char *fmt, va_list ap);

/* #API: |Concatenate string with a string with just one character|output string; input character|output string reference (optional usage)|O(1)|1;2| */
srt_string *ss_cat_char(srt_string **s, int c);

/* #API: |Cat data read from file handle|output string; file handle; read max size (in bytes)|output result|O(n): WARNING: involves external file I/O|1;2| */
srt_string *ss_cat_read(srt_string **s, FILE *handle, size_t max_bytes);

/*
 * Transformation
 */

/* #API: |Convert string to lowercase|output string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_tolower(srt_string **s);

/* #API: |Convert string to uppercase|output string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_toupper(srt_string **s);

/* #API: |Convert to base64|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_enc_b64(srt_string **s, const srt_string *src);

/* #API: |Convert to hexadecimal (lowercase)|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_enc_hex(srt_string **s, const srt_string *src);

/* #API: |Convert to hexadecimal (uppercase)|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_enc_HEX(srt_string **s, const srt_string *src);

/* #API: |Convert to LZ|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_enc_lz(srt_string **s, const srt_string *src);

/* #API: |Convert to LZ (high compression)|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_enc_lzh(srt_string **s, const srt_string *src);

/* #API: |Convert/escape for JSON encoding|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_enc_esc_json(srt_string **s, const srt_string *src);

/* #API: |Convert/escape for XML encoding|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_enc_esc_xml(srt_string **s, const srt_string *src);

/* #API: |Convert/escape for URL encoding|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_enc_esc_url(srt_string **s, const srt_string *src);

/* #API: |Convert/escape escaping " as ""|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_enc_esc_dquote(srt_string **s, const srt_string *src);

/* #API: |Convert/escape escaping ' as ''|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_enc_esc_squote(srt_string **s, const srt_string *src);

/* #API: |Decode from base64|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_dec_b64(srt_string **s, const srt_string *src);

/* #API: |Decode from hexadecimal (lowercase)|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_dec_hex(srt_string **s, const srt_string *src);

/* #API: |Decode from LZ|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_dec_lz(srt_string **s, const srt_string *src);

/* #API: |Unescape from JSON encoding|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_dec_esc_json(srt_string **s, const srt_string *src);

/* #API: |Unescape from XML encoding|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_dec_esc_xml(srt_string **s, const srt_string *src);

/* #API: |Unescape from URL encoding|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_dec_esc_url(srt_string **s, const srt_string *src);

/* #API: |Unescape "" as "|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_dec_esc_dquote(srt_string **s, const srt_string *src);

/* #API: |Unescape '' as '|output string; input string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_dec_esc_squote(srt_string **s, const srt_string *src);

/* #API: |Set Turkish mode locale (related to case conversion)|S_TRUE: enable turkish mode, S_FALSE: disable|S_TRUE: conversion functions OK, S_FALSE: error (missing functions)|O(1)|1;2| */
srt_bool ss_set_turkish_mode(srt_bool enable_turkish_mode);

/* #API: |Clear string|output string|output string reference (optional usage)|O(n)|1;2| */
void ss_clear(srt_string *s);

/* #API: |Check and fix string (if input string is NULL, replaces it with a empty valid string)|output string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_check(srt_string **s);

/* #API: |Erase portion of a string (byte/UTF-8 mode)|input/output string; byte offset where to start the cut; number of bytes to be cut|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_erase(srt_string **s, size_t off, size_t n);

/* #API: |Erase portion of a string (Unicode character mode)|input/output string; character offset where to start the cut; number of characters to be cut|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_erase_u(srt_string **s, size_t char_off, size_t n);

/* #API: |Replace into string|input/output string; byte offset where to start applying the replace operation; target pattern; replacement pattern|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_replace(srt_string **s, size_t off, const srt_string *s1, const srt_string *s2);

/* #API: |Resize string (byte/UTF-8 mode)|input/output string; new size in bytes; fill byte|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_resize(srt_string **s, size_t n, char fill_byte);

/* #API: |Resize string (Unicode character mode)|input/output string; new size in characters; fill character|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_resize_u(srt_string **s, size_t n, int fill_char);

/* #API: |Remove spaces from left and right side|input/output string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_trim(srt_string **s);

/* #API: |Remove spaces from left side|input/output string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_ltrim(srt_string **s);

/* #API: |Remove spaces from right side|input/output string|output string reference (optional usage)|O(n)|1;2| */
srt_string *ss_rtrim(srt_string **s);

/*
 * Export
 */

/* #API: |Give a C-compatible zero-ended string reference (byte/UTF-8 mode)|input string|Zero-ended C compatible string reference (UTF-8)|O(1)|1;2| */
const char *ss_to_c(const srt_string *s);

/* #API: |Give a C-compatible zero-ended string reference ("wide char" Unicode mode) (UTF-16 for 16-bit wchar_t, and UTF-32 for 32-bit wchar_t)|input string; output string buffer; output string max characters; output string size|Zero'ended C compatible string reference ("wide char" Unicode mode)|O(n)|1;2| */
const wchar_t *ss_to_w(const srt_string *s, wchar_t *o, size_t nmax, size_t *n);

/*
 * Search
 */

/* #API: |Find substring into string|input string; search offset start; target string|Offset location if found, S_NPOS if not found|O(n)|1;2| */
size_t ss_find(const srt_string *s, size_t off, const srt_string *tgt);

/* #API: |Find blank (9, 10, 13, 32) character into string|input string; search offset start|Offset location if found, S_NPOS if not found|O(n)|1;2| */
size_t ss_findb(const srt_string *s, size_t off);

/* #API: |Find first byte between a min and a max value|input string; search offset start; target byte mininum value; target byte maximum value|Offset location if found, S_NPOS if not found|O(n)|1;2| */
size_t ss_findcx(const srt_string *s, size_t off, uint8_t c_min, uint8_t c_max);

/* #API: |Find byte into string|input string; search offset start; target character|Offset location if found, S_NPOS if not found|O(n)|1;2| */
size_t ss_findc(const srt_string *s, size_t off, char c);

/* #API: |Find Unicode character into string|input string; search offset start; target character|Offset location if found, S_NPOS if not found|O(n)|1;2| */
size_t ss_findu(const srt_string *s, size_t off, int c);

/* #API: |Find non-blank (9, 10, 13, 32) character into string|input string; search offset start|Offset location if found, S_NPOS if not found|O(n)|1;2| */
size_t ss_findnb(const srt_string *s, size_t off);

/* #API: |Find n bytes|input string; search offset start; target buffer; target buffer size (bytes)|Offset location if found, S_NPOS if not found|O(n)|1;2| */
size_t ss_find_cn(const srt_string *s, size_t off, const char *t, size_t ts);

/* #API: |Find substring into string (in range)|input string; search offset start; max offset (S_NPOS for end of string); target string|Offset location if found, S_NPOS if not found|O(n)|1;2| */
size_t ss_findr(const srt_string *s, size_t off, size_t max_off, const srt_string *tgt);

/* #API: |Find blank (9, 10, 13, 32) character into string (in range)|input string; search offset start; max offset (S_NPOS for end of string)|Offset location if found, S_NPOS if not found|O(n)|1;2| */
size_t ss_findrb(const srt_string *s, size_t off, size_t max_off);

/* #API: |Find first byte between a min and a max value|input string; search offset start; max offset (S_NPOS for end of string); target byte mininum value; target byte maximum value|Offset location if found, S_NPOS if not found|O(n)|1;2| */
size_t ss_findrcx(const srt_string *s, size_t off, size_t max_off, uint8_t c_min, uint8_t c_max);

/* #API: |Find byte into string (in range)|input string; search offset start; max offset (S_NPOS for end of string); target character|Offset location if found, S_NPOS if not found|O(n)|1;2| */
size_t ss_findrc(const srt_string *s, size_t off, size_t max_off, char c);

/* #API: |Find Unicode character into string (in range)|input string; search offset start; max offset (S_NPOS for end of string); target character|Offset location if found, S_NPOS if not found|O(n)|1;2| */
size_t ss_findru(const srt_string *s, size_t off, size_t max_off, int c);

/* #API: |Find non-blank (9, 10, 13, 32) character into string (in range)|input string; search offset start; max offset (S_NPOS for end of string)|Offset location if found, S_NPOS if not found|O(n)|1;2| */
size_t ss_findrnb(const srt_string *s, size_t off, size_t max_off);

/* #API: |Find n bytes|input string; search offset start; max offset (S_NPOS for end of string); target buffer; target buffer size (bytes)|Offset location if found, S_NPOS if not found|O(n)|1;2| */
size_t ss_findr_cn(const srt_string *s, size_t off, size_t max_off, const char *t, size_t ts);

/* #API: |Split/tokenize: break string by separators|input string; separator; output substring references; number of output substrings|Number of elements|O(n)|1;2| */
size_t ss_split(const srt_string *src, const srt_string *separator, srt_string_ref out_substrings[], size_t max_refs);

/*
 * Compare
 */

/* #API: |String compare|string 1; string 2|0: s1 = s2; < 0: s1 lower than s2; > 0: s1 greater than s2|O(n)|1;2| */
int ss_cmp(const srt_string *s1, const srt_string *s2);

/* #API: |Case-insensitive string compare|string 1; string 2|0: s1 = s2; < 0: s1 lower than s2; > 0: s1 greater than s2|O(n)|1;2| */
int ss_cmpi(const srt_string *s1, const srt_string *s2);

/* #API: |Partial string compare|string 1; string 1 offset (bytes; string 2; comparison size (bytes)|0: s1 = s2; < 0: s1 lower than s2; > 0: s1 greater than s2|O(n)|1;2| */
int ss_ncmp(const srt_string *s1, size_t s1off, const srt_string *s2, size_t n);

/* #API: |Partial case insensitive string compare|string 1; string 1 offset (bytes; string 2; comparison size (bytes)|0: s1 = s2; < 0: s1 lower than s2; > 0: s1 greater than s2|O(n)|1;2| */
int ss_ncmpi(const srt_string *s1, size_t s1off, const srt_string *s2, size_t n);

/*
 * snprintf equivalent
 */

/* #API: |printf operation on string|output string; printf max output size -including the 0 terminator- (bytes); printf "format";printf "format" parameters|output string reference (optional usage)|O(n)|1;2| */
int ss_printf(srt_string **s, size_t size, const char *fmt, ...);

/*
 * Unicode character I/O
 */

/* #API: |Get next Unicode character|input string; iterator|Output character, or EOF if no more characters left|O(1)|1;2| */
int ss_getchar(const srt_string *s, size_t *autoinc_off);

/* #API: |Append Unicode character to string|output string; Unicode character|Echo of the output character or EOF if overflow error|O(1)|1;2| */
int ss_putchar(srt_string **s, int c);

/* #API: |Extract last character from string|input/output string|Extracted character if OK, EOF if empty|O(1)|1;2| */
int ss_popchar(srt_string **s);

/*
 * I/O
 */

/* #API: |Read from file handle|output string; file handle; read max size (in bytes)|output result|O(n): WARNING: involves external file I/O|1;2| */
ssize_t ss_read(srt_string **s, FILE *handle, size_t max_bytes);

/* #API: |Write to file|output file; string; string offset; bytes to write|written bytes < 0: error|O(n): WARNING: involves external file I/O|1;2| */
ssize_t ss_write(FILE *handle, const srt_string *s, size_t offset, size_t bytes);

/*
 * Hashing
 */

/* #API: |String CRC-32 checksum|string|32-bit hash|O(n)|1;2| */
uint32_t ss_crc32(const srt_string *s);

/* #API: |CRC-32 checksum for substring|string; CRC resulting from previous chained CRC calls (use S_CRC32_INIT for the first call); start offset; end offset|32-bit hash|O(n)|1;2| */
uint32_t ss_crc32r(const srt_string *s, uint32_t crc, size_t off1, size_t off2);

/* #API: |String Adler32 checksum|string|32-bit hash|O(n)|1;2| */
uint32_t ss_adler32(const srt_string *s);

/* #API: |Adler32 checksum for substring|string; Adler32 resulting from previous chained Adler32 calls (use S_ADLER32_INIT for the first call); start offset; end offset|32-bit hash|O(n)|1;2| */
uint32_t ss_adler32r(const srt_string *s, uint32_t adler, size_t off1, size_t off2);

/* #API: |String FNV-1 checksum|string|32-bit hash|O(n)|1;2| */
uint32_t ss_fnv1(const srt_string *s);

/* #API: |FNV-1 checksum for substring|string; FNV-1 resulting from previous chained FNV-1 calls (use S_FNV1_INIT for the first call); start offset; end offset|32-bit hash|O(n)|1;2| */
uint32_t ss_fnv1r(const srt_string *s, uint32_t fnv, size_t off1, size_t off2);

/* #API: |String FNV-1A checksum|string|32-bit hash|O(n)|1;2| */
uint32_t ss_fnv1a(const srt_string *s);

/* #API: |FNV-1A checksum for substring|string; FNV resulting from previous chained FNV-1A calls (use S_FNV1_INIT for the first call); start offset; end offset|32-bit hash|O(n)|1;2| */
uint32_t ss_fnv1ar(const srt_string *s, uint32_t fnv, size_t off1, size_t off2);

/* #API: |String MurmurHash3-32 checksum|string|32-bit hash|O(n)|1;2| */
uint32_t ss_mh3_32(const srt_string *s);

/* #API: |MurmurHash3-32 checksum for substring|string; MH3-32 accumulator from previous chained MH3-32 calls (use S_MH3_32_INIT for the first call); start offset; end offset|32-bit hash|O(n)|1;2| */
uint32_t ss_mh3_32r(const srt_string *s, uint32_t acc, size_t off1, size_t off2);

/*
 * Inlined functions
 */

S_INLINE srt_bool ss_is_ref(const srt_string *s)
{
	return s && s->d.f.flag3 != 0 ? S_TRUE : S_FALSE;
}

S_INLINE srt_bool ss_is_cref(const srt_string *s)
{
	return s && s->d.f.flag4 != 0 ? S_TRUE : S_FALSE;
}

S_INLINE char *ss_get_buffer(srt_string *s)
{
	/*
	 * Constness breaking will be addressed once the ss_to_c gets fixed.
	 */
	return ss_is_ref(s) ? ((struct SStringRefRW *)s)->str
			    : (char *)sdx_get_buffer((srt_data *)s);
}

S_INLINE const char *ss_get_buffer_r(const srt_string *s)
{
	return ss_is_ref(s) ?
		  ((const struct SStringRef *)s)->cstr
		: (const char *)sdx_get_buffer_r((const srt_data *)s);
}

	/*
	 * Aux
	 */

#ifdef S_DEBUG
extern size_t dbg_cnt_alloc_calls; /* alloc or realloc calls */
#endif

#ifdef __cplusplus
} /* extern "C" { */
#endif
#endif /* SSTRING_H */


text:
"""
This application simulates the plant controlled by the thermostat node: it takes a voltage command,
runs a crude thermodynamics simulation, and publishes the temperature (i.e., one subscription, one publication).
"""

import time
import asyncio
import uavcan.si.unit.voltage
import uavcan.si.sample.temperature
import uavcan.time
import pyuavcan
from pyuavcan.application.heartbeat_publisher import Health
from pyuavcan.application import make_node, NodeInfo, register

UPDATE_PERIOD = 0.5

heater_voltage = 0.0
saturation = False

async def handle_command(msg: uavcan.si.unit.voltage.Scalar_1, _metadata: pyuavcan.transport.TransferFrom) -> None:
    global heater_voltage, saturation
    if msg.volt < 0.0:
        heater_voltage = 0.0
        saturation = True
    elif msg.volt > 50.0:
        heater_voltage = 50.0
        saturation = True
    else:
        heater_voltage = msg.volt
        saturation = False

async def main() -> None:
    with make_node(NodeInfo(name="org.uavcan.pyuavcan.demo.plant"), "plant.db") as node:
        # Expose internal states for diagnostics.
        node.registry["status.saturation"] = lambda: saturation  # The register type will be deduced as "bit[1]".

        # Initialize values from the registry. The temperature is in kelvin because in UAVCAN everything follows SI.
        # Here, we specify the type explicitly as "real32[1]". If we pass a native float, it would be "real64[1]".
        temp_environment = float(node.registry.setdefault("model.environment.temperature", register.Real32([292.15])))
        temp_plant = temp_environment

        # Set up the ports.
        pub_meas = node.make_publisher(uavcan.si.sample.temperature.Scalar_1, "temperature")
        pub_meas.priority = pyuavcan.transport.Priority.HIGH
        sub_volt = node.make_subscriber(uavcan.si.unit.voltage.Scalar_1, "voltage")
        sub_volt.receive_in_background(handle_command)

        # Run the main loop forever.
        next_update_at = asyncio.get_running_loop().time()
        while True:
            # Publish new measurement and update node health.
            await pub_meas.publish(
                uavcan.si.sample.temperature.Scalar_1(
                    timestamp=uavcan.time.SynchronizedTimestamp_1(microsecond=int(time.time() * 1e6)),
                    kelvin=temp_plant,
                )
            )
            node.heartbeat_publisher.health = Health.ADVISORY if saturation else Health.NOMINAL

            # Sleep until the next iteration.
            next_update_at += UPDATE_PERIOD
            await asyncio.sleep(next_update_at - asyncio.get_running_loop().time())

            # Update the simulation.
            temp_plant += heater_voltage * 0.1 * UPDATE_PERIOD  # Energy input from the heater.
            temp_plant -= (temp_plant - temp_environment) * 0.05 * UPDATE_PERIOD  # Dissipation.

if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        pass


text:
from __future__ import unicode_literals

from django.db import migrations
from bluebottle.utils.utils import update_group_permissions

def add_group_permissions(apps, schema_editor):
    group_perms = {
        'Staff': {
            'perms': (
                'change_budgetline', 'add_budgetline',
                'delete_budgetline', 'change_donation',
                'change_bankaccount', 'add_bankaccount',
                'change_payoutaccount', 'change_payout',
                'change_plainpayoutaccount'
            )
        },
    }

    update_group_permissions('funding', group_perms, apps)

class Migration(migrations.Migration):
    dependencies = [
        ('funding', '0044_auto_20191108_1008'),
    ]

    operations = [
        migrations.RunPython(add_group_permissions)
    ]


text:
\documentclass{article}

\usepackage[margin=1in]{geometry}     %for 1inch margins that play nice with fancyhdr
\usepackage{amsmath,amssymb}          % math and junk
\usepackage{fancyhdr}                 % for a nice running header and footer
\usepackage{lastpage}                 % for nice "X of Y" footer
\usepackage[per-mode=symbol]{siunitx} % for nice units and junk!
\usepackage{gnuplot-lua-tikz}         % enable tikz plots made from gnuplot
\usepackage{float}                    % [H] option for floats
\usepackage[american]{circuitikz}     % for teh circuit diagrams
\usepackage[hidelinks]{hyperref}                 % get those sweet, sweet, links
\usepackage{framed}                   % for framed titlepage
\usepackage{subfig}

% unused, but common for other experiments
%\usepackage{rotating}                 % for sideways stuff!
%\usepackage{cancel}                   % for `canceling out' parts of equations. fancy!
%\usepackage{mdwlist}                  % itemize* and friends
%\usepackage{verbatim}                 % for \verbatiminput command and comment environment
%\usepackage[colorinlistoftodos]{todonotes}                % todo's, if used/needed
%\usepackage{multirow}                 % for multi-row spans in tabular environment

% values!
\newcommand{\docAuthor}{Sean Barag}
\newcommand{\docCoAuthor}{None}
\newcommand{\ta}{Yang Gao}
\newcommand{\docTitle}{DC Voltage Supplies and Regulation}
\newcommand{\courseName}{ECE-L303}
\newcommand{\labNum}{Lab 3}
\newcommand{\labSec}{062}
\newcommand{\dueDate}{14 October 2011}
\newcommand{\perfDate}{7 September 2011}

% paths
\graphicspath{{$HOME/texmf/graphics/}}

% meta-data
\pdfinfo{
	/Title    (\labNum: \docTitle)
	/Author   (\docAuthor)
	/Keywords (\docTitle, \labNum)
}

% for fancy header
\pagestyle{fancy}
\lhead{\courseName\ $|$ \labSec}
\chead{\labNum: \docTitle}
\rhead{\docAuthor}
\cfoot{\thepage\ of \pageref{LastPage}}

% title info
\title{\courseName\ \labNum: \\ \docTitle}
\author{\docAuthor}
\date{}

% shortcuts, cause I'm lazy
\newcommand{\bs}[1]{\boldsymbol{#1}}
\newcommand{\tbf}[1]{\textbf{#1}}

\begin{document}
% Cover page written by Bryndon Blackburn
\input{titlePage.tex}

% Blank page so two-sided printing leaves the cover page on its own sheet
\thispagestyle{empty}
\newpage
\mbox{}

\maketitle
\setcounter{page}{1} % fixes page numbering issues caused by cover sheet
\tableofcontents % this helps
\pagebreak
\listoffigures   % there's over 9000 figures
\listoftables    % there's way fewer of them

\newpage % I want object to be at the top of a new page
\section{Object}
\input{object.tex}

\section{Circuit Diagrams}
\input{cd.tex}

\section{Graphs \& Data}
\input{graphs.tex}

\section{Conclusion}
\input{conclusion.tex}

\newpage
\appendix

\section{License}
\input{license.tex}

\end{document}