text:
import {ParamMap} from '@angular/router';
import {LoggerFactory} from '@elderbyte/ts-logger';

export class ParamsUtil {

    private static readonly logger = LoggerFactory.getLogger('ParamsUtil');

    public static parseParams(params: string): Map<string, string> {

        params = params.trim();

        // Remove hash at beginning

        if (params.startsWith('#')) {
            params = params.substr(1).trim();
        }

        return ParamsUtil.decodeURLParams(params);
    }

    public static params(
        queryParams: URLSearchParams,
        fragmentParams: URLSearchParams
    ): Map<string, string> {

        return ParamsUtil.merge(
            ParamsUtil.searchParams(queryParams),
            ParamsUtil.searchParams(fragmentParams)
        );
    }

    public static queryParams(queryParams: ParamMap): Map<string, string> {
        const params = new Map<string, string>();
        queryParams.keys.forEach(k => params.set(k, queryParams.get(k)));
        return params;
    }

    public static searchParams(urlparams: URLSearchParams): Map<string, string> {
        const params = new Map<string, string>();
        urlparams.forEach((value, key, parent) => params.set(key, value));
        return params;
    }

    public static merge<K, V>(map1: Map<K, V>, map2: Map<K, V>): Map<K, V> {
        return new Map(
            [
                ...Array.from(map1.entries()),
                ...Array.from(map2.entries())
            ]
        );
    }

    private static decodeURLParams(search: string): Map<string, string> {

        const hashes = search.slice(search.indexOf('?') + 1).split('&');

        const params = new Map<string, string>();

        hashes
            .filter(hash => !!hash && hash.length > 0)
            .forEach(hash => {

            const mid = hash.indexOf('=');

            if (mid) {
                const key = hash.slice(0, mid);
                if (key) {
                    params.set(
                        key,
                        decodeURIComponent(hash.slice(mid + 1))
                    );
                }
            } else {
                params.set(hash, null);
            }
        });

        return params;
    }

}


text:
Sequel.migration do
  change do
    create_table :reg_c420 do
      column :id, Integer, primary_key: true
      column :id_pai, Integer, index: true, null: false
      column :cod_tot_par, String, size: 7
      column :vlr_acum_tot, BigDecimal, size: [18, 2]
      column :nr_tot, String, size: 2
      column :descr_nr_tot, String, size: 1000
      column :cnpj_pai, String, size: 14, index: true
    end
  end
end

redpajama_set_name: RedPajamaGithub


text:
import os

import pytest

def pytest_addoption(parser):
    parser.addoption("--datadir",
                     help="path to data files")

def pytest_generate_tests(metafunc):
    if 'base_url' in metafunc.fixturenames:
        if metafunc.config.option.datadir:
            base_url = ('file://'
                        + os.path.abspath(metafunc.config.option.datadir)
                        + os.sep)
        else:
            base_url = 'http://hgdownload.cse.ucsc.edu/goldenpath/hg19/database/'
            # Mirror. Slightly faster and more stable, I believe -KT

            base_url = 'http://kt.era.ee/distribute/pyintervaltree/'
        metafunc.parametrize('base_url',[base_url])


text:
from __future__ import division, unicode_literals

import re
import numpy as np

from monty.io import zopen
from pymatgen.electronic_structure.core import Spin, Orbital

"""
Module for reading Lobster output files. For more information
on LOBSTER see www.cohp.de.
"""

__author__ = "Marco Esters"
__copyright__ = "Copyright 2017, The Materials Project"
__version__ = "0.2"
__maintainer__ = "Marco Esters"
__email__ = "esters@uoregon.edu"
__date__ = "Dec 13, 2017"

class Cohpcar(object):
    """
    Class to read COHPCAR/COOPCAR files generated by LOBSTER.

    Args:
        are_coops: Determines if the file is a list of COHPs or COOPs.
          Default is False for COHPs.

        filename: Name of the COHPCAR file. If it is None, the default
          file name will be chosen, depending on the value of are_coops.

    .. attribute: cohp_data

         Dict that contains the COHP data of the form:
           {bond: {"COHP": {Spin.up: cohps, Spin.down:cohps},
                   "ICOHP": {Spin.up: icohps, Spin.down: icohps},
                   "length": bond length}
         Also contains an entry for the average, which does not have
         a "length" key.

    .. attribute: efermi

         The Fermi energy in eV.

    .. attribute: energies

         Sequence of energies in eV. Note that LOBSTER shifts the energies
         so that the Fermi energy is at zero.

    .. attribute: is_spin_polarized

         Boolean to indicate if the calculation is spin polarized.
    """
    def __init__(self, are_coops=False, filename=None):
        self.are_coops = are_coops
        if filename is None:
            filename = "COOPCAR.lobster" if are_coops \
                        else "COHPCAR.lobster"

        with zopen(filename, "rt") as f:
            contents = f.read().split("\n")

        # The parameters line is the second line in a COHPCAR file. It
        # contains all parameters that are needed to map the file.
        parameters = contents[1].split()
        # Subtract 1 to skip the average
        num_bonds = int(parameters[0]) - 1
        self.efermi = float(parameters[-1])
        if int(parameters[1]) == 2:
            spins = [Spin.up, Spin.down]
            self.is_spin_polarized = True
        else:
            spins = [Spin.up]
            self.is_spin_polarized = False

        # The COHP data start in row num_bonds + 3
        data = np.array([np.array(row.split(), dtype=float)
                         for row in contents[num_bonds+3:]]).transpose()
        self.energies = data[0]

        cohp_data = {"average": {"COHP": {spin: data[1+2*s*(num_bonds+1)]
                                          for s, spin in enumerate(spins)},
                                 "ICOHP": {spin: data[2+2*s*(num_bonds+1)]
                                           for s, spin in enumerate(spins)}}}
        orb_cohp = {}
        for bond in range(num_bonds):
            bond_data = self._get_bond_data(contents[3+bond])
            label = bond_data["label"]
            orbs = bond_data["orbitals"]
            cohp = {spin: data[2*(bond+s*(num_bonds+1))+3]
                    for s, spin in enumerate(spins)}
            icohp = {spin: data[2*(bond+s*(num_bonds+1))+4]
                     for s, spin in enumerate(spins)}
            if orbs is None:
                cohp_data[label] = {"COHP": cohp, "ICOHP": icohp,
                                    "length": bond_data["length"],
                                    "sites": bond_data["sites"]}
            elif label in orb_cohp:
                orb_cohp[label].update({bond_data["orb_label"]:
                                        {"COHP": cohp, "ICOHP": icohp,
                                         "orbitals": orbs}})
            else:
                if label not in cohp_data:
                    cohp_data[label] = {"COHP": None, "ICOHP": None,
                                        "length": bond_data["length"],
                                        "sites": bond_data["sites"]}
                orb_cohp[label] = {bond_data["orb_label"]: {"COHP": cohp,
                                                            "ICOHP": icohp,
                                                            "orbitals": orbs}}

        self.orb_res_cohp = orb_cohp if orb_cohp else None
        self.cohp_data = cohp_data

    @staticmethod
    def _get_bond_data(line):
        """
        Subroutine to extract bond label, site indices, and length from
        a LOBSTER header line. The site indices are zero-based, so they
        can be easily used with a Structure object.

        Example header line: No.4:Fe1->Fe9(2.4524893531900283)
        Example header line for orbtial-resolved COHP:
            No.1:Fe1[3p_x]->Fe2[3d_x^2-y^2](2.456180552772262)

        Args:
            line: line in the COHPCAR header describing the bond.

        Returns:
            Dict with the bond label, the bond length, a tuple of the site
            indices, a tuple containing the orbitals (if orbital-resolved),
            and a label for the orbitals (if orbital-resolved).
        """

        orb_labs = ["s", "p_y", "p_z", "p_x", "d_xy", "d_yz", "d_z^2",
                    "d_xz", "d_x^2-y^2", "4f_y(3x^2-y^2)", "4f_xyz",
                    "4f_yz^2", "4f_z^3", "4f_xz^2", "4f_z(x^2-y^2)"]

        line = line.split("(")
        length = float(line[-1][:-1])
        # Replacing "->" with ":" makes splitting easier
        sites = line[0].replace("->", ":").split(":")[1:3]
        site_indices = tuple(int(re.split(r"\D+", site)[1]) - 1
                             for site in sites)
        species = tuple(re.split(r"\d+", site)[0] for site in sites)
        if "[" in sites[0]:
            orbs = [re.findall(r"\[(.*)\]", site)[0] for site in sites]
            orbitals = [tuple((int(orb[0]), Orbital(orb_labs.index(orb[1:]))))
                        for orb in orbs]
            orb_label = "%d%s-%d%s" % (orbitals[0][0], orbitals[0][1].name,
                                       orbitals[1][0], orbitals[1][1].name)
        else:
            orbitals = None
            orb_label = None

        label = "%s%d-%s%d" % (species[0], site_indices[0] + 1,
                               species[1], site_indices[1] + 1)
        bond_data = {"label": label, "length": length, "sites": site_indices,
                     "orbitals": orbitals, "orb_label": orb_label}
        return bond_data

class Icohplist(object):
    """
    Class to read ICOHPLIST/ICOOPLIST files generated by LOBSTER.

    Args:
        are_coops: Determines if the file is a list of ICOHPs or ICOOPs.
          Defaults to False for ICOHPs.

        filename: Name of the ICOHPLIST file. If it is None, the default
          file name will be chosen, depending on the value of are_coops.

    .. attribute: are_coops

         Boolean to indicate if the populations are COOPs or COHPs.

    .. attribute: is_spin_polarized

         Boolean to indicate if the calculation is spin polarized.

    .. attribute: icohplist

         Dict containing the listfile data of the form:
           {bond: "length": bond length,
                  "number_of_bonds": number of bonds
                  "icohp": {Spin.up: ICOHP(Ef) spin up, Spin.down: ...}}
    """
    def __init__(self, are_coops=False, filename=None):
        self.are_coops = are_coops
        if filename is None:
            filename = "ICOOPLIST.lobster" if are_coops \
                        else "ICOHPLIST.lobster"

        # LOBSTER list files have an extra trailing blank line
        # and we don't need the header.
        with zopen(filename) as f:
            data = f.read().split("\n")[1:-1]

        if len(data) == 0:
            raise IOError("ICOHPLIST file contains no data.")

        # If the calculation is spin polarized, the line in the middle
        # of the file will be another header line.
        if "distance" in data[len(data)//2]:
            num_bonds = len(data)//2
            if num_bonds == 0:
                raise IOError("ICOHPLIST file contains no data.")
            self.is_spin_polarized = True
        else:
            num_bonds = len(data)
            self.is_spin_polarized = False

        icohplist = {}
        for bond in range(num_bonds):
            line = data[bond].split()
            label = "%s-%s" % (line[1], line[2])
            length = float(line[3])
            icohp = float(line[4])
            num = int(line[5])
            icohplist[label] = {"length": length, "number_of_bonds": num,
                                "icohp": {Spin.up: icohp}}
            if self.is_spin_polarized:
                icohp = float(data[bond+num_bonds+1].split()[4])
                icohplist[label]["icohp"][Spin.down] = icohp

        self.icohplist = icohplist


text:
ansible-role-postfix
====================

Ansible for manage Postfix


text:
<?php
class Kwc_Advanced_Team_Member_Data_Model extends Kwf_Component_FieldModel
{
    protected $_rowClass = 'Kwc_Advanced_Team_Member_Data_Row';
}


text:
import pytest

from nbgrader.tests.formgrader.manager import HubAuthManager
from nbgrader.tests.formgrader.conftest import jupyterhub, minversion

@jupyterhub
@minversion
@pytest.mark.js
def test_configproxy_auth_success(gradebook, tempdir):
    """Can the formgrader be started with the correct auth token?"""

    man = HubAuthManager(tempdir)
    man._write_config()

    man._start_jupyterhub(configproxy_auth_token='foo')
    man._start_formgrader(configproxy_auth_token='foo')

    assert man.jupyterhub.poll() is None
    assert man.formgrader.poll() is None

    man._stop_formgrader()
    man._stop_jupyterhub()

    assert man.formgrader.poll() == 0
    assert man.jupyterhub.poll() == 0

@jupyterhub
@minversion
@pytest.mark.js
def test_configproxy_auth_failure(gradebook, tempdir):
    """Can the formgrader not be started when the auth token is incorrect?"""

    man = HubAuthManager(tempdir)
    man._write_config()

    man._start_jupyterhub(configproxy_auth_token='foo')
    man._start_formgrader(configproxy_auth_token='bar')

    assert man.jupyterhub.poll() is None
    assert man.formgrader.poll() == 1

    man._stop_jupyterhub()

    assert man.jupyterhub.poll() == 0


text:
const profile = require('../../lib/commands/commandsProfile');

describe('profile', () => {
  describe('when there is no profile', () => {
    describe('current profile', () => {
      it('should be undefined', () => {
        expect(profile.current()).toBeUndefined();
      });
    });
  });

  describe('create "default" profile', () => {
    let defaultProfile;

    beforeAll(() => {
      defaultProfile = profile.get('default');
    });

    it('returns the profile object', () => {
      expect(defaultProfile.commands).not.toBeUndefined();
      expect(defaultProfile.setRawMode).not.toBeUndefined();
      expect(defaultProfile.getRawMode).not.toBeUndefined();
    });

    it('returns the commands object', () => {
      expect(defaultProfile.commands().get).not.toBeUndefined();
      expect(defaultProfile.commands().add).not.toBeUndefined();
      expect(defaultProfile.commands().forEach).not.toBeUndefined();
    });

    it('should not create a new instance for the same profile', () => {
      expect(profile.get('default')).toBe(defaultProfile);
    });

    describe('when rawMode is true', () => {
      it('returns false', () => {
        expect(defaultProfile.getRawMode()).toBeFalsy();
      });
    });

    describe('when rawMode is true', () => {
      let setRawMode;

      describe('when stdin isTTY is true', () => {
        beforeEach(() => {
          setRawMode = jest.fn();

          Object.defineProperty(process, 'stdin', {
    				value: {
              isTTY: true,
              setRawMode: setRawMode
            },
    				configurable: true,
    				writable: false
    			});

        	defaultProfile.setRawMode(true);

          profile.define('default');
        });

        it('calls setRawMode', () => {
          expect(process.stdin.setRawMode).toHaveBeenCalledWith(true);
        });

        it('returns true', () => {
          expect(defaultProfile.getRawMode).toBeTruthy();
        });
      });

      describe('when stdin isTTY is false', () => {
        beforeEach(() => {
          setRawMode = jest.fn();

          Object.defineProperty(process, 'stdin', {
    				value: {
              isTTY: false,
              setRawMode: setRawMode
            },
    				configurable: true,
    				writable: false
    			});

        	defaultProfile.setRawMode(true);

          profile.define('default');
        });

        it('does not call setRawMode', () => {
          expect(process.stdin.setRawMode).not.toHaveBeenCalled();
        });
      });
    });

    describe('define "default" as current profile', () => {
      beforeEach(() => {
        profile.define('default');
      });

      it('should be "default"', () => {
        expect(profile.current()).toEqual(defaultProfile);
      });
    });

    afterAll(() => {
      profile.remove('default');
    });
  });
});


text:
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE476_NULL_Pointer_Dereference__int64_t_68b.c
Label Definition File: CWE476_NULL_Pointer_Dereference.label.xml
Template File: sources-sinks-68b.tmpl.c
*/
/*
 * @description
 * CWE: 476 NULL Pointer Dereference
 * BadSource:  Set data to NULL
 * GoodSource: Initialize data
 * Sinks:
 *    GoodSink: Check for NULL before attempting to print data
 *    BadSink : Print data
 * Flow Variant: 68 Data flow: data passed as a global variable from one function to another in different source files
 *
 * */

#include "std_testcase.h"

#include <wchar.h>

extern int64_t * CWE476_NULL_Pointer_Dereference__int64_t_68_badData;
extern int64_t * CWE476_NULL_Pointer_Dereference__int64_t_68_goodG2BData;
extern int64_t * CWE476_NULL_Pointer_Dereference__int64_t_68_goodB2GData;

#ifndef OMITBAD

void CWE476_NULL_Pointer_Dereference__int64_t_68b_badSink()
{
    int64_t * data = CWE476_NULL_Pointer_Dereference__int64_t_68_badData;
    /* POTENTIAL FLAW: Attempt to use data, which may be NULL */
    printLongLongLine(*data);
}

#endif /* OMITBAD */

#ifndef OMITGOOD

/* goodG2B uses the GoodSource with the BadSink */
void CWE476_NULL_Pointer_Dereference__int64_t_68b_goodG2BSink()
{
    int64_t * data = CWE476_NULL_Pointer_Dereference__int64_t_68_goodG2BData;
    /* POTENTIAL FLAW: Attempt to use data, which may be NULL */
    printLongLongLine(*data);
}

/* goodB2G uses the BadSource with the GoodSink */
void CWE476_NULL_Pointer_Dereference__int64_t_68b_goodB2GSink()
{
    int64_t * data = CWE476_NULL_Pointer_Dereference__int64_t_68_goodB2GData;
    /* FIX: Check for NULL before attempting to print data */
    if (data != NULL)
    {
        printLongLongLine(*data);
    }
    else
    {
        printLine("data is NULL");
    }
}

#endif /* OMITGOOD */


text:
package com.artemis.reference;

import com.artemis.Component;

public class Cullible extends Component {

}