text:
"""Common objects shared by all _ps* modules."""

from __future__ import division
import errno
import functools
import os
import socket
import stat
import sys
from collections import namedtuple
from socket import AF_INET, SOCK_STREAM, SOCK_DGRAM
try:
    import threading
except ImportError:
    import dummy_threading as threading

if sys.version_info >= (3, 4):
    import enum
else:
    enum = None

# --- constants

AF_INET6 = getattr(socket, 'AF_INET6', None)
AF_UNIX = getattr(socket, 'AF_UNIX', None)

STATUS_RUNNING = "running"
STATUS_SLEEPING = "sleeping"
STATUS_DISK_SLEEP = "disk-sleep"
STATUS_STOPPED = "stopped"
STATUS_TRACING_STOP = "tracing-stop"
STATUS_ZOMBIE = "zombie"
STATUS_DEAD = "dead"
STATUS_WAKE_KILL = "wake-kill"
STATUS_WAKING = "waking"
STATUS_IDLE = "idle"  # BSD
STATUS_LOCKED = "locked"  # BSD
STATUS_WAITING = "waiting"  # BSD

CONN_ESTABLISHED = "ESTABLISHED"
CONN_SYN_SENT = "SYN_SENT"
CONN_SYN_RECV = "SYN_RECV"
CONN_FIN_WAIT1 = "FIN_WAIT1"
CONN_FIN_WAIT2 = "FIN_WAIT2"
CONN_TIME_WAIT = "TIME_WAIT"
CONN_CLOSE = "CLOSE"
CONN_CLOSE_WAIT = "CLOSE_WAIT"
CONN_LAST_ACK = "LAST_ACK"
CONN_LISTEN = "LISTEN"
CONN_CLOSING = "CLOSING"
CONN_NONE = "NONE"

if enum is None:
    NIC_DUPLEX_FULL = 2
    NIC_DUPLEX_HALF = 1
    NIC_DUPLEX_UNKNOWN = 0
else:
    class NicDuplex(enum.IntEnum):
        NIC_DUPLEX_FULL = 2
        NIC_DUPLEX_HALF = 1
        NIC_DUPLEX_UNKNOWN = 0

    globals().update(NicDuplex.__members__)

# --- functions

def usage_percent(used, total, _round=None):
    """Calculate percentage usage of 'used' against 'total'."""
    try:
        ret = (used / total) * 100
    except ZeroDivisionError:
        ret = 0
    if _round is not None:
        return round(ret, _round)
    else:
        return ret

def memoize(fun):
    """A simple memoize decorator for functions supporting (hashable)
    positional arguments.
    It also provides a cache_clear() function for clearing the cache:

    >>> @memoize
    ... def foo()
    ...     return 1
    ...
    >>> foo()
    1
    >>> foo.cache_clear()
    >>>
    """
    @functools.wraps(fun)
    def wrapper(*args, **kwargs):
        key = (args, frozenset(sorted(kwargs.items())))
        lock.acquire()
        try:
            try:
                return cache[key]
            except KeyError:
                ret = cache[key] = fun(*args, **kwargs)
        finally:
            lock.release()
        return ret

    def cache_clear():
        """Clear cache."""
        lock.acquire()
        try:
            cache.clear()
        finally:
            lock.release()

    lock = threading.RLock()
    cache = {}
    wrapper.cache_clear = cache_clear
    return wrapper

def isfile_strict(path):
    """Same as os.path.isfile() but does not swallow EACCES / EPERM
    exceptions, see:
    http://mail.python.org/pipermail/python-dev/2012-June/120787.html
    """
    try:
        st = os.stat(path)
    except OSError as err:
        if err.errno in (errno.EPERM, errno.EACCES):
            raise
        return False
    else:
        return stat.S_ISREG(st.st_mode)

def sockfam_to_enum(num):
    """Convert a numeric socket family value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    """
    if enum is None:
        return num
    try:
        return socket.AddressFamily(num)
    except (ValueError, AttributeError):
        return num

def socktype_to_enum(num):
    """Convert a numeric socket type value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    """
    if enum is None:
        return num
    try:
        return socket.AddressType(num)
    except (ValueError, AttributeError):
        return num

# --- Process.connections() 'kind' parameter mapping

conn_tmap = {
    "all": ([AF_INET, AF_INET6, AF_UNIX], [SOCK_STREAM, SOCK_DGRAM]),
    "tcp": ([AF_INET, AF_INET6], [SOCK_STREAM]),
    "tcp4": ([AF_INET], [SOCK_STREAM]),
    "udp": ([AF_INET, AF_INET6], [SOCK_DGRAM]),
    "udp4": ([AF_INET], [SOCK_DGRAM]),
    "inet": ([AF_INET, AF_INET6], [SOCK_STREAM, SOCK_DGRAM]),
    "inet4": ([AF_INET], [SOCK_STREAM, SOCK_DGRAM]),
    "inet6": ([AF_INET6], [SOCK_STREAM, SOCK_DGRAM]),
}

if AF_INET6 is not None:
    conn_tmap.update({
        "tcp6": ([AF_INET6], [SOCK_STREAM]),
        "udp6": ([AF_INET6], [SOCK_DGRAM]),
    })

if AF_UNIX is not None:
    conn_tmap.update({
        "unix": ([AF_UNIX], [SOCK_STREAM, SOCK_DGRAM]),
    })

del AF_INET, AF_INET6, AF_UNIX, SOCK_STREAM, SOCK_DGRAM

# --- namedtuples for psutil.* system-related functions

# psutil.swap_memory()
sswap = namedtuple('sswap', ['total', 'used', 'free', 'percent', 'sin',
                             'sout'])
# psutil.disk_usage()
sdiskusage = namedtuple('sdiskusage', ['total', 'used', 'free', 'percent'])
# psutil.disk_io_counters()
sdiskio = namedtuple('sdiskio', ['read_count', 'write_count',
                                 'read_bytes', 'write_bytes',
                                 'read_time', 'write_time'])
# psutil.disk_partitions()
sdiskpart = namedtuple('sdiskpart', ['device', 'mountpoint', 'fstype', 'opts'])
# psutil.net_io_counters()
snetio = namedtuple('snetio', ['bytes_sent', 'bytes_recv',
                               'packets_sent', 'packets_recv',
                               'errin', 'errout',
                               'dropin', 'dropout'])
# psutil.users()
suser = namedtuple('suser', ['name', 'terminal', 'host', 'started'])
# psutil.net_connections()
sconn = namedtuple('sconn', ['fd', 'family', 'type', 'laddr', 'raddr',
                             'status', 'pid'])
# psutil.net_if_addrs()
snic = namedtuple('snic', ['family', 'address', 'netmask', 'broadcast', 'ptp'])
# psutil.net_if_stats()
snicstats = namedtuple('snicstats', ['isup', 'duplex', 'speed', 'mtu'])

# --- namedtuples for psutil.Process methods

# psutil.Process.memory_info()
pmem = namedtuple('pmem', ['rss', 'vms'])
# psutil.Process.cpu_times()
pcputimes = namedtuple('pcputimes', ['user', 'system'])
# psutil.Process.open_files()
popenfile = namedtuple('popenfile', ['path', 'fd'])
# psutil.Process.threads()
pthread = namedtuple('pthread', ['id', 'user_time', 'system_time'])
# psutil.Process.uids()
puids = namedtuple('puids', ['real', 'effective', 'saved'])
# psutil.Process.gids()
pgids = namedtuple('pgids', ['real', 'effective', 'saved'])
# psutil.Process.io_counters()
pio = namedtuple('pio', ['read_count', 'write_count',
                         'read_bytes', 'write_bytes'])
# psutil.Process.ionice()
pionice = namedtuple('pionice', ['ioclass', 'value'])
# psutil.Process.ctx_switches()
pctxsw = namedtuple('pctxsw', ['voluntary', 'involuntary'])
# psutil.Process.connections()
pconn = namedtuple('pconn', ['fd', 'family', 'type', 'laddr', 'raddr',
                             'status'])


text:
#include <errno.h>
#include <stddef.h>
#include <unistd.h>

/* Get file-specific information about PATH.  */
long int
__pathconf (path, name)
     const char *path;
     int name;
{
  if (path == NULL)
    {
      __set_errno (EINVAL);
      return -1;
    }
  return __fpathconf (0, name);
}

weak_alias (__pathconf, pathconf)

stub_warning (pathconf)

redpajama_set_name: RedPajamaGithub


text:
package com.badr.infodota.trackdota.task;

import com.badr.infodota.BeanContainer;
import com.badr.infodota.base.service.TaskRequest;
import com.badr.infodota.trackdota.api.game.GamesResult;
import com.badr.infodota.trackdota.service.TrackdotaService;

/**
 * Created by ABadretdinov
 * 20.08.2015
 * 15:15
 */
public class GamesResultLoadRequest extends TaskRequest<GamesResult> {
    public GamesResultLoadRequest() {
        super(GamesResult.class);
    }

    @Override
    public GamesResult loadData() throws Exception {
        BeanContainer container = BeanContainer.getInstance();
        TrackdotaService trackdotaService = container.getTrackdotaService();
        return trackdotaService.getGames();
    }
}


text:
layout: newsstory
title: ALWAYS NICE TO WIN
match: Friendly  Oldbury 0 Yeltz 1
---

The pre-season warm-ups continue with a 1-0 victory against local rivals Oldbury, the goal coming in the first-half from Kelvin Phillips.

Saturday brings Stafford Rangers to The Grove, followed by a trip to Studley in the week. Not too long now.

Haven't had much interest in voting for the new  Hall of Fame , so if you do have 5 minutes please make your selections.

Match Report from DJ

Halesowen Town: Harris; Stuart Skidmore (March 65), Small, Sewell (Charlton 70), Josh Skidmore (Smith HT), Baker (Colwell HT), Michael Hollis (Simon Hollis HT), Ashby (Hallam HT), Phillips, Trainer, Kavanagh.

Kelvin Phillips hit the Halesowen winner from close range early in the first half. Oldbury turned into the net off goalkeeper Matt Harris in the 40th minute but the effort was disallowed for offside.

In the second period Bryan Small's shot fell inches wide in the 55th minute. Late in the game Richard Kavanagh and Simon Hollis also put long shots just wide of the mark.


text:
package com.bbn.bue.common;

/**
 * Like {@link Runnable}, but may throw an arbitrary exception.
 */
public interface ThrowingRunnable {

  void run() throws Exception;
}


text:
package io.gravitee.repository.mongodb.management.internal.model;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.List;
import java.util.Objects;

/**
 * @author Florent CHAMFROY (florent.chamfroy at graviteesource.com)
 * @author GraviteeSource Team
 */
@Document(collection = "environments")
public class EnvironmentMongo {

	@Id
	private String id;

	private String cockpitId;

	private List<String> hrids;

	private String name;

	private String description;

	private String organizationId;

	private List<String> domainRestrictions;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getOrganizationId() {
        return organizationId;
    }

    public void setOrganizationId(String organizationId) {
        this.organizationId = organizationId;
    }

    public List<String> getDomainRestrictions() {
        return domainRestrictions;
    }

    public void setDomainRestrictions(List<String> domainRestrictions) {
        this.domainRestrictions = domainRestrictions;
    }

	public List<String> getHrids() {
		return hrids;
	}

	public void setHrids(List<String> hrids) {
		this.hrids = hrids;
	}

	public String getCockpitId() {
		return cockpitId;
	}

	public void setCockpitId(String cockpitId) {
		this.cockpitId = cockpitId;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (!(o instanceof EnvironmentMongo)) return false;
		EnvironmentMongo envMongo = (EnvironmentMongo) o;
		return Objects.equals(id, envMongo.id);
	}

	@Override
	public int hashCode() {
		return Objects.hash(id);
	}

	@Override
	public String toString() {
		return "EnvironmentMongo{" +
			"id='" + id + '\'' +
			", cockpitId='" + cockpitId + '\'' +
			", hrids=" + hrids +
			", name='" + name + '\'' +
			", description='" + description + '\'' +
			", organizationId='" + organizationId + '\'' +
			", domainRestrictions=" + domainRestrictions +
			'}';
	}
}


text:
% Function is based on gillespieManyReactionsQSimple but modified to
% include more light models of different forms

% Function simulates several light models provided the Q matrix is defined
% and the model type - current settings assume M state Markov chains that
% code M/2 positions and codes 2 directions
function [X Xdot T] = gillespieQGeneral(inpGill)

% Deconstruct inputs into individual variables
len = inpGill.len;
x0 = inpGill.x0;
N = inpGill.N;
Nstart = inpGill.Nstart;
nPos = inpGill.nPos;
modelType = inpGill.type;

% Inputs for the Q matrix rate method
Q = inpGill.Q;
transit = inpGill.transit;
nReacs = inpGill.nReacs;
intenParams.i0 = inpGill.alpha;

% Set initial parameters for time and populations
t = zeros(N, 1);
z = zeros(N, len);
z(1, :) = x0;
alp = zeros(N, nReacs);

% Loop across specified number of iterations and simulate
for i = 2:N

    % Update molecular numbers and other data sequentially
    x = z(i - 1, :);
    told = t(i-1);

    % Get reaction rates of the state process from Q matrix
    rdotx1 = getRatesQMx2(Q, x(1), nReacs-nPos);

    % Based on model type obtain the rate at various positions for the
    % observed counting processes
    R = getPositionalIntensity(x(1), modelType, intenParams, nPos);

    % Obtain characteristics of the next reaction based on rate set
    rdot = [rdotx1 R];
    rdotsum = sum(rdot);
    tnex = told - log(rand)/rdotsum;
    rdot_ratio = rdot/rdotsum;
    reac = 1 + sum(rand > cumsum(rdot_ratio));

    % Ensure the next reaction is sensible
    try
        xnex = x + transit(:, reac)';
    catch excep1
        assignin('base', 'reac', reac);
        assignin('base', 'transit', transit);
        assignin('base', 'excep1', excep1);
        error('Problems assinging xnex');
    end

    % Assign variables and ensure dimensions are consistent
    try
        alp(i-1, :) = rdot;
    catch excep2
        assignin('base', 'rdot', rdot);
        assignin('base', 'alp', alp(i-1, :));
        assignin('base', 'excep2', excep2);
        error('Dimension mismatch');
    end
    t(i) = tnex;
    z(i, :) = xnex;

    % Catch a possible error
    if rdotsum == 0
        assignin('base', 'z', z(1:i, :));
        assignin('base', 'alp', alp(1:i-1, :));
        error(['All rates are zero at i = ' num2str(i)]);
    end

end

% Save data from simulation for post processing and account for the control
x = z;
xdot = alp;

% Account for equilibrium and remove last value (in previous code would
% calculate the next step at i = N)
X = x(Nstart:N-1, :);
Xdot = xdot(Nstart:N-1, :);
T = t(Nstart:N-1, :);


text:
<?php
namespace OpenDNS\MES\Recurring;

/**
 * Abstract with setters for recurring billing profiles
 */
abstract class RecurringDetailRequest extends Request
{

    /**
     * Sets Amount to charge each billing cycle
     *
     * @param int $recurringAmount
     *
     * @return self The current class instance for chaining
     */
    public function setRecurringAmount($recurringAmount)
    {
        return $this->setField('recur_amount', $recurringAmount);
    }

    /**
     * Sets starting date of the recurring payments
     * @param DateTime $startDate
     *
     * @return self The current class instance for chaining
     */
    public function setRecurringStartDate(\DateTime $startDate)
    {
        return $this->setField('recur_start_date', $startDate->format('m/d/y'));
    }

    /**
     * Sets number of payments to process over the lifespan of the profile, or 0 for infinite
     *
     * @param int $payments
     *
     * @return self The current class instance for chaining
     */
    public function setNumberofPayments($payments)
    {
        return $this->setField('recur_num_pmt', $payments);
    }

    /**
     * Sets a reference number that's of significance to the client.
     *
     * This might be an order number or some other value that you the
     * merchant would like to be able to refer to. It can't contain '&' or '='
     * for some reason
     *
     * @param int|string $referenceNumber A number of some interest to you.
     * @return self The current class instance for chaining
     */
    public function setClientReferenceNumber($referenceNumber)
    {
        return $this->setField('client_reference_number', $referenceNumber);
    }

    /**
     * Sets a card ID from a previous 'Store Card' operation to charge.
     *
     * This is mutually exclusive of setting the card number. Setting a Card ID
     * will unset any previously set card number.
     *
     * @param string $cardId 32-character card ID
     * @return self The current class instance for chaining
     */
    public function setCardId($cardId)
    {
        return $this->removeField('card_number')
                    ->setField('card_id', $cardId);
    }

    /**
     * Sets the credit card number to charge.
     *
     * This is mutually exclusive of setting the card id. Setting a card number
     * will unset any previously set card id.
     *
     * @param string $cardNumber 15 or 16 digit credit card number
     * @return self The current class instance for chaining
     */
    public function setCardNumber($cardNumber)
    {
        return $this->removeField('card_id')
                    ->setField('card_number', $cardNumber);
    }

    /**
     * Sets the credit card expiration date.
     *
     * Accepts strings because that's most commonly how they're
     * implemented in web forms. You can also pass a \DateTime instance as a single argument
     *
     * @param int|string|\DateTime $month Either the expiration month or a datetime representing the whole expiration date
     * @param int|string|null $year Expiration year (2 or 4 digits) or omit if using a \DateTime
     * @return self The current class instance for chaining
     */
    public function setCardExpiration($month, $year)
    {
        $month = str_pad($month, 2, '0', STR_PAD_LEFT);

        $year = substr(str_pad($year, 2, '0', STR_PAD_LEFT), -2);

        return $this->setField('card_exp_date', $month . $year);
    }

    /**
     * Sets the cardholder's street address for verification
     *
     * Just the first line ('123 Fake Street', for example)
     *
     * @param string $streetAddress
     * @return self The current class instance for chaining
     */
    public function setStreetAddress($streetAddress)
    {
        return $this->setField('cardholder_street_address', $streetAddress);
    }

    /**
     * Sets the cardholder's ZIP code (or postal code) for verification
     *
     * Can be either 5 or 9 digits long.
     *
     * @param int $zipCode
     * @return self The current class instance for chaining
     */
    public function setZipCode($zipCode)
    {
        return $this->setField('cardholder_zip', $zipCode);
    }

    /**
     * Sets the amount of tax to charge on the transaction
     *
     * @param int $taxAmount
     * @return self The current class instance for chaining
     */
    public function setTaxAmount($taxAmount)
    {
        return $this->setField('tax_amount', $taxAmount);
    }

}