text:
> A ToDo List written for implement React with Redux data-flow.

[![Build Status](https://travis-ci.org/renatobenks/ToDoListSoftExpert.svg?branch=master)](https://travis-ci.org/renatobenks/ToDoListSoftExpert)

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/48fe82adbe3e4945a0d4b9b2ad948478)](https://www.codacy.com/app/renato-benkendorf/ToDoListSoftExpert?utm_source=github.com&utm_medium=referral&utm_content=renatobenks/ToDoListSoftExpert&utm_campaign=Badge_Grade)

[![Test Coverage](https://codeclimate.com/repos/58bddd275723fd027b003f5a/badges/b9071f9c803e247ef447/coverage.svg)](https://codeclimate.com/repos/58bddd275723fd027b003f5a/coverage)

[![Code Climate](https://codeclimate.com/repos/58bddd275723fd027b003f5a/badges/b9071f9c803e247ef447/gpa.svg)](https://codeclimate.com/repos/58bddd275723fd027b003f5a/feed)
[![Issue Count](https://codeclimate.com/repos/58bddd275723fd027b003f5a/badges/b9071f9c803e247ef447/issue_count.svg)](https://codeclimate.com/repos/58bddd275723fd027b003f5a/feed)

Esta é uma pequena aplicação de ToDo List, que deverá ser extendida e melhorada.

[Leia mais sobre esse app aqui](./.docs/about.md)

![Todo list](.docs/images/template.jpg)

---

## Requirements

Para que esta aplicação possa ser funcionar, tenha certeza
que você tem instalado no seu ambiente o Node.js.
E que as seguintes ferramentas estão corretamente configuradas:

- Node.js (recommended: 4.x):
```bash
$ node --version
```

- npm (recommended: 2.x or 3.x)
```bash
$ npm --version
```

## Running app

Uma vez que você garantiu a instalação das ferramentas acima,
veja como colocar o app rodando:

Instale as depêndencias da aplicação:

```sh
$ npm i
```

### Environment: development

Para construir a aplicação em modo de desenvolvimento:

```sh
$ npm start
```

Assim que você tiver o bundle construído, você pode abrir o
`index.html`  no seu browser e verificar se a aplicação
está funcionando corretamente.

### Testing components

Como esta aplicação é para ser supostamente um case study e não
uma aplicação real, você pode habilitar testes específicos,
adicionado "#testName" na URL.

Por exemplo, para habilitar o teste "renderBottom", você abrirá
o arquivo `index.html` e adicionará no final a hash "#renderBottom".

Example URL:

    file:///C:/Users/user/Desktop/TodoList/index.html#renderBottom

Note que agora o campo input está renderizado abaixo da lista.

---


text:
package v1beta1

import (
	"k8s.io/kubernetes/pkg/api/unversioned"
	"k8s.io/kubernetes/pkg/api/v1"
	"k8s.io/kubernetes/pkg/runtime"
)

// GroupName is the group name use in this package
const GroupName = "authentication.k8s.io"

// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = unversioned.GroupVersion{Group: GroupName, Version: "v1beta1"}

func AddToScheme(scheme *runtime.Scheme) {
	// Add the API to Scheme.
	addKnownTypes(scheme)
	addDefaultingFuncs(scheme)
	addConversionFuncs(scheme)
}

// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) {
	scheme.AddKnownTypes(SchemeGroupVersion,
		&v1.ListOptions{},
		&v1.DeleteOptions{},
		&v1.ExportOptions{},

		&TokenReview{},
	)
}

redpajama_set_name: RedPajamaGithub


text:
<component
	id="Tree"
	title="Tree 2.0"
	tooltip="Tree"
	icon="res/Tree/Tree.png"
	handlerType="sapui5"
	propertySheetPath="res/Tree/aps/PropertyPage.html"
	group="ScnCommunityBasics"
	databound="false"
>

	<jsInclude>res/require_loader.js</jsInclude>
	<jsInclude>res/Tree/TreeLoader.js</jsInclude>
	<cssInclude>res/Tree/Tree.css</cssInclude>

	<property
		id="cleanAll"
		type="boolean"
		title="Clean All Nodes"
		group="Display"
		bindable="true"
		visible="false">

	</property>
	<property
		id="defaultImage"
		type="Url"
		title="Url For Default Picture"
		group="Display"
		bindable="true"
		visible="true">

	</property>
	<property
		id="expandedKey"
		type="String"
		title="Technical Proprty For Expanded Key"
		group="Display"
		bindable="true"
		visible="false">

	</property>
	<property
		id="nodesContent"
		type="String"
		title="Nodes"
		group="Display"
		bindable="true"
		visible="true">

	</property>
	<property
		id="onFirstExpand"
		type="ScriptText"
		title="Event For On First Expand"
		group="Events"
		visible="true">

	</property>
	<property
		id="onSelectionChanged"
		type="ScriptText"
		title="Event For On Selection Changed"
		group="Events"
		visible="true">

	</property>
	<property
		id="roundtrip"
		type="String"
		title="Technical Proprty For Roundtrip"
		group="Display"
		bindable="true"
		visible="false">

	</property>
	<property
		id="selectedKey"
		type="String"
		title="Technical Proprty For Selected Key"
		group="Display"
		bindable="true"
		visible="false">

	</property>

	<initialization>
		<defaultValue property="TOP_MARGIN">0</defaultValue>
		<defaultValue property="BOTTOM_MARGIN">auto</defaultValue>
		<defaultValue property="LEFT_MARGIN">0</defaultValue>
		<defaultValue property="RIGHT_MARGIN">auto</defaultValue>
		<defaultValue property="WIDTH">230</defaultValue>
		<defaultValue property="HEIGHT">400</defaultValue>

		<defaultValue property="cleanAll"><![CDATA[false]]></defaultValue>
		<defaultValue property="defaultImage"><![CDATA[]]></defaultValue>
		<defaultValue property="expandedKey"><![CDATA[]]></defaultValue>
		<defaultValue property="nodesContent"><![CDATA[[]]]></defaultValue>
		<defaultValue property="onFirstExpand"><![CDATA[]]></defaultValue>
		<defaultValue property="onSelectionChanged"><![CDATA[]]></defaultValue>
		<defaultValue property="roundtrip"><![CDATA[]]></defaultValue>
		<defaultValue property="selectedKey"><![CDATA[]]></defaultValue>

	</initialization>

</component>


text:
import { createWaitablePromise, Wait, WaitablePromise } from '@algolia/client-common';
import { MethodEnum } from '@algolia/requester-common';
import { RequestOptions } from '@algolia/transporter';

import {
  initIndex,
  MultipleBatchRequest,
  MultipleBatchResponse,
  SearchClient,
  waitTask,
} from '../..';

export const multipleBatch = (base: SearchClient) => {
  return (
    requests: readonly MultipleBatchRequest[],
    requestOptions?: RequestOptions
  ): Readonly<WaitablePromise<MultipleBatchResponse>> => {
    const wait: Wait<MultipleBatchResponse> = (response, waitRequestOptions) => {
      return Promise.all(
        Object.keys(response.taskID).map(indexName => {
          return initIndex(base)(indexName, {
            methods: { waitTask },
          }).waitTask(response.taskID[indexName], waitRequestOptions);
        })
      );
    };

    return createWaitablePromise<MultipleBatchResponse>(
      base.transporter.write(
        {
          method: MethodEnum.Post,
          path: '1/indexes/*/batch',
          data: {
            requests,
          },
        },
        requestOptions
      ),
      wait
    );
  };
};


text:
import Backdrop from './../src/';
import {insertPositionedElement, removeTestElements} from './utilities';
import {simulateMouseEvent} from '@fczbkk/event-simulator';

describe('Backdrop', function () {

  let b = null;
  let elm = null;

  beforeEach(function () {
    b = new Backdrop();
    elm = insertPositionedElement(100, 100);
  });

  afterEach(function () {
    b.destroy();
    removeTestElements();
  });

  it('should exist', function () {
    expect(Backdrop).toBeDefined();
  });

  describe('defaults and options', function () {

    it('should have default options', function () {
      expect(b.options.backdrop_class).toEqual('backdrop');
      expect(b.options.z_index).toEqual(1000);
      expect(b.options.padding).toEqual(5);
      expect(b.options.color).toEqual('#000000');
      expect(b.options.opacity).toEqual(0.5);
      expect(typeof b.options.onShow).toEqual('function');
      expect(typeof b.options.onHide).toEqual('function');
    });

    it('should mix provided options with default ones', function () {
      b.setOptions({
        padding: 100
      });
      expect(b.options.padding).toEqual(100);
    });

    it('should allow `false` values', function () {
      b.setOptions({
        hide_on_click: false
      });
      expect(b.options.hide_on_click).toEqual(false);
    });
  });

  describe('actions', function () {

    it('should show overlays for element fully inside BODY', function () {
      b.show(elm);
      const overlays = document.querySelectorAll('.backdrop');
      expect(overlays.length).toEqual(4);
    });

    it('should show overlays for element partially inside BODY', function () {
      elm.style.top = '-50px';
      elm.style.left = '-50px';
      b.show(elm);
      const overlays = document.querySelectorAll('.backdrop');
      expect(overlays.length).toEqual(2);
    });

    it('should show overlays for element outside BODY', function () {
      elm.style.top = '-200px';
      elm.style.left = '-200px';
      b.show(elm);
      const overlays = document.querySelectorAll('.backdrop');
      expect(overlays.length).toEqual(1);
    });

    it('should show single overlay for non-existing target', function () {
      b.show(null);
      const overlays = document.querySelectorAll('.backdrop');
      expect(overlays.length).toEqual(1);
    });

    it('should show single overlay for invalid target', function () {
      b.show('xxx');
      const overlays = document.querySelectorAll('.backdrop');
      expect(overlays.length).toEqual(1);
    });

    it('should hide overlays', function () {
      b.show(elm);
      b.hide();
      const overlays = document.querySelectorAll('.backdrop');
      expect(overlays.length).toEqual(0);
    });

    it('should hide previous overlays on show', function () {
      b.show(elm);
      b.show(elm);
      const overlays = document.querySelectorAll('.backdrop');
      expect(overlays.length).toEqual(4);
    });

    it('should hide overlays on click', function () {
      b.show(elm);
      if (document.createEvent) {
        simulateMouseEvent(b.backdrops[0]);
        expect(b.is_active).toEqual(false);
      }
    });

  });

  describe('callbacks', function () {

    it('should fire onShow', function () {
      spyOn(b.options, 'onShow');
      b.show(elm);
      expect(b.options.onShow).toHaveBeenCalled();
    });

    it('should fire onHide', function () {
      spyOn(b.options, 'onHide');
      b.show(elm);
      b.hide();
      expect(b.options.onHide).toHaveBeenCalled();
    });

  });

  describe('hide on click', function () {

    it('should be enabled by default', function () {
      expect(b.options.hide_on_click).toEqual(true);
    });

    it('should hide on click when enabled', function () {
      b.show(elm);
      if (document.createEvent) {
        simulateMouseEvent(b.backdrops[0]);
        expect(b.is_active).toEqual(false);
      }
    });

    it('should not hide on click when disabled', function () {
      b.options.hide_on_click = false;
      b.show(elm);
      if (document.createEvent) {
        simulateMouseEvent(b.backdrops[0]);
        expect(b.is_active).toEqual(true);
      }
    });

  });

  describe('cover', function () {

    it('should be in options', function () {
      expect(b.options.cover).toEqual(false);
    });

    it('should not add if disabled', function () {
      b.show(elm);
      expect(b.covers.length).toEqual(0);
    });

    it('should add if enabled', function () {
      b.setOptions({
        cover: true
      });
      b.show(elm);
      expect(b.covers.length).not.toEqual(0);
    });

    it('should hide on click', function () {
      b.setOptions({
        cover: true
      });
      b.show(elm);
      if (document.createEvent) {
        simulateMouseEvent(b.covers[0]);
        expect(b.is_active).toEqual(false);
      }
    });

  });

});


text:
package uk.ac.cam.cl.signups.database;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import javax.management.RuntimeErrorException;

import org.mongojack.JacksonDBCollection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import uk.ac.cam.cl.signups.SignupService;
import uk.ac.cam.cl.signups.api.exceptions.DuplicateNameException;
import uk.ac.cam.cl.signups.api.exceptions.ItemNotFoundException;
import uk.ac.cam.cl.signups.interfaces.DatabaseItem;

import com.google.inject.Inject;
import com.mongodb.BasicDBObject;

public class MongoCollection<T extends DatabaseItem> implements DatabaseCollection<T> {

    /* For logging */
    private static final Logger log = LoggerFactory.getLogger(MongoCollection.class);

    private JacksonDBCollection<T, String> collection;

    @Inject /* We are not actually injecting using Guice, we do it manually */
    protected void setCollection(JacksonDBCollection<T, String> collection) {
        this.collection = collection;
    }

    public void insertItem(T item) throws DuplicateNameException {
        try {
            collection.insert(item);
        } catch (com.mongodb.DuplicateKeyException dupKey) {
            log.debug("Duplicate Key Exception caught when inserting something " +
                    "of ID " + item.get_id() + "and of class "
                    + item.getClass().getSimpleName() + " - throwing DuplicateNameException");
            throw new DuplicateNameException(item.get_id());
        } catch (com.mongodb.MongoException e) {
            log.error("A MongoException was caught when inserting something " +
                    "of ID " + item.get_id() + "and of class "
                    + item.getClass().getSimpleName() + " - throwing RuntimeException " +
                    "because the only MongoException that is okay is DuplicateKey");
            throw new RuntimeException(e);
        }
    }

    public void updateItem(T item) throws ItemNotFoundException {
        if (!contains(item.get_id())) {
            log.debug("The item of ID " + item.get_id()
                    + " of type " + item.getClass().getSimpleName() + " was not found in the database");
            throw new ItemNotFoundException("The item of ID " + item.get_id()
                    + " of type " + item.getClass().getSimpleName() + " was not found in the database");
        }
        collection.updateById(item.get_id(), item);
    }

    public List<T> listItems() {
        List<T> rtn = new LinkedList<T>();
        Iterator<T> allItems = collection.find();
        while (allItems.hasNext())
            rtn.add(allItems.next());
        return rtn;
    }

    public boolean contains(String id) {
        int matchingItems = collection.find(new BasicDBObject("_id", id)).count();
        assert (matchingItems == 0 || matchingItems == 1);
        return (matchingItems == 1);
    }

    public T getItem(String id) throws ItemNotFoundException {
        if (!contains(id)) {
            log.debug("The item of ID " + id + " was not found in the database");
            throw new ItemNotFoundException("The item of ID " + id + " was not found in the database");
        }
        return collection.findOneById(id);
    }

    public void removeAll() {
        collection.remove(new BasicDBObject());
    }

    public void removeItem(String id) throws ItemNotFoundException {
        if (!contains(id)) {
            log.debug("The item of ID " + id + " was not found in the database");
            throw new ItemNotFoundException("The item of ID " + id + " was not found in the database");
        }
        collection.removeById(id);
    }

}


text:
package com.jhlabs.map.shapefile;

import java.io.*;

public class ShapefileException extends IOException {
	public ShapefileException(String s) {
		super(s);
	}
}


text:
function f = make(varargin)
%MAKE   Constructor shortcut for SINGFUN objects.
%   For SINGFUN methods implemented at the ONEFUN level, it is not possible to
%   call the class constructor file corresponding to a ONEFUN object directly.
%   F = MAKE(VARARGIN) allows us to get around this and construct a SINGFUN.
%
% See also SINGFUN.

% Copyright 2015 by The University of Oxford and The Chebfun Developers.
% See http://www.chebfun.org/ for Chebfun information.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Developer note: This is essentially a "factory method" in the sense of
% _Design Patterns_ by Gamma, Helm, Johnson, and Vlissides.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

f = singfun(varargin{:});

end


text:
namespace Memento
{
    using System;

    public class MementoExecute
    {
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        public static void Main()
        {
            SalesProspect s = new SalesProspect();
            s.Name = "Noel van Halen";
            s.Phone = "(412) 256-0990";
            s.Budget = 25000.0;

            // Store internal state
            ProspectMemory m = new ProspectMemory();
            m.Memento = s.SaveMemento();

            // Continue changing originator
            s.Name = "Leo Welch";
            s.Phone = "(310) 209-7111";
            s.Budget = 1000000.0;

            // Restore saved state
            s.RestoreMemento(m.Memento);
        }
    }
}


text:
package org.apache.zookeeper.test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.regex.Pattern;

import org.apache.zookeeper.TestableZooKeeper;
import org.apache.zookeeper.ZooKeeper;
import static org.apache.zookeeper.client.FourLetterWordMain.send4LetterWord;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class FourLetterWordsTest extends ClientBase {
    protected static final Logger LOG =
        LoggerFactory.getLogger(FourLetterWordsTest.class);

    /** Test the various four letter words */
    @Test
    public void testFourLetterWords() throws Exception {
        verify("ruok", "imok");
        verify("envi", "java.version");
        verify("conf", "clientPort");
        verify("stat", "Outstanding");
        verify("srvr", "Outstanding");
        verify("cons", "queued");
        verify("dump", "Session");
        verify("wchs", "watches");
        verify("wchp", "");
        verify("wchc", "");

        verify("srst", "reset");
        verify("crst", "reset");

        verify("stat", "Outstanding");
        verify("srvr", "Outstanding");
        verify("cons", "queued");

        TestableZooKeeper zk = createClient();
        String sid = "0x" + Long.toHexString(zk.getSessionId());

        verify("stat", "queued");
        verify("srvr", "Outstanding");
        verify("cons", sid);
        verify("dump", sid);

        zk.getData("/", true, null);

        verify("stat", "queued");
        verify("srvr", "Outstanding");
        verify("cons", sid);
        verify("dump", sid);

        verify("wchs", "watching 1");
        verify("wchp", sid);
        verify("wchc", sid);
        zk.close();

        verify("ruok", "imok");
        verify("envi", "java.version");
        verify("conf", "clientPort");
        verify("stat", "Outstanding");
        verify("srvr", "Outstanding");
        verify("cons", "queued");
        verify("dump", "Session");
        verify("wchs", "watch");
        verify("wchp", "");
        verify("wchc", "");

        verify("srst", "reset");
        verify("crst", "reset");

        verify("stat", "Outstanding");
        verify("srvr", "Outstanding");
        verify("cons", "queued");
        verify("mntr", "zk_server_state\tstandalone");
    }

    private String sendRequest(String cmd) throws IOException {
      HostPort hpobj = ClientBase.parseHostPortList(hostPort).get(0);
      return send4LetterWord(hpobj.host, hpobj.port, cmd);
    }

    private void verify(String cmd, String expected) throws IOException {
        String resp = sendRequest(cmd);
        LOG.info("cmd " + cmd + " expected " + expected + " got " + resp);
        Assert.assertTrue(resp.contains(expected));
    }

    @Test
    public void validateStatOutput() throws Exception {
        ZooKeeper zk1 = createClient();
        ZooKeeper zk2 = createClient();

        String resp = sendRequest("stat");
        BufferedReader in = new BufferedReader(new StringReader(resp));

        String line;
        // first line should be version info
        line = in.readLine();
        Assert.assertTrue(Pattern.matches("^.*\\s\\d+\\.\\d+\\.\\d+-.*$", line));
        Assert.assertTrue(Pattern.matches("^Clients:$", in.readLine()));

        int count = 0;
        while ((line = in.readLine()).length() > 0) {
            count++;
            Assert.assertTrue(Pattern.matches("^ /.*:\\d+\\[\\d+\\]\\(queued=\\d+,recved=\\d+,sent=\\d+\\)$", line));
        }
        // ensure at least the two clients we created are accounted for
        Assert.assertTrue(count >= 2);

        line = in.readLine();
        Assert.assertTrue(Pattern.matches("^Latency min/avg/max: \\d+/\\d+/\\d+$", line));
        line = in.readLine();
        Assert.assertTrue(Pattern.matches("^Received: \\d+$", line));
        line = in.readLine();
        Assert.assertTrue(Pattern.matches("^Sent: \\d+$", line));
        line = in.readLine();
        Assert.assertTrue(Pattern.matches("^Outstanding: \\d+$", line));
        line = in.readLine();
        Assert.assertTrue(Pattern.matches("^Zxid: 0x[\\da-fA-F]+$", line));
        line = in.readLine();
        Assert.assertTrue(Pattern.matches("^Mode: .*$", line));
        line = in.readLine();
        Assert.assertTrue(Pattern.matches("^Node count: \\d+$", line));

        zk1.close();
        zk2.close();
    }

    @Test
    public void validateConsOutput() throws Exception {
        ZooKeeper zk1 = createClient();
        ZooKeeper zk2 = createClient();

        String resp = sendRequest("cons");
        BufferedReader in = new BufferedReader(new StringReader(resp));

        String line;
        int count = 0;
        while ((line = in.readLine()) != null && line.length() > 0) {
            count++;
            Assert.assertTrue(line, Pattern.matches("^ /.*:\\d+\\[\\d+\\]\\(queued=\\d+,recved=\\d+,sent=\\d+.*\\)$", line));
        }
        // ensure at least the two clients we created are accounted for
        Assert.assertTrue(count >= 2);

        zk1.close();
        zk2.close();
    }
}


text:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System;
using System.Composition;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;

namespace Microsoft.CodeAnalysis.Editor.Implementation.Workspaces
{
    [ExportWorkspaceServiceFactory(typeof(IProjectCacheHostService), ServiceLayer.Editor)]
    [Shared]
    internal partial class ProjectCacheHostServiceFactory : IWorkspaceServiceFactory
    {
        [ImportingConstructor]
        [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
        public ProjectCacheHostServiceFactory()
        {
        }

        public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
        {
            if (workspaceServices.Workspace.Kind != WorkspaceKind.Host)
            {
                return new ProjectCacheService(workspaceServices.Workspace, createImplicitCache: false);
            }

            return new ProjectCacheService(workspaceServices.Workspace, createImplicitCache: true);
        }
    }
}


text:
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE124_Buffer_Underwrite__char_alloca_memcpy_72b.cpp
Label Definition File: CWE124_Buffer_Underwrite.stack.label.xml
Template File: sources-sink-72b.tmpl.cpp
*/
/*
 * @description
 * CWE: 124 Buffer Underwrite
 * BadSource:  Set data pointer to before the allocated memory buffer
 * GoodSource: Set data pointer to the allocated memory buffer
 * Sinks: memcpy
 *    BadSink : Copy string to data using memcpy
 * Flow Variant: 72 Data flow: data passed in a vector from one function to another in different source files
 *
 * */

#include "std_testcase.h"
#include <vector>

#include <wchar.h>

using namespace std;

namespace CWE124_Buffer_Underwrite__char_alloca_memcpy_72
{

#ifndef OMITBAD

void badSink(vector<char *> dataVector)
{
    /* copy data out of dataVector */
    char * data = dataVector[2];
    {
        char source[100];
        memset(source, 'C', 100-1); /* fill with 'C's */
        source[100-1] = '\0'; /* null terminate */
        /* POTENTIAL FLAW: Possibly copying data to memory before the destination buffer */
        memcpy(data, source, 100*sizeof(char));
        /* Ensure the destination buffer is null terminated */
        data[100-1] = '\0';
        printLine(data);
    }
}

#endif /* OMITBAD */

#ifndef OMITGOOD

/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSink(vector<char *> dataVector)
{
    char * data = dataVector[2];
    {
        char source[100];
        memset(source, 'C', 100-1); /* fill with 'C's */
        source[100-1] = '\0'; /* null terminate */
        /* POTENTIAL FLAW: Possibly copying data to memory before the destination buffer */
        memcpy(data, source, 100*sizeof(char));
        /* Ensure the destination buffer is null terminated */
        data[100-1] = '\0';
        printLine(data);
    }
}

#endif /* OMITGOOD */

} /* close namespace */


text:
///////////////////////////////////////////////////////////////////////////////
//
// ShellIcons.h
// Do not tamper with the order of the items below!
//
// If you want to add new items to the ShellIcons.png strip here are the steps.
//
// 1:  Look for an //UNUSED tag indicating there is a 'slot' in the existing
//     strip that is empty.  If you find one replace the text UNUSED with an
//     image id (like cmdidVsShellMyCoolImage) and uncomment the line.
//
// 2:  If there is no UNUSED tag available then simply add your id to the end of
//     the list using the next sequential number.
//
// 3:  Finally, you want to insert your image into the ShellIcons.png strip at
//     X-offset (id - 1)*16.
//
///////////////////////////////////////////////////////////////////////////////

#ifndef __SHELLICONS_H__
#define __SHELLICONS_H__

#define cmdidVsShellUser                                        32768   // app-custom controls should use tcid >= cmdidVsShellUser
#define cmdidVsShellInteractiveSessionInterrupt                     1   // Cancel evaluation in interactive window
#define cmdidVsShellInteractiveSessionRestart                       2   // Reset interactive window session
#define cmdidVsShellAlignObjectsBottom                              3   // AlignObjectsBottom,
#define cmdidVsShellAlignObjectsCenteredHorizontal                  4   // AlignObjectsCenteredHorizontal,
#define cmdidVsShellAlignObjectsCenteredVertical                    5   // AlignObjectsCenteredVertical,
#define cmdidVsShellAlignObjectsLeft                                6   // AlignObjectsLeft,
#define cmdidVsShellAlignObjectsRight                               7   // AlignObjectsRight,
#define cmdidVsShellAlignObjectsTop                                 8   // AlignObjectsTop,
#define cmdidVsShellAlignToGrid                                     9   // AlignToGrid,
#define cmdidVsShellBold                                           10   // Bold,
#define cmdidVsShellBringToFront                                   11   // BringToFront,
#define cmdidVsShellBullets                                        12   // Bullets,
#define cmdidVsShellCascadeWindows                                 13   // CascadeWindows,
#define cmdidVsShellCentered                                       14   // Centered,
#define cmdidVsShellCenterHorizontallyInForm                       15   // CenterHorizontallyInForm,
#define cmdidVsShellCenterVerticallyInForm                         16   // CenterVerticallyInForm,
#define cmdidVsShellClear                                          17   // Clear,
#define cmdidVsShellClose                                          18   // Close,
#define cmdidVsShellCodeWindow                                     19   // CodeWindow,
#define cmdidVsShellCollapse2                                      20   // Collapse2,
#define cmdidVsShellColumns                                        21   // Columns,
#define cmdidVsShellCompleteWord                                   22   // CompleteWord,
#define cmdidVsShellCopy                                           23   // Copy,
#define cmdidVsShellFont                                           24   // Font,
#define cmdidVsShellCut                                            25   // Cut,
#define cmdidVsShellDeclineInvitation                              26   // DeclineInvitation,
#define cmdidVsShellDelete                                         27   // Delete,
#define cmdidVsShellDeleteAllInkAnnots                             28   // DeleteAllInkAnnots,
#define cmdidVsShellDeleteCells                                    29   // DeleteCells,
#define cmdidVsShellDeleteColumns                                  30   // DeleteColumns,
#define cmdidVsShellDeleteRows                                     31   // DeleteRows,
#define cmdidVsShellDownArrow                                      32   // DownArrow,
#define cmdidVsShellExit                                           33   // Exit,
#define cmdidVsShellExpand2                                        34   // Expand2,
#define cmdidVsShellF1Help                                         35   // F1Help,
#define cmdidVsShellFieldList                                      36   // FieldList,
#define cmdidVsShellFind                                           37   // Find,
#define cmdidVsShellFullJustify                                    38   // FullJustify,
#define cmdidVsShellFullScreen                                     39   // FullScreen,
#define cmdidVsShellGraph                                          40   // Graph,
#define cmdidVsShellHappyFace                                      41   // HappyFace,
#define cmdidVsShellFilter                                         42   // Filter
#define cmdidVsShellHideWindow                                     43   // HideWindow,
#define cmdidVsShellHorizontalSpacingDecrease                      44   // HorizontalSpacingDecrease,
#define cmdidVsShellHorizontalSpacingIncrease                      45   // HorizontalSpacingIncrease,
#define cmdidVsShellHorizontalSpacingMakeEqual                     46   // HorizontalSpacingMakeEqual,
#define cmdidVsShellHorizontalSpacingRemove                        47   // HorizontalSpacingRemove,
#define cmdidVsShellIndent                                         48   // Indent,
#define cmdidVsShellIndentRTL                                      49   // IndentRTL,
#define cmdidVsShellIndentVerticalBT                               50   // IndentVerticalBT,
#define cmdidVsShellInsertCells                                    51   // InsertCells,
#define cmdidVsShellInsertColumnsLeft                              52   // InsertColumnsLeft,
#define cmdidVsShellInsertColumnsRight                             53   // InsertColumnsRight,
#define cmdidVsShellInsertRowsAbove                                54   // InsertRowsAbove,
#define cmdidVsShellInsertRowsBelow                                55   // InsertRowsBelow,
#define cmdidVsShellInsertTable                                    56   // InsertTable,
#define cmdidVsShellItalic                                         57   // Italic,
#define cmdidVsShellLeftArrow                                      58   // LeftArrow,
#define cmdidVsShellLeftJustify                                    59   // LeftJustify,
#define cmdidVsShellLineChart                                      60   // LineChart,
#define cmdidVsShellMergeCells                                     61   // MergeCells,
#define cmdidVsShellSplitCells                                     62   // SplitCells,
#define cmdidVsShellNewFolder                                      63   // NewFolder,
#define cmdidVsShellNewTask                                        64   // NewTask,
//#define UNUSED                                                   65   // Not Used, if replaced put your icon description here
#define cmdidVsShellNumbering                                      66   // Numbering,
//#define UNUSED                                                   67   // Not Used, if replaced put your icon description here
#define cmdidVsShellOpen                                           68   // Open,
#define cmdidVsShellOptions                                        69   // Options,
#define cmdidVsShellOutdent                                        70   // Outdent,
#define cmdidVsShellOutlineView                                    71   // OutlineView,
#define cmdidVsShellParagraphDialog                                72   // ParagraphDialog,
#define cmdidVsShellParameterInfo                                  73   // ParameterInfo,
#define cmdidVsShellPaste                                          74   // Paste,
#define cmdidVsShellPause                                          75   // Pause,
#define cmdidVsShellPlay                                           76   // Play,
#define cmdidVsShellPrint                                          77   // Print,
#define cmdidVsShellPrintPreview                                   78   // PrintPreview,
#define cmdidVsShellPrintSetup                                     79   // PrintSetup,
#define cmdidVsShellProperties                                     80   // Properties,
#define cmdidVsShellPSSHelp                                        81   // PSSHelp,
#define cmdidVsShellQuickInfo                                      82   // QuickInfo,
#define cmdidVsShellReports                                        83   // Reports
#define cmdidVsShellRecord                                         84   // Record,
#define cmdidVsShellRedo                                           85   // Redo,
#define cmdidVsShellREM                                            86   // REM,
#define cmdidVsShellRename                                         87   // Rename,
#define cmdidVsShellRenameFolder                                   88   // RenameFolder,
#define cmdidVsShellRenameMaster                                   89   // RenameMaster,
#define cmdidVsShellRestart                                        90   // Restart,
#define cmdidVsShellRightArrow                                     91   // RightArrow,
#define cmdidVsShellRightJustify                                   92   // RightJustify,
#define cmdidVsShellRotateLeft                                     93   // RotateLeft,
#define cmdidVsShellRotateRight                                    94   // RotateRight,
#define cmdidVsShellSave                                           95   // Save,
#define cmdidVsShellSaveAll                                        96   // SaveAll,
#define cmdidVsShellSelectAll                                      97   // SelectAll,
#define cmdidVsShellSelectMember                                   98   // SelectMember,
#define cmdidVsShellSendToBack                                     99   // SendToBack,
#define cmdidVsShellSetNextStatement                              100   // SetNextStatement,
#define cmdidVsShellShowNextStatement                             101   // ShowNextStatement,
#define cmdidVsShellSizeToControlHeight                           102   // SizeToControlHeight,
#define cmdidVsShellSizeToControlHeightAndWidth                   103   // SizeToControlHeightAndWidth,
#define cmdidVsShellSizeToControlWidth                            104   // SizeToControlWidth,
#define cmdidVsShellSizeToGrid                                    105   // SizeToGrid,
#define cmdidVsShellFormatDrawingObject                           106   // FormatDrawingObject,
#define cmdidVsShellSortingGrouping                               107   // SortingGrouping,
#define cmdidVsShellSortUp                                        108   // SortUp,
#define cmdidVsShellSplit                                         109   // Split,
#define cmdidVsShellDistributeColumn                              110   // DistributeColumn,
#define cmdidVsShellDistributeRow                                 111   // DistributeRow,
#define cmdidVsShellStepIn                                        112   // StepIn,
#define cmdidVsShellStepOut                                       113   // StepOut,
#define cmdidVsShellStepOver                                      114   // StepOver,
#define cmdidVsShellStepToCursor                                  115   // StepToCursor,
#define cmdidVsShellStop                                          116   // Stop,
#define cmdidVsShellSubscript                                     117   // Subscript,
#define cmdidVsShellSuperscript                                   118   // Superscript,
#define cmdidVsShellTabOrder                                      119   // TabOrder,
#define cmdidVsShellTileWindowsHorizontally                       120   // TileWindowsHorizontally,
#define cmdidVsShellTileWindowsVertically                         121   // TileWindowsVertically,
#define cmdidVsShellToolbox                                       122   // Toolbox,
#define cmdidVsShellToolLock                                      123   // ToolLock,
#define cmdidVsShellUnderline                                     124   // Underline,
#define cmdidVsShellUndo                                          125   // Undo,
#define cmdidVsShellUnREM                                         126   // UnREM,
#define cmdidVsShellUpArrow                                       127   // UpArrow,
#define cmdidVsShellVBProjectProperties                           128   // VBProjectProperties,
#define cmdidVsShellVerticalSpacingDecrease                       129   // VerticalSpacingDecrease,
#define cmdidVsShellVerticalSpacingIncrease                       130   // VerticalSpacingIncrease,
#define cmdidVsShellVerticalSpacingMakeEqual                      131   // VerticalSpacingMakeEqual,
#define cmdidVsShellVerticalSpacingRemove                         132   // VerticalSpacingRemove,
#define cmdidVsShellViewPropertyPages                             133   // ViewPropertyPages,
#define cmdidVsShellViewVBEObject                                 134   // ViewVBEObject,
#define cmdidVsShellWebStopLoading                                135   // WebStopLoading,
//#define UNUSED                                                  136   // Not Used, if replaced put your icon description here
#define cmdidVsShellZoom                                          137   // Zoom,
#define cmdidVsShellZoomIn                                        138   // ZoomIn,
#define cmdidVsShellZoomOut                                       139   // ZoomOut,
#define cmdidVsShellPinTab                                        140   // PinTab,
#define cmdidVsShellPromoteTab                                    141   // PromoteTab,
#define cmdidVsShellBringFloatingWindowsToFront                   142   // BringFloatingWindowsToFront,
#define cmdidVsShellStartupSettings                               143   // StartupSettings,
#define cmdidVsShellNil                                           144   // Nil,
#define cmdidVsShellSortDialog                                    145   // SortDialog,
#define cmdidVsShellWatch                                         146   // Watch,
#define cmdidVsShellDeleteWatch                                   147   // DeleteWatch,
#define cmdidVsShellImmediateWindow                               148   // ImmediateWindow,
#define cmdidVsShellCollapseParent                                149   // CollapseParent
#endif //__SHELLICONS_H__


text:
package com.github.stocky37.util.jersey;

import javax.ws.rs.core.Response;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.ANNOTATION_TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Status {
	Response.Status value();
}


text:
namespace orbit_session_setup {

class DoubleClickableLabel : public QLabel {
  Q_OBJECT

 public:
  using QLabel::QLabel;

 signals:
  void DoubleClicked();

 protected:
  void mouseDoubleClickEvent(QMouseEvent* event) override {
    QWidget::mouseDoubleClickEvent(event);
    emit DoubleClicked();
  }
};

}  // namespace orbit_session_setup

#endif  // ORBIT_QT_DOUBLE_CLICKABLE_LABEL_H_


text: build_number = 10


text:
package easymvp.compiler;

import java.util.Set;

import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;

/**
 * @author Saeed Masoumi (saeed@6thsolution.com)
 */
final class Validator {

    static boolean isClass(Element element) {
        return element.getKind() == ElementKind.CLASS;
    }

    static boolean isAbstractClass(Element element) {
        return isClass(element) && getModifiers(element).contains(Modifier.ABSTRACT);
    }

    static boolean isNotAbstractClass(Element element) {
        return isClass(element) && !getModifiers(element).contains(Modifier.ABSTRACT);
    }

    static boolean isSubType(Element child, String parentCanonicalName,
                             ProcessingEnvironment procEnv) {
        return procEnv.getTypeUtils()
                .isSubtype(child.asType(), getTypeElement(procEnv, parentCanonicalName).asType());
    }

    static boolean isPrivate(Element element) {
        return getModifiers(element).contains(Modifier.PRIVATE);
    }

    static boolean isMethod(Element element) {
        return ElementKind.METHOD == element.getKind();
    }

    static TypeElement getTypeElement(ProcessingEnvironment procEnv, String canonicalName) {
        return procEnv.getElementUtils().getTypeElement(canonicalName);
    }

    static Set<Modifier> getModifiers(Element element) {
        return element.getModifiers();
    }

}


text:
"use strict";
/*
 * ooiui/static/js/views/aa/AlertToggleNotificationModalFormView.js
 * View for event acknowledgement modal
 */

var AlertToggleNotificationModalFormView = ModalFormView.extend({
  bindings: {

  },
  events: {
    "click #toggleNotification": "onSubmit",
    "change input[name='alertalarm']": "updatedType"
  },
  initialize: function() {
    _.bindAll(this, "render","onSubmit");
    // Intentionally left blank to override parent
  },
  initialRender:function(){
    this.$el.html('<i class="fa fa-spinner fa-spin" style="margin-top:50px;margin-left:50%;font-size:90px;color:#337ab7;"> </i>');
  },
  template: JST['ooiui/static/js/partials/AlertToggleNotificationModalForm.html'],
  onSubmit: function(e) {
    var self = this;

    //stop the page redirect
    e.preventDefault();

    //console.log('id from modal form after submit: ', this.model.get('id'));

    ooi.trigger('alertToggleNotification:update', this.model);

// TODO: Set the redmine ticket field
/*    if (this.model.get('active') == 0) {
      this.model.set('active', true);
    } else {
      this.model.set('active', false);
    }

    // Sends ack
    this.model.save(null,{success: function(model, response, opts) {
      console.log('Notification Toggled OK!');
    },
      error: function(model, response, opts) {
        console.log('Notification Toggled Error!');
      }
    });*/
      this.hide();
  },
  render: function() {
    var self = this;

    this.$el.html(this.template({
      model: this.model,
      metadata_collection: this.metadata_collection
    }));
  }
});


text:
.chatContainer {
  display: flex;
  flex-flow: column;
  height: 80vh;
}

.chatMessages {
  flex: 2;
  overflow-y: scroll;
  border: 1px solid #e3e3e3;
  border-radius: 4px;
  margin-bottom: 5px;
}

.chatMessage {
  clear: both;
  float: right;
  background-color: #eef;
  padding: 8px;
  margin: 10px;
  max-width: 80%;
  min-width: 40px;
  position: relative;
}

/* For the speech bubble thingy. */
.chatMessage:after {
  left: 100%;
  bottom: 8px;
  border: solid transparent;
  content: " ";
  height: 0;
  width: 0;
  position: absolute;
  pointer-events: none;
  border-color: rgba(0, 122, 255, 0);
  border-left-color: #eef;
  border-width: 5px;
  margin-top: -5px;
}

.chatInput {
  min-height: 50px;
  margin-bottom: 5px;
}

.sendButton {
  resize: none;
}

#chatContextMenu {
  position: absolute;
  display: none;
  background-color: red;
}


text:
require 'redcarpet'

module LandingPageEng
	class Product < ActiveRecord::Base
		CATEGORIES = ["Animals",
		"Apparel & Accessories",
		"Arts & Entertainment",
		"Baby & Toddler",
		"Business & Industrial",
		"Cameras & Optics",
		"Electronics",
		"Food, Beverages & Tobacco",
		"Furniture",
		"Hardware",
		"Health & Beauty",
		"Home & Garden",
		"Luggage & Bags",
		"Mature",
		"Media",
		"Office Supplies",
		"Religious & Ceremonial",
		"Software",
		"Sporting Goods",
		"Toys & Games",
		"Vehicles & Parts"]

		attr_accessible :categories, :tags, :description, :details, :name, :picture_link_texts_attributes,
		:prices_attributes, :target_affiliates_attributes, :slug, :brand, :department

		has_many :prices
		has_many :picture_link_texts
		has_many :target_affiliates

		accepts_nested_attributes_for :picture_link_texts, allow_destroy: true
		accepts_nested_attributes_for :prices, allow_destroy: true
		accepts_nested_attributes_for :target_affiliates, allow_destroy: true

		validates :name,  presence: true, length: { maximum: 50 }
		validates :description, presence: true

		# Return the lowest known price for a given product or nil
		def price
			begin
				target_affiliates = self.target_affiliates
				target_affiliates[0].price
			rescue Exception => e
				nil
			end
		end

		def description
			markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)
			markdown.render(read_attribute(:description)).html_safe
		end

		def details
			markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)
			markdown.render(read_attribute(:details)).html_safe
		end

	end
end


text:
//[START all]
package pw2;

import pw2.domain.*;

import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory;
import com.googlecode.objectify.ObjectifyService;

import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent;

/**
 * OfyHelper, a ServletContextListener, is setup in web.xml to run before a JSP is run.  This is
 * required to let JSP's access Ofy.
 **/
public class OfyHelper implements ServletContextListener {
  public void contextInitialized(ServletContextEvent event) {
    // This will be invoked as part of a warmup request, or the first user request if no warmup
    // request.
    ObjectifyService.register(Conductor.class);
    ObjectifyService.register(Review.class);
  }

  public void contextDestroyed(ServletContextEvent event) {
    // App Engine does not currently invoke this method.
  }
}
//[END all]


text:
package com.dtolabs.rundeck.core.authorization;

import com.dtolabs.rundeck.core.authorization.providers.EnvironmentalContext;
import com.dtolabs.rundeck.core.common.Framework;

import javax.security.auth.Subject;
import java.util.Map;
import java.util.Set;

/**
 * Created by greg on 7/17/15.
 */
public interface AclRule {
    public String getSourceIdentity();

    public String getDescription();

    public Map<String, Object> getResource();

    public String getResourceType();

    public boolean isRegexMatch();

    public boolean isContainsMatch();
    public boolean isEqualsMatch();

    //    public Subject getSubject();
    public String getUsername();

    public String getGroup();

    public Set<String> getAllowActions();

    public EnvironmentalContext getEnvironment();

//    boolean isAppContext() {
//        return environment.equals(Framework.RUNDECK_APP_ENV);
//    }

    public Set<String> getDenyActions();
}


text:
import Ember from 'ember';

export default Ember.Route.extend({
  redirect: function () {
    let url = this.router.location.formatURL('/404');
    if (window.location.pathname !== url) {
      this.transitionTo('/404');
    }
  }
});


text:
package ec2

import (
	"encoding/xml"
	"log"
	"net/url"
	"strconv"
	"time"
)

type SpotPrice struct {
	InstanceType       string    `xml:"instanceType"`       // m1.small</instanceType>
	ProductDescription string    `xml:"productDescription"` // Linux/UNIX</productDescription>
	SpotPrice          float64   `xml:"spotPrice"`          // 0.287</spotPrice>
	Timestamp          time.Time `xml:"timestamp"`          // 2009-12-04T20:56:05.000Z</timestamp>
	AvailabilityZone   string    `xml:"availabilityZone"`   // us-east-1a</availabilityZone>
}

type DescribeSpotPriceHistoryResponse struct {
	SpotPrices []*SpotPrice `xml:"spotPriceHistorySet>item"`
}

const TIME_FORMAT = "2006-01-02T15:04:05.999Z"

type SpotPriceFilter struct {
	InstanceTypes       []string
	AvailabilityZones   []string
	ProductDescriptions []string
	StartTime           time.Time
	EndTime             time.Time
}

const DESC_LINUX_UNIX = "Linux/UNIX"

func (client *Client) DescribeSpotPriceHistory(filter *SpotPriceFilter) (prices []*SpotPrice, e error) {
	query := queryForAction("DescribeSpotPriceHistory")
	if filter == nil {
		filter = &SpotPriceFilter{}
	}
	values := url.Values{}
	for i, instanceType := range filter.InstanceTypes {
		values.Add("InstanceType."+strconv.Itoa(i+1), instanceType)
	}
	for i, desc := range filter.ProductDescriptions {
		values.Add("ProductDescription."+strconv.Itoa(i+1), desc)
	}

	if !filter.StartTime.IsZero() {
		values.Add("StartTime", filter.StartTime.Format(TIME_FORMAT))
	}
	if !filter.EndTime.IsZero() {
		values.Add("EndTime", filter.EndTime.Format(TIME_FORMAT))
	}
	query += "&" + values.Encode()
	log.Println(query)
	raw, e := client.DoSignedRequest("GET", ENDPOINT, query, nil)
	if e != nil {
		return prices, e
	}
	rsp := &DescribeSpotPriceHistoryResponse{}
	e = xml.Unmarshal(raw.Content, rsp)
	if e != nil {
		return prices, e
	}
	return rsp.SpotPrices, nil
}


text:
{-# LANGUAGE OverloadedStrings, TypeFamilies #-}
import Data.Word (Word8)
import qualified Data.ByteString as S
import Data.ByteString.Char8 () --

class SafeHead a where
	type Content a
	safeHead :: a -> Maybe (Content a)

instance  SafeHead [a] where
	type Content [a] = a
	safeHead [] = Nothing
	safeHead (x:_) = Just x
instance SafeHead S.ByteString where
	type Content S.ByteString = Word8
	safeHead bs
	| S.null bs = Nothing
	| otherwise = Just $ S.head bs

main :: IO ()
main =  do
	print $ safeHead (""::String)
	print $ safeHead ("hello" :: String)

	print $ safeHead (""::S.ByteString)
	print $ safeHead ("hello" :: S.ByteString)

module Phunctor00 where
-- myFmap :: Functor f => (a -> b) -> f a -> f b
-- myFmap _ [] = []
-- myFmap g (x:xs) = g x : myFmap g xs
-- myFmap' _ Nothing = Nothing
-- myFmap' g (Just a) = Just (g a)
--f x = x^3
--g x = x + x + x
--(f . g) x = f (g x)


text: // wxUSE_STD_IOSTREAM


text:
package ai.subut.kurjun.quota;

import java.io.IOException;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import ai.subut.kurjun.common.service.KurjunProperties;

import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;

@RunWith( MockitoJUnitRunner.class )
public class QuotaManagementModuleTest
{
    private QuotaManagementModule managementModule;

    @Mock
    KurjunProperties kurjunProperties;

    @Before
    public void setUp() throws Exception
    {
        managementModule = new QuotaManagementModule();
    }

    @Test
    public void getFileDb() throws Exception
    {
        // mock
        when( kurjunProperties.getWithDefault( anyString(), anyString() ) ).thenReturn( "test" );

        assertNotNull( managementModule.getFileDb( kurjunProperties ) );
    }
}


text:
module.exports = type

function type(x) {
  if (x !== x) return 'nan'

  var t = str.call(x).slice(8, -1).toLowerCase()

  if (t === 'object') {
    // Check if prototype is a function and has a name
    var proto = Object.getPrototypeOf(x)
    if (type(proto) === 'function' && proto.name) return proto.name
  }

  return t
}

var str = ({}).toString


text:
package nl.basjes.parse.useragent.beam;

import nl.basjes.parse.useragent.annotate.YauaaField;
import org.apache.beam.sdk.coders.StringUtf8Coder;
import org.apache.beam.sdk.testing.PAssert;
import org.apache.beam.sdk.testing.TestPipeline;
import org.apache.beam.sdk.transforms.Create;
import org.apache.beam.sdk.transforms.DoFn;
import org.apache.beam.sdk.transforms.ParDo;
import org.apache.beam.sdk.values.PCollection;
import org.junit.Rule;
import org.junit.Test;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

public class TestUserAgentAnalysisDoFnInline implements Serializable {

    @Rule
    public final transient TestPipeline pipeline = TestPipeline.create();

    @Test
    public void testInlineDefinition() { // NOSONAR java:S2699 False positive because PAssert is unknown to Sonar
        List<String> useragents = Arrays.asList(
            "Mozilla/5.0 (X11; Linux x86_64) " +
                "AppleWebKit/537.36 (KHTML, like Gecko) " +
                "Chrome/48.0.2564.82 Safari/537.36",

            "Mozilla/5.0 (Linux; Android 7.0; Nexus 6 Build/NBD90Z) " +
                "AppleWebKit/537.36 (KHTML, like Gecko) " +
                "Chrome/53.0.2785.124 Mobile Safari/537.36"
        );

        // Apply Create, passing the list and the coder, to create the PCollection.
        PCollection<String> input = pipeline.apply(Create.of(useragents)).setCoder(StringUtf8Coder.of());

        PCollection<TestRecord> testRecords = input
            .apply("Create testrecords from input",
                ParDo.of(new DoFn<String, TestRecord>() {
                    @SuppressWarnings("unused") // Called via the annotation
                    @ProcessElement
                    public void processElement(ProcessContext c) {
                        c.output(new TestRecord(c.element()));
                    }
                }));

        PCollection<TestRecord> filledTestRecords = testRecords
            .apply("Extract Elements from Useragent",
                ParDo.of(new UserAgentAnalysisDoFn<TestRecord>(15000) { // Setting the cacheSize
                    public String getUserAgentString(TestRecord record) {
                        return record.getUserAgent();
                    }

                    @SuppressWarnings("unused") // Called via the annotation
                    @YauaaField("DeviceClass")
                    public void setDeviceClass(TestRecord record, String value) {
                        record.deviceClass = value;
                    }

                    @SuppressWarnings("unused") // Called via the annotation
                    @YauaaField("AgentNameVersion")
                    public void setAgentNameVersion(TestRecord record, String value) {
                        record.agentNameVersion = value;
                    }
                }));

        TestRecord expectedRecord1 = new TestRecord(useragents.get(0));
        expectedRecord1.deviceClass = "Desktop";
        expectedRecord1.agentNameVersion = "Chrome 48.0.2564.82";

        TestRecord expectedRecord2 = new TestRecord(useragents.get(1));
        expectedRecord2.deviceClass = "Phone";
        expectedRecord2.agentNameVersion = "Chrome 53.0.2785.124";

        PAssert.that(filledTestRecords).containsInAnyOrder(expectedRecord1, expectedRecord2);

        pipeline.run().waitUntilFinish();
    }

}


text:
#include "talk/xmpp/hangoutpubsubclient.h"

#include "talk/base/logging.h"
#include "talk/xmpp/constants.h"
#include "talk/xmpp/jid.h"
#include "talk/xmllite/qname.h"
#include "talk/xmllite/xmlelement.h"

// Gives a high-level API for MUC call PubSub needs such as
// presenter state, recording state, mute state, and remote mute.

namespace buzz {

namespace {
const char kPresenting[] = "s";
const char kNotPresenting[] = "o";
const char kEmpty[] = "";

const std::string GetPublisherNickFromPubSubItem(const XmlElement* item_elem) {
  if (item_elem == NULL) {
    return "";
  }

  return Jid(item_elem->Attr(QN_ATTR_PUBLISHER)).resource();
}

}  // namespace

// Knows how to handle specific states and XML.
template <typename C>
class PubSubStateSerializer {
 public:
  virtual ~PubSubStateSerializer() {}
  virtual XmlElement* Write(const QName& state_name, const C& state) = 0;
  virtual C Parse(const XmlElement* state_elem) = 0;
};

// Knows how to create "keys" for states, which determines their
// uniqueness.  Most states are per-nick, but block is
// per-blocker-and-blockee.  This is independent of itemid, especially
// in the case of presenter state.
class PubSubStateKeySerializer {
 public:
  virtual ~PubSubStateKeySerializer() {}
  virtual std::string GetKey(const std::string& publisher_nick,
                             const std::string& published_nick) = 0;
};

class PublishedNickKeySerializer : public PubSubStateKeySerializer {
 public:
  virtual std::string GetKey(const std::string& publisher_nick,
                             const std::string& published_nick) {
    return published_nick;
  }
};

class PublisherAndPublishedNicksKeySerializer
    : public PubSubStateKeySerializer {
 public:
  virtual std::string GetKey(const std::string& publisher_nick,
                             const std::string& published_nick) {
    return publisher_nick + ":" + published_nick;
  }
};

// A simple serialiazer where presence of item => true, lack of item
// => false.
class BoolStateSerializer : public PubSubStateSerializer<bool> {
  virtual XmlElement* Write(const QName& state_name, const bool& state) {
    if (!state) {
      return NULL;
    }

    return new XmlElement(state_name, true);
  }

  virtual bool Parse(const XmlElement* state_elem) {
    return state_elem != NULL;
  }
};

// Adapts PubSubClient to be specifically suited for pub sub call
// states.  Signals state changes and keeps track of keys, which are
// normally nicks.
// TODO: Expose this as a generally useful class, not just
// private to hangouts.
template <typename C>
class PubSubStateClient : public sigslot::has_slots<> {
 public:
  // Gets ownership of the serializers, but not the client.
  PubSubStateClient(const std::string& publisher_nick,
                    PubSubClient* client,
                    const QName& state_name,
                    C default_state,
                    PubSubStateKeySerializer* key_serializer,
                    PubSubStateSerializer<C>* state_serializer)
      : publisher_nick_(publisher_nick),
        client_(client),
        state_name_(state_name),
        default_state_(default_state) {
    key_serializer_.reset(key_serializer);
    state_serializer_.reset(state_serializer);
    client_->SignalItems.connect(
        this, &PubSubStateClient<C>::OnItems);
    client_->SignalPublishResult.connect(
        this, &PubSubStateClient<C>::OnPublishResult);
    client_->SignalPublishError.connect(
        this, &PubSubStateClient<C>::OnPublishError);
    client_->SignalRetractResult.connect(
        this, &PubSubStateClient<C>::OnRetractResult);
    client_->SignalRetractError.connect(
        this, &PubSubStateClient<C>::OnRetractError);
  }

  virtual ~PubSubStateClient() {}

  virtual void Publish(const std::string& published_nick,
                       const C& state,
                       std::string* task_id_out) {
    std::string key = key_serializer_->GetKey(publisher_nick_, published_nick);
    std::string itemid = state_name_.LocalPart() + ":" + key;
    if (StatesEqual(state, default_state_)) {
      client_->RetractItem(itemid, task_id_out);
    } else {
      XmlElement* state_elem = state_serializer_->Write(state_name_, state);
      state_elem->AddAttr(QN_NICK, published_nick);
      client_->PublishItem(itemid, state_elem, task_id_out);
    }
  };

  sigslot::signal1<const PubSubStateChange<C>&> SignalStateChange;
  // Signal (task_id, item).  item is NULL for retract.
  sigslot::signal2<const std::string&,
                   const XmlElement*> SignalPublishResult;
  // Signal (task_id, item, error stanza).  item is NULL for retract.
  sigslot::signal3<const std::string&,
                   const XmlElement*,
                   const XmlElement*> SignalPublishError;

 protected:
  // return false if retracted item (no info or state given)
  virtual bool ParseStateItem(const PubSubItem& item,
                              StateItemInfo* info_out,
                              bool* state_out) {
    const XmlElement* state_elem = item.elem->FirstNamed(state_name_);
    if (state_elem == NULL) {
      return false;
    }

    info_out->publisher_nick = GetPublisherNickFromPubSubItem(item.elem);
    info_out->published_nick = state_elem->Attr(QN_NICK);
    *state_out = state_serializer_->Parse(state_elem);
    return true;
  };

  virtual bool StatesEqual(C state1, C state2) {
    return state1 == state2;
  }

  PubSubClient* client() { return client_; }

 private:
  void OnItems(PubSubClient* pub_sub_client,
               const std::vector<PubSubItem>& items) {
    for (std::vector<PubSubItem>::const_iterator item = items.begin();
         item != items.end(); ++item) {
      OnItem(*item);
    }
  }

  void OnItem(const PubSubItem& item) {
    const std::string& itemid = item.itemid;
    StateItemInfo info;
    C new_state;

    bool retracted = !ParseStateItem(item, &info, &new_state);
    if (retracted) {
      bool known_itemid =
          (info_by_itemid_.find(itemid) != info_by_itemid_.end());
      if (!known_itemid) {
        // Nothing to retract, and nothing to publish.
        // Probably a different state type.
        return;
      } else {
        info = info_by_itemid_[itemid];
        info_by_itemid_.erase(itemid);
        new_state = default_state_;
      }
    } else {
      // TODO: Assert new key matches the known key. It
      // shouldn't change!
      info_by_itemid_[itemid] = info;
    }

    std::string key = key_serializer_->GetKey(
        info.publisher_nick, info.published_nick);
    bool has_old_state = (state_by_key_.find(key) != state_by_key_.end());
    C old_state = has_old_state ? state_by_key_[key] : default_state_;
    if ((retracted && !has_old_state) || StatesEqual(new_state, old_state)) {
      // Nothing change, so don't bother signalling.
      return;
    }

    if (retracted || StatesEqual(new_state, default_state_)) {
      // We treat a default state similar to a retract.
      state_by_key_.erase(key);
    } else {
      state_by_key_[key] = new_state;
    }

    PubSubStateChange<C> change;
    change.publisher_nick = info.publisher_nick;
    change.published_nick = info.published_nick;
    change.old_state = old_state;
    change.new_state = new_state;
    SignalStateChange(change);
 }

  void OnPublishResult(PubSubClient* pub_sub_client,
                       const std::string& task_id,
                       const XmlElement* item) {
    SignalPublishResult(task_id, item);
  }

  void OnPublishError(PubSubClient* pub_sub_client,
                      const std::string& task_id,
                      const buzz::XmlElement* item,
                      const buzz::XmlElement* stanza) {
    SignalPublishError(task_id, item, stanza);
  }

  void OnRetractResult(PubSubClient* pub_sub_client,
                       const std::string& task_id) {
    // There's no point in differentiating between publish and retract
    // errors, so we simplify by making them both signal a publish
    // result.
    const XmlElement* item = NULL;
    SignalPublishResult(task_id, item);
  }

  void OnRetractError(PubSubClient* pub_sub_client,
                      const std::string& task_id,
                      const buzz::XmlElement* stanza) {
    // There's no point in differentiating between publish and retract
    // errors, so we simplify by making them both signal a publish
    // error.
    const XmlElement* item = NULL;
    SignalPublishError(task_id, item, stanza);
  }

  std::string publisher_nick_;
  PubSubClient* client_;
  const QName state_name_;
  C default_state_;
  talk_base::scoped_ptr<PubSubStateKeySerializer> key_serializer_;
  talk_base::scoped_ptr<PubSubStateSerializer<C> > state_serializer_;
  // key => state
  std::map<std::string, C> state_by_key_;
  // itemid => StateItemInfo
  std::map<std::string, StateItemInfo> info_by_itemid_;
};

class PresenterStateClient : public PubSubStateClient<bool> {
 public:
  PresenterStateClient(const std::string& publisher_nick,
                       PubSubClient* client,
                       const QName& state_name,
                       bool default_state)
      : PubSubStateClient<bool>(
          publisher_nick, client, state_name, default_state,
          new PublishedNickKeySerializer(), NULL) {
  }

  virtual void Publish(const std::string& published_nick,
                       const bool& state,
                       std::string* task_id_out) {
    XmlElement* presenter_elem = new XmlElement(QN_PRESENTER_PRESENTER, true);
    presenter_elem->AddAttr(QN_NICK, published_nick);

    XmlElement* presentation_item_elem =
        new XmlElement(QN_PRESENTER_PRESENTATION_ITEM, false);
    const std::string& presentation_type = state ? kPresenting : kNotPresenting;
    presentation_item_elem->AddAttr(
        QN_PRESENTER_PRESENTATION_TYPE, presentation_type);

    // The Presenter state is kind of dumb in that it doesn't always use
    // retracts.  It relies on setting the "type" to a special value.
    std::string itemid = published_nick;
    std::vector<XmlElement*> children;
    children.push_back(presenter_elem);
    children.push_back(presentation_item_elem);
    client()->PublishItem(itemid, children, task_id_out);
  }

 protected:
  virtual bool ParseStateItem(const PubSubItem& item,
                              StateItemInfo* info_out,
                              bool* state_out) {
    const XmlElement* presenter_elem =
        item.elem->FirstNamed(QN_PRESENTER_PRESENTER);
    const XmlElement* presentation_item_elem =
        item.elem->FirstNamed(QN_PRESENTER_PRESENTATION_ITEM);
    if (presentation_item_elem == NULL || presenter_elem == NULL) {
      return false;
    }

    info_out->publisher_nick = GetPublisherNickFromPubSubItem(item.elem);
    info_out->published_nick = presenter_elem->Attr(QN_NICK);
    *state_out = (presentation_item_elem->Attr(
        QN_PRESENTER_PRESENTATION_TYPE) != kNotPresenting);
    return true;
  }

  virtual bool StatesEqual(bool state1, bool state2) {
    return false;  // Make every item trigger an event, even if state doesn't change.
  }
};

HangoutPubSubClient::HangoutPubSubClient(XmppTaskParentInterface* parent,
                                         const Jid& mucjid,
                                         const std::string& nick)
    : mucjid_(mucjid),
      nick_(nick) {
  presenter_client_.reset(new PubSubClient(parent, mucjid, NS_PRESENTER));
  presenter_client_->SignalRequestError.connect(
      this, &HangoutPubSubClient::OnPresenterRequestError);

  media_client_.reset(new PubSubClient(parent, mucjid, NS_GOOGLE_MUC_MEDIA));
  media_client_->SignalRequestError.connect(
      this, &HangoutPubSubClient::OnMediaRequestError);

  presenter_state_client_.reset(new PresenterStateClient(
      nick_, presenter_client_.get(), QN_PRESENTER_PRESENTER, false));
  presenter_state_client_->SignalStateChange.connect(
      this, &HangoutPubSubClient::OnPresenterStateChange);
  presenter_state_client_->SignalPublishResult.connect(
      this, &HangoutPubSubClient::OnPresenterPublishResult);
  presenter_state_client_->SignalPublishError.connect(
      this, &HangoutPubSubClient::OnPresenterPublishError);

  audio_mute_state_client_.reset(new PubSubStateClient<bool>(
      nick_, media_client_.get(), QN_GOOGLE_MUC_AUDIO_MUTE, false,
      new PublishedNickKeySerializer(), new BoolStateSerializer()));
  // Can't just repeat because we need to watch for remote mutes.
  audio_mute_state_client_->SignalStateChange.connect(
      this, &HangoutPubSubClient::OnAudioMuteStateChange);
  audio_mute_state_client_->SignalPublishResult.connect(
      this, &HangoutPubSubClient::OnAudioMutePublishResult);
  audio_mute_state_client_->SignalPublishError.connect(
      this, &HangoutPubSubClient::OnAudioMutePublishError);

  video_mute_state_client_.reset(new PubSubStateClient<bool>(
      nick_, media_client_.get(), QN_GOOGLE_MUC_VIDEO_MUTE, false,
      new PublishedNickKeySerializer(), new BoolStateSerializer()));
  // Can't just repeat because we need to watch for remote mutes.
  video_mute_state_client_->SignalStateChange.connect(
      this, &HangoutPubSubClient::OnVideoMuteStateChange);
  video_mute_state_client_->SignalPublishResult.connect(
      this, &HangoutPubSubClient::OnVideoMutePublishResult);
  video_mute_state_client_->SignalPublishError.connect(
      this, &HangoutPubSubClient::OnVideoMutePublishError);

  video_pause_state_client_.reset(new PubSubStateClient<bool>(
      nick_, media_client_.get(), QN_GOOGLE_MUC_VIDEO_PAUSE, false,
      new PublishedNickKeySerializer(), new BoolStateSerializer()));
  video_pause_state_client_->SignalStateChange.connect(
      this, &HangoutPubSubClient::OnVideoPauseStateChange);
  video_pause_state_client_->SignalPublishResult.connect(
      this, &HangoutPubSubClient::OnVideoPausePublishResult);
  video_pause_state_client_->SignalPublishError.connect(
      this, &HangoutPubSubClient::OnVideoPausePublishError);

  recording_state_client_.reset(new PubSubStateClient<bool>(
      nick_, media_client_.get(), QN_GOOGLE_MUC_RECORDING, false,
      new PublishedNickKeySerializer(), new BoolStateSerializer()));
  recording_state_client_->SignalStateChange.connect(
      this, &HangoutPubSubClient::OnRecordingStateChange);
  recording_state_client_->SignalPublishResult.connect(
      this, &HangoutPubSubClient::OnRecordingPublishResult);
  recording_state_client_->SignalPublishError.connect(
      this, &HangoutPubSubClient::OnRecordingPublishError);

  media_block_state_client_.reset(new PubSubStateClient<bool>(
      nick_, media_client_.get(), QN_GOOGLE_MUC_MEDIA_BLOCK, false,
      new PublisherAndPublishedNicksKeySerializer(),
      new BoolStateSerializer()));
  media_block_state_client_->SignalStateChange.connect(
      this, &HangoutPubSubClient::OnMediaBlockStateChange);
  media_block_state_client_->SignalPublishResult.connect(
      this, &HangoutPubSubClient::OnMediaBlockPublishResult);
  media_block_state_client_->SignalPublishError.connect(
      this, &HangoutPubSubClient::OnMediaBlockPublishError);
}

HangoutPubSubClient::~HangoutPubSubClient() {
}

void HangoutPubSubClient::RequestAll() {
  presenter_client_->RequestItems();
  media_client_->RequestItems();
}

void HangoutPubSubClient::OnPresenterRequestError(
    PubSubClient* client, const XmlElement* stanza) {
  SignalRequestError(client->node(), stanza);
}

void HangoutPubSubClient::OnMediaRequestError(
    PubSubClient* client, const XmlElement* stanza) {
  SignalRequestError(client->node(), stanza);
}

void HangoutPubSubClient::PublishPresenterState(
    bool presenting, std::string* task_id_out) {
  presenter_state_client_->Publish(nick_, presenting, task_id_out);
}

void HangoutPubSubClient::PublishAudioMuteState(
    bool muted, std::string* task_id_out) {
  audio_mute_state_client_->Publish(nick_, muted, task_id_out);
}

void HangoutPubSubClient::PublishVideoMuteState(
    bool muted, std::string* task_id_out) {
  video_mute_state_client_->Publish(nick_, muted, task_id_out);
}

void HangoutPubSubClient::PublishVideoPauseState(
    bool paused, std::string* task_id_out) {
  video_pause_state_client_->Publish(nick_, paused, task_id_out);
}

void HangoutPubSubClient::PublishRecordingState(
    bool recording, std::string* task_id_out) {
  recording_state_client_->Publish(nick_, recording, task_id_out);
}

// Remote mute is accomplished by setting another client's mute state.
void HangoutPubSubClient::RemoteMute(
    const std::string& mutee_nick, std::string* task_id_out) {
  audio_mute_state_client_->Publish(mutee_nick, true, task_id_out);
}

// Block media is accomplished by setting another client's block
// state, kind of like remote mute.
void HangoutPubSubClient::BlockMedia(
    const std::string& blockee_nick, std::string* task_id_out) {
  media_block_state_client_->Publish(blockee_nick, true, task_id_out);
}

void HangoutPubSubClient::OnPresenterStateChange(
    const PubSubStateChange<bool>& change) {
  SignalPresenterStateChange(
      change.published_nick, change.old_state, change.new_state);
}

void HangoutPubSubClient::OnPresenterPublishResult(
    const std::string& task_id, const XmlElement* item) {
  SignalPublishPresenterResult(task_id);
}

void HangoutPubSubClient::OnPresenterPublishError(
    const std::string& task_id, const XmlElement* item,
    const XmlElement* stanza) {
  SignalPublishPresenterError(task_id, stanza);
}

// Since a remote mute is accomplished by another client setting our
// mute state, if our state changes to muted, we should mute ourselves.
// Note that remote un-muting is disallowed by the RoomServer.
void HangoutPubSubClient::OnAudioMuteStateChange(
    const PubSubStateChange<bool>& change) {
  bool was_muted = change.old_state;
  bool is_muted = change.new_state;
  bool remote_action = (!change.publisher_nick.empty() &&
                        (change.publisher_nick != change.published_nick));
  if (remote_action) {
    const std::string& mutee_nick = change.published_nick;
    const std::string& muter_nick = change.publisher_nick;
    if (!is_muted) {
      // The server should prevent remote un-mute.
      LOG(LS_WARNING) << muter_nick << " remote unmuted " << mutee_nick;
      return;
    }
    bool should_mute_locally = (mutee_nick == nick_);
    SignalRemoteMute(mutee_nick, muter_nick, should_mute_locally);
  } else {
    SignalAudioMuteStateChange(change.published_nick, was_muted, is_muted);
  }
}

const std::string GetAudioMuteNickFromItem(const XmlElement* item) {
  if (item != NULL) {
    const XmlElement* audio_mute_state =
        item->FirstNamed(QN_GOOGLE_MUC_AUDIO_MUTE);
    if (audio_mute_state != NULL) {
      return audio_mute_state->Attr(QN_NICK);
    }
  }
  return std::string();
}

const std::string GetBlockeeNickFromItem(const XmlElement* item) {
  if (item != NULL) {
    const XmlElement* media_block_state =
        item->FirstNamed(QN_GOOGLE_MUC_MEDIA_BLOCK);
    if (media_block_state != NULL) {
      return media_block_state->Attr(QN_NICK);
    }
  }
  return std::string();
}

void HangoutPubSubClient::OnAudioMutePublishResult(
    const std::string& task_id, const XmlElement* item) {
  const std::string& mutee_nick = GetAudioMuteNickFromItem(item);
  if (mutee_nick != nick_) {
    SignalRemoteMuteResult(task_id, mutee_nick);
  } else {
    SignalPublishAudioMuteResult(task_id);
  }
}

void HangoutPubSubClient::OnAudioMutePublishError(
    const std::string& task_id, const XmlElement* item,
    const XmlElement* stanza) {
  const std::string& mutee_nick = GetAudioMuteNickFromItem(item);
  if (mutee_nick != nick_) {
    SignalRemoteMuteError(task_id, mutee_nick, stanza);
  } else {
    SignalPublishAudioMuteError(task_id, stanza);
  }
}

void HangoutPubSubClient::OnVideoMuteStateChange(
    const PubSubStateChange<bool>& change) {
  SignalVideoMuteStateChange(
      change.published_nick, change.old_state, change.new_state);
}

void HangoutPubSubClient::OnVideoMutePublishResult(
    const std::string& task_id, const XmlElement* item) {
  SignalPublishVideoMuteResult(task_id);
}

void HangoutPubSubClient::OnVideoMutePublishError(
    const std::string& task_id, const XmlElement* item,
    const XmlElement* stanza) {
  SignalPublishVideoMuteError(task_id, stanza);
}

void HangoutPubSubClient::OnVideoPauseStateChange(
    const PubSubStateChange<bool>& change) {
  SignalVideoPauseStateChange(
      change.published_nick, change.old_state, change.new_state);
}

void HangoutPubSubClient::OnVideoPausePublishResult(
    const std::string& task_id, const XmlElement* item) {
  SignalPublishVideoPauseResult(task_id);
}

void HangoutPubSubClient::OnVideoPausePublishError(
    const std::string& task_id, const XmlElement* item,
    const XmlElement* stanza) {
  SignalPublishVideoPauseError(task_id, stanza);
}

void HangoutPubSubClient::OnRecordingStateChange(
    const PubSubStateChange<bool>& change) {
  SignalRecordingStateChange(
      change.published_nick, change.old_state, change.new_state);
}

void HangoutPubSubClient::OnRecordingPublishResult(
    const std::string& task_id, const XmlElement* item) {
  SignalPublishRecordingResult(task_id);
}

void HangoutPubSubClient::OnRecordingPublishError(
    const std::string& task_id, const XmlElement* item,
    const XmlElement* stanza) {
  SignalPublishRecordingError(task_id, stanza);
}

void HangoutPubSubClient::OnMediaBlockStateChange(
    const PubSubStateChange<bool>& change) {
  const std::string& blockee_nick = change.published_nick;
  const std::string& blocker_nick = change.publisher_nick;

  bool was_blockee = change.old_state;
  bool is_blockee = change.new_state;
  if (!was_blockee && is_blockee) {
    SignalMediaBlock(blockee_nick, blocker_nick);
  }
  // TODO: Should we bother signaling unblock? Currently
  // it isn't allowed, but it might happen when a participant leaves
  // the room and the item is retracted.
}

void HangoutPubSubClient::OnMediaBlockPublishResult(
    const std::string& task_id, const XmlElement* item) {
  const std::string& blockee_nick = GetBlockeeNickFromItem(item);
  SignalMediaBlockResult(task_id, blockee_nick);
}

void HangoutPubSubClient::OnMediaBlockPublishError(
    const std::string& task_id, const XmlElement* item,
    const XmlElement* stanza) {
  const std::string& blockee_nick = GetBlockeeNickFromItem(item);
  SignalMediaBlockError(task_id, blockee_nick, stanza);
}

}  // namespace buzz


text:
/**
 * Created by foxmask on 12/04/17.
 */
$(document).on("click","a.btn.btn-md.btn-default", function () {
    triggerId = $(this).attr('data')
    var request = $.ajax({
        url: Urls.fire_trigger(triggerId),
        type: 'get',
        dataType: 'html',
        success: showResponse,
    });
    function showResponse(response) {
        $('#trigger-footer-'+triggerId).html(response);
    }
});

$(document).on("click","a.btn.btn-md.btn-primary, a.btn.btn-md.btn-success", function () {
    triggerId = $(this).attr('data')
    var request = $.ajax({
        url: Urls.trigger_on_off(triggerId),
        type: 'get',
        dataType: 'html',
        success: showResponse,
    });
    function showResponse(response) {
        $('#trigger-record-'+triggerId).html(response);
    }
});


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>Uses of Package games</title>
<meta name="date" content="2015-12-31">
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Use

Tree

Index

Help

Prev

Next

Frames

No Frames

All Classes

Uses of Package
games

Packages that use games

Package
Description

games

Implements all the logic for the games

gui

Implements the user interface

Classes in games used by games

Class and Description

Checkers2.CheckerCell

Game

Games superclass

Classes in games used by gui

Class and Description

Checkers2

This class implements the game Checkers (also known as Draughts).

GameOfLife

Implements Conway's "Game of Life" for use with the launchpad S

LightsOut

Implements Lights Out game

ReactionGame

Implements Reaction timing game - Whack a mole-like game

Simon

This class will implement the well know Simon game.

Snake

Implements Snake game

Skip navigation links

Overview

Package

Class

Use

Tree

Index

Help

Prev

Next

Frames

No Frames

All Classes


text:
package org.openntf.domino.impl;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import lotus.domino.NotesException;

import org.openntf.domino.DateTime;
import org.openntf.domino.NotesCalendarEntry;
import org.openntf.domino.NotesCalendarNotice;
import org.openntf.domino.Session;
import org.openntf.domino.WrapperFactory;
import org.openntf.domino.utils.DominoUtils;

// TODO: Auto-generated Javadoc
/**
 * The Class NotesCalendar.
 */
public class NotesCalendar extends BaseThreadSafe<org.openntf.domino.NotesCalendar, lotus.domino.NotesCalendar, Session>
		implements org.openntf.domino.NotesCalendar {

	/**
	 * Instantiates a new outline.
	 *
	 * @param delegate
	 *            the delegate
	 * @param parent
	 *            the parent
	 */
	protected NotesCalendar(final lotus.domino.NotesCalendar delegate, final Session parent) {
		super(delegate, parent, NOTES_OUTLINE);
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#createEntry(java.lang.String)
	 */
	@Override
	public NotesCalendarEntry createEntry(final String iCalEntry) {
		try {
			return fromLotus(getDelegate().createEntry(iCalEntry), NotesCalendarEntry.SCHEMA, this);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return null;
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#createEntry(java.lang.String, int)
	 */
	@Override
	public NotesCalendarEntry createEntry(final String iCalEntry, final int flags) {
		try {
			return fromLotus(getDelegate().createEntry(iCalEntry, flags), NotesCalendarEntry.SCHEMA, this);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return null;
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getAutoSendNotices()
	 */
	@Override
	public boolean getAutoSendNotices() {
		try {
			return getDelegate().getAutoSendNotices();
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return false;
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getEntries(lotus.domino.DateTime, lotus.domino.DateTime)
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public Vector<org.openntf.domino.NotesCalendarEntry> getEntries(final lotus.domino.DateTime start, final lotus.domino.DateTime end) {
		List recycleThis = new ArrayList();
		try {
			lotus.domino.DateTime dt1 = toLotus(start, recycleThis);
			lotus.domino.DateTime dt2 = toLotus(end, recycleThis);
			return fromLotusAsVector(getDelegate().getEntries(dt1, dt2), org.openntf.domino.NotesCalendarEntry.SCHEMA, this);

		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return null;
		} finally {
			s_recycle(recycleThis);
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getEntries(lotus.domino.DateTime, lotus.domino.DateTime, int, int)
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public Vector<org.openntf.domino.NotesCalendarEntry> getEntries(final lotus.domino.DateTime start, final lotus.domino.DateTime end,
			final int skipCount, final int maxReturn) {
		List recycleThis = new ArrayList();
		try {
			lotus.domino.DateTime dt1 = toLotus(start, recycleThis);
			lotus.domino.DateTime dt2 = toLotus(end, recycleThis);
			return fromLotusAsVector(getDelegate().getEntries(dt1, dt2, skipCount, maxReturn), org.openntf.domino.NotesCalendarEntry.SCHEMA,
					this);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return null;
		} finally {
			s_recycle(recycleThis);
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getEntriesProcessed()
	 */
	@Override
	public int getEntriesProcessed() {
		try {
			return getDelegate().getEntriesProcessed();
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return 0;
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getEntry(java.lang.String)
	 */
	@Override
	public NotesCalendarEntry getEntry(final String uid) {
		try {
			return fromLotus(getDelegate().getEntry(uid), NotesCalendarEntry.SCHEMA, this);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return null;
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getEntryByNoteID(java.lang.String)
	 */
	@Override
	public NotesCalendarEntry getEntryByNoteID(final String noteid) {
		try {
			return fromLotus(getDelegate().getEntryByNoteID(noteid), NotesCalendarEntry.SCHEMA, this);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return null;
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getEntryByUNID(java.lang.String)
	 */
	@Override
	public NotesCalendarEntry getEntryByUNID(final String unid) {
		try {
			return fromLotus(getDelegate().getEntryByUNID(unid), NotesCalendarEntry.SCHEMA, this);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return null;
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getNewInvitations()
	 */
	@Override
	public Vector<org.openntf.domino.NotesCalendarNotice> getNewInvitations() {
		try {
			return fromLotusAsVector(getDelegate().getNewInvitations(), NotesCalendarNotice.SCHEMA, this);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return null;
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getNewInvitations(lotus.domino.DateTime, lotus.domino.DateTime)
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public Vector<org.openntf.domino.NotesCalendarNotice> getNewInvitations(final lotus.domino.DateTime start,
			final lotus.domino.DateTime since) {
		List recycleThis = new ArrayList();
		try {
			lotus.domino.DateTime dt1 = toLotus(start, recycleThis);
			lotus.domino.DateTime dt2 = toLotus(since, recycleThis);
			return fromLotusAsVector(getDelegate().getNewInvitations(dt1, dt2), NotesCalendarNotice.SCHEMA, this);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return null;
		} finally {
			s_recycle(recycleThis);
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getNoticeByUNID(java.lang.String)
	 */
	@Override
	public NotesCalendarNotice getNoticeByUNID(final String unid) {
		try {
			return fromLotus(getDelegate().getNoticeByUNID(unid), NotesCalendarNotice.SCHEMA, this);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return null;
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.impl.Base#getParent()
	 */
	@Override
	public final Session getParent() {
		return parent;
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getReadRangeMask1()
	 */
	@Override
	public int getReadRangeMask1() {
		try {
			return getDelegate().getReadRangeMask1();
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return 0;
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getReadRangeMask2()
	 */
	@Override
	public int getReadRangeMask2() {
		try {
			return getDelegate().getReadRangeMask2();
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return 0;
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getReadXLotusPropsOutputLevel()
	 */
	@Override
	public int getReadXLotusPropsOutputLevel() {
		try {
			return getDelegate().getReadXLotusPropsOutputLevel();
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return 0;
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getUntilTime()
	 */
	@Override
	public DateTime getUntilTime() {
		try {
			return fromLotus(getDelegate().getUntilTime(), DateTime.SCHEMA, getAncestorSession());
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return null;
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#readRange(lotus.domino.DateTime, lotus.domino.DateTime)
	 */
	@Override
	public String readRange(final lotus.domino.DateTime start, final lotus.domino.DateTime end) {
		@SuppressWarnings("rawtypes")
		List recycleThis = new ArrayList();
		try {
			lotus.domino.DateTime dt1 = toLotus(start, recycleThis);
			lotus.domino.DateTime dt2 = toLotus(end, recycleThis);
			return getDelegate().readRange(dt1, dt2);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return null;
		} finally {
			s_recycle(recycleThis);
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#readRange(lotus.domino.DateTime, lotus.domino.DateTime, int, int)
	 */
	@Override
	public String readRange(final lotus.domino.DateTime start, final lotus.domino.DateTime end, final int skipCount, final int maxRead) {
		@SuppressWarnings("rawtypes")
		List recycleThis = new ArrayList();
		try {
			lotus.domino.DateTime dt1 = toLotus(start, recycleThis);
			lotus.domino.DateTime dt2 = toLotus(end, recycleThis);
			return getDelegate().readRange(dt1, dt2, skipCount, maxRead);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return null;
		} finally {
			s_recycle(recycleThis);
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#setAutoSendNotices(boolean)
	 */
	@Override
	public void setAutoSendNotices(final boolean flag) {
		try {
			getDelegate().setAutoSendNotices(flag);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#setReadRangeMask1(int)
	 */
	@Override
	public void setReadRangeMask1(final int mask) {
		try {
			getDelegate().setReadRangeMask1(mask);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#setReadRangeMask2(int)
	 */
	@Override
	public void setReadRangeMask2(final int mask) {
		try {
			getDelegate().setReadRangeMask2(mask);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#setReadXLotusPropsOutputLevel(int)
	 */
	@Override
	public void setReadXLotusPropsOutputLevel(final int level) {
		try {
			getDelegate().setReadXLotusPropsOutputLevel(level);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
		}
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.openntf.domino.types.SessionDescendant#getAncestorSession()
	 */
	@Override
	public final Session getAncestorSession() {
		return parent;
	}

	/* (non-Javadoc)
	 * @see lotus.domino.NotesCalendar#getApptunidFromUID(java.lang.String)
	 */
	@Override
	public String getApptunidFromUID(final String arg0) {
		try {
			return getDelegate().getApptunidFromUID(arg0);
		} catch (NotesException e) {
			DominoUtils.handleException(e);
			return null;
		}
	}

	/* (non-Javadoc)
	 * @see org.openntf.domino.NotesCalendar#getApptunidFromUID(java.lang.String, boolean)
	 */
	@Override
	@SuppressWarnings("nls")
	public String getApptunidFromUID(final String arg0, final boolean arg1) {
		String result = null;
		Class<?> klazz = getDelegate().getClass();
		try {
			Method chkMethod = klazz.getMethod("getApptunidFromUID", String.class, Boolean.TYPE); //$NON-NLS-1$
			try {
				result = (String) chkMethod.invoke(getDelegate(), arg0, arg1);
			} catch (IllegalArgumentException e) {
				DominoUtils.handleException(e);
			} catch (IllegalAccessException e) {
				DominoUtils.handleException(e);
			} catch (InvocationTargetException e) {
				DominoUtils.handleException(e);
			}
		} catch (SecurityException e) {
			DominoUtils.handleException(e);
		} catch (NoSuchMethodException e) {
			Exception noMethod = new RuntimeException("Method is not available on this version of Domino", e);
			DominoUtils.handleException(noMethod);
		}
		return result;
	}

	@Override
	protected WrapperFactory getFactory() {
		return parent.getFactory();
	}

	@Override
	public boolean getActAsDbOwner() {
		try {
			return getDelegate().getActAsDbOwner();
		} catch (Exception e) {
			DominoUtils.handleException(e);
		}
		return false;
	}

	@Override
	public boolean getAutoRemoveProcessedNotices() {
		try {
			return getDelegate().getAutoRemoveProcessedNotices();
		} catch (Exception e) {
			DominoUtils.handleException(e);
		}
		return false;
	}

	@Override
	public String getRecurrenceID(final lotus.domino.DateTime arg0) {
		try {
			return getDelegate().getRecurrenceID(arg0);
		} catch (Exception e) {
			DominoUtils.handleException(e);
		}
		return null;
	}

	@Override
	public void setActAsDbOwner(final boolean arg0) {
		try {
			getDelegate().setActAsDbOwner(arg0);
		} catch (Exception e) {
			DominoUtils.handleException(e);
		}
	}

	@Override
	public void setAutoRemoveProcessedNotices(final boolean arg0) {
		try {
			getDelegate().setAutoRemoveProcessedNotices(arg0);
		} catch (Exception e) {
			DominoUtils.handleException(e);
		}
	}

}


text:
package com.github.trancee.fernet;

import java.security.GeneralSecurityException;

public class FernetException extends GeneralSecurityException {
	private static final long serialVersionUID = 1L;

	public FernetException(String message) {
		super(message);
	}
	public FernetException(Exception exception) {
		super(exception);
	}
}


text:
angular.module('jupiterApp').directive('ngEnter', function () {
    return function (scope, element, attrs) {
        element.bind("keydown keypress", function (event) {
            if(event.which === 13) {
                scope.$apply(function (){
                    scope.$eval(attrs.ngEnter);
                });

                event.preventDefault();
            }
        });
    };
});