text:
import os
import re
import sys

import Common
import ChessMove
import PgnTokenizer
from ChessState import ChessState

###############################################################################
# Match
# - contains tags, comments, moves, and states of a bughouse chess match
# - is able to load itself from bpgn match text
###############################################################################
class PgnChessMatch:
    def __init__(self):
        self.initState = ChessState(Common.initChessFEN)
        self.moves = []
        self.tags = {}
        self.comments = []
        self.states = [self.initState]

    def incrMoveNum(self, fullMove):
        old = fullMove

        m = re.match(r'^(\d+)([AaBb])$', fullMove)
        [num, letter] = [int(m.group(1)), m.group(2)]

        if letter in 'ab':
            num += 1

        letter = {'A':'a', 'a':'A', 'B':'b', 'b':'B'}[letter]

        new = str(num) + letter

        #print "incremented from %s to %s" % (old, new)

        return new

    def sanityCheck(self):
        # does the game have ANY moves in it?
        if len(self.moves) == 0:
            raise MatchZeroMovesException("no moves recorded")

        # does the game have missing/out-of-order moves in it?
        expectA = '1A'
        expectB = '1B'
        for m in self.moves:

            if 'TIME_FORFEIT' in m.flags:
                continue

            # bughouse-db games store a repeated move at the end when
            # that player forfeits on time

            fullMove = m.moveNum + m.player

            if fullMove == expectA:
                expectA = self.incrMoveNum(expectA)
            elif fullMove == expectB:
                expectB = self.incrMoveNum(expectB)
            else:
                raise MatchMovesOOOException("expected move %s or %s (got instead:\n %s)" % \
                    (expectA, expectB, str(m)))

    # - parses, populates the tags member
    # - parses, populates the moves member
    # - parses, populates the comments member
    # - calculates the states member
    #
    def parsePgn(self, text):
        tokens = PgnTokenizer.tokenize(text)
        moveNum = 1
        player = 'W'

        while tokens:
            token = tokens.pop(0)

            #print "on token: -%s-" % token

            # tag tokens eg: [Event "May 2013 Tourney"]
            m = re.match(r'\[(.*?) "(.*?)"\]', token)
            if m:
                self.tags[m.group(1)] = m.group(2)
                continue

            # comment tokens eg: { good move! also consider Rxe8 }
            m = re.match('^{(.*)}$', token)
            if m:
                # if we're in the moves section, comment applies to a move
                if self.moves:
                    self.moves[-1].addComment(m.group(1))
                # else it applies to the match comments
                else:
                    self.comments.append(m.group(1))

                continue

            # result tokens eg: 0-1
            m = re.match(Common.regexResults, token)
            if m:
                self.result = token

                if tokens:
                    raise Exception("result token was not the final token! next is: " + tokens[0])

                continue

            # move number token eg: 34.
            m = re.match(r'(\d+)\.', token)
            if m:
                if moveNum == int(m.group(1)) + 1:
                    raise Exception("out of order move number: " + token)

                moveNum += 1;
                player = 'W'

            # normal move (SAN)
            m = re.match(Common.regexSanChess, token)
            if m:
                move = ChessMove.ChessMove()
                move.moveNum = moveNum
                move.player = player
                move.san = token
                self.moves.append(move)

                player = {'W':'B', 'B':'W'}[player]

        # calculate all board states
        self.states = [self.initState]

        for move in self.moves:
            # exceptions (repeated moves due to time forfeiture, etc.) just carry state along...
            if 'TIME_FORFEIT' in move.flags:
                self.states.append(self.states[-1])
                continue

            currState = self.states[-1]
            nextState = currState.transition(move.san)

            self.states.append(nextState)

    def __str__(self):
        answer = ''
        #answer = '%s[%s],%s[%s] vs %s[%s],%s[%s]\n' % ( \
        #    self.tags['WhiteA'], self.tags['WhiteAElo'], self.tags['BlackA'], self.tags['BlackAElo'], \
        #    self.tags['BlackB'], self.tags['BlackBElo'], self.tags['WhiteA'], self.tags['WhiteAElo'] \
        #)

        answer += "TAGS:\n"
        for tag,value in self.tags.iteritems():
            answer += "%s: \"%s\"\n" % (tag, value)
        answer += "COMMENTS:\n"
        for c in self.comments:
            answer += c + "\n"
        answer += "MOVES (%d total):\n" % len(self.moves)
        for m in self.moves:
            answer += str(m) + "\n"
        return answer

###############################################################################
# PgnChessMatchIteratorFile
# - return matches from file containing multiple matches
# - basically, split the text around '[Event "..."]' tags
###############################################################################
class PgnChessMatchIteratorFile:
    def __init__(self, path):
        self.path = path

        self.fp = open(path, 'r')
        self.lineNum = -1

    def __iter__(self):
        self.fp.seek(0, 0)
        self.lineNum = -1
        return self

    def peekLine(self, doStrip=1):
        line = self.fp.readline()
        self.fp.seek(-1*len(line), 1)

        if doStrip:
            line = line.rstrip()

        return line

    def readLine(self):
        self.lineNum += 1
        temp = self.fp.readline()
        #print "read: %s" % temp
        return temp

    def consumeNewLines(self):
        while 1:
            line = self.peekLine(False)
            if not line:
                return False
            if not re.match(r'^\s+$', line):
                break
            self.readLine()
        return True

    # strategy here is simple: consume lines until an Event tag is found
    # in other words, Event tags delimit the matches
    def next(self):
        if not self.consumeNewLines():
            raise StopIteration

        matchText = self.readLine()

        if not re.match(r'^\[Event', matchText):
            raise Exception(("expected Event tag at %s:%d\n" + \
                "(instead got: %s)") % (self.path, self.lineNum, matchText))

        # so long as the next line is not an Event tag, add to current match
        while 1:
            line = self.peekLine()
            if not re.match(r'^\[Event', line):
                matchText += '\n' + line
                if not self.readLine():
                    break
            else:
                break

        # return a match
        match = PgnChessMatch()
        match.path = self.path
        match.parsePgn(matchText)
        return match

    def __del__(self):
        if self.fp:
            self.fp.close()

        self.fp = None

###############################################################################
# MatchIteratorDir
# - return matches from a directory containing files
# - basically, loop over MatchIteratorFile for every file in a directory
###############################################################################
class PgnChessMatchIteratorDir:
    def __init__(self, path):
        self.walkObj = os.walk(path)
        self.matchIterFileObj = None
        self.filesList = []

    def __iter__(self):
        return self

    def next(self):
        while 1:
            # first level: does the file iterator still have something left?
            if self.matchIterFileObj:
                try:
                    return self.matchIterFileObj.next()
                except StopIteration:
                    self.matchIterFileObj = None

            # second level, is current list of files exhausted? can we create a new
            # file iterator?
            if self.filesList:
                self.matchIterFileObj = PgnChessMatchIteratorFile(self.filesList.pop())
                continue

            # third level: no file iterator, no files list, descend!
            # purposely don't trap exception: StopIterations should bubble up and tell
            # caller that we're done
            (root, subFolder, files) = self.walkObj.next()

            for f in files:
                (dummy, ext) = os.path.splitext(f)
                if ext == '.bpgn':
                    self.filesList.append(os.path.join(root, f))

###############################################################################
# main()
###############################################################################
if __name__ == '__main__':
    gamesCount = 0
    goodGamesCount = 0

    path = sys.argv[1]
    it = None
    if os.path.isfile(path):
        it = PgnChessMatchIteratorFile(path)
    elif os.path.isdir(path):
        it = PgnChessMatchIteratorDir(path)
    else:
        raise Exception("WTF?")

    for m in it:
        gamesCount += 1

        try:
            m.sanityCheck()
        #except MatchMovesOOOException as e:
        #    print "%s: skipping match due to out of order (or missing) moves\n%s\n%s" % (m.path, '\n'.join(m.comments), str(e))
        #    continue
        #except MatchZeroMovesException as e:
        #    print "%s: skipping match due to it being empty (no moves whatsoever)\n%s\n%s" % (m.path, '\n'.join(m.comments), str(e))
        #    continue
        except Exception as e:
            print e

        for s in m.states:
            print s.occupancy()

        goodGamesCount += 1
        #raw_input("hit enter for next game")
        print "%d/%d games are good (%02.2f%%)" % (goodGamesCount, gamesCount, 100.0*goodGamesCount/gamesCount)


text:
local ffi = require("ffi")

require ("lj2audit.elf-em")

ffi.cdef[[
static const int AUDIT_GET		=1000;	/* Get status */
static const int AUDIT_SET		=1001;	/* Set status (enable/disable/auditd) */
static const int AUDIT_LIST		=1002;	/* List syscall rules -- deprecated */
static const int AUDIT_ADD		=1003;	/* Add syscall rule -- deprecated */
static const int AUDIT_DEL		=1004;	/* Delete syscall rule -- deprecated */
static const int AUDIT_USER		=1005;	/* Message from userspace -- deprecated */
static const int AUDIT_LOGIN		=1006;	/* Define the login id and information */
static const int AUDIT_WATCH_INS		=1007;	/* Insert file/dir watch entry */
static const int AUDIT_WATCH_REM		=1008;	/* Remove file/dir watch entry */
static const int AUDIT_WATCH_LIST	=1009;	/* List all file/dir watches */
static const int AUDIT_SIGNAL_INFO	=1010;	/* Get info about sender of signal to auditd */
static const int AUDIT_ADD_RULE		=1011;	/* Add syscall filtering rule */
static const int AUDIT_DEL_RULE		=1012;	/* Delete syscall filtering rule */
static const int AUDIT_LIST_RULES	=1013;	/* List syscall filtering rules */
static const int AUDIT_TRIM		=1014;	/* Trim junk from watched tree */
static const int AUDIT_MAKE_EQUIV	=1015;	/* Append to watched tree */
static const int AUDIT_TTY_GET		=1016;	/* Get TTY auditing status */
static const int AUDIT_TTY_SET		=1017;	/* Set TTY auditing status */
static const int AUDIT_SET_FEATURE	=1018;	/* Turn an audit feature on or off */
static const int AUDIT_GET_FEATURE	=1019;	/* Get which features are enabled */
]]

ffi.cdef[[
static const int AUDIT_FIRST_USER_MSG	=1100;	/* Userspace messages mostly uninteresting to kernel */
static const int AUDIT_USER_AVC		=1107;	/* We filter this differently */
static const int AUDIT_USER_TTY		=1124;	/* Non-ICANON TTY input meaning */
static const int AUDIT_LAST_USER_MSG	=1199;
static const int AUDIT_FIRST_USER_MSG2	=2100;	/* More user space messages */
static const int AUDIT_LAST_USER_MSG2	=2999;
]]

ffi.cdef[[
static const int AUDIT_DAEMON_START      =1200;    /* Daemon startup record */
static const int AUDIT_DAEMON_END        =1201;   /* Daemon normal stop record */
static const int AUDIT_DAEMON_ABORT      =1202;    /* Daemon error stop record */
static const int AUDIT_DAEMON_CONFIG     =1203;    /* Daemon config change */
]]

ffi.cdef[[
static const int AUDIT_SYSCALL		=1300;	/* Syscall event */
/* static const int AUDIT_FS_WATCH	=1301;	 * Deprecated */
static const int AUDIT_PATH		=1302;	/* Filename path information */
static const int AUDIT_IPC		=1303;	/* IPC record */
static const int AUDIT_SOCKETCALL	=1304;	/* sys_socketcall arguments */
static const int AUDIT_CONFIG_CHANGE	=1305;	/* Audit system configuration change */
static const int AUDIT_SOCKADDR		=1306;	/* sockaddr copied as syscall arg */
static const int AUDIT_CWD		=1307;	/* Current working directory */
static const int AUDIT_EXECVE		=1309;	/* execve arguments */
static const int AUDIT_IPC_SET_PERM	=1311;	/* IPC new permissions record type */
static const int AUDIT_MQ_OPEN		=1312;	/* POSIX MQ open record type */
static const int AUDIT_MQ_SENDRECV	=1313;	/* POSIX MQ send/receive record type */
static const int AUDIT_MQ_NOTIFY		=1314;	/* POSIX MQ notify record type */
static const int AUDIT_MQ_GETSETATTR	=1315;	/* POSIX MQ get/set attribute record type */
static const int AUDIT_KERNEL_OTHER	=1316;	/* For use by 3rd party modules */
static const int AUDIT_FD_PAIR		=1317;    /* audit record for pipe/socketpair */
static const int AUDIT_OBJ_PID		=1318;	/* ptrace target */
static const int AUDIT_TTY		=1319;	/* Input on an administrative TTY */
static const int AUDIT_EOE		=1320;	/* End of multi-record event */
static const int AUDIT_BPRM_FCAPS	=1321;	/* Information about fcaps increasing perms */
static const int AUDIT_CAPSET		=1322;	/* Record showing argument to sys_capset */
static const int AUDIT_MMAP		=1323;	/* Record showing descriptor and flags in mmap */
static const int AUDIT_NETFILTER_PKT	=1324;	/* Packets traversing netfilter chains */
static const int AUDIT_NETFILTER_CFG	=1325;	/* Netfilter chain modifications */
static const int AUDIT_SECCOMP		=1326;	/* Secure Computing event */
static const int AUDIT_PROCTITLE		=1327;	/* Proctitle emit event */
static const int AUDIT_FEATURE_CHANGE	=1328;	/* audit log listing feature changes */
]]

ffi.cdef[[
static const int AUDIT_AVC		=1400;	/* SE Linux avc denial or grant */
static const int AUDIT_SELINUX_ERR	=1401;	/* Internal SE Linux Errors */
static const int AUDIT_AVC_PATH		=1402;	/* dentry, vfsmount pair from avc */
static const int AUDIT_MAC_POLICY_LOAD	=1403;	/* Policy file load */
static const int AUDIT_MAC_STATUS	=1404;	/* Changed enforcing,permissive,off */
static const int AUDIT_MAC_CONFIG_CHANGE	=1405;	/* Changes to booleans */
static const int AUDIT_MAC_UNLBL_ALLOW	=1406;	/* NetLabel: allow unlabeled traffic */
static const int AUDIT_MAC_CIPSOV4_ADD	=1407;	/* NetLabel: add CIPSOv4 DOI entry */
static const int AUDIT_MAC_CIPSOV4_DEL	=1408;	/* NetLabel: del CIPSOv4 DOI entry */
static const int AUDIT_MAC_MAP_ADD	=1409;	/* NetLabel: add LSM domain mapping */
static const int AUDIT_MAC_MAP_DEL	=1410;	/* NetLabel: del LSM domain mapping */
static const int AUDIT_MAC_IPSEC_ADDSA	=1411;	/* Not used */
static const int AUDIT_MAC_IPSEC_DELSA	=1412;	/* Not used  */
static const int AUDIT_MAC_IPSEC_ADDSPD	=1413;	/* Not used */
static const int AUDIT_MAC_IPSEC_DELSPD	=1414;	/* Not used */
static const int AUDIT_MAC_IPSEC_EVENT	=1415;	/* Audit an IPSec event */
static const int AUDIT_MAC_UNLBL_STCADD	=1416;	/* NetLabel: add a static label */
static const int AUDIT_MAC_UNLBL_STCDEL	=1417;	/* NetLabel: del a static label */
]]

ffi.cdef[[
static const int AUDIT_FIRST_KERN_ANOM_MSG   =1700;
static const int AUDIT_LAST_KERN_ANOM_MSG    =1799;
static const int AUDIT_ANOM_PROMISCUOUS      =1700; /* Device changed promiscuous mode */
static const int AUDIT_ANOM_ABEND            =1701; /* Process ended abnormally */
static const int AUDIT_ANOM_LINK		    =1702; /* Suspicious use of file links */
static const int AUDIT_INTEGRITY_DATA	    =1800; /* Data integrity verification */
static const int AUDIT_INTEGRITY_METADATA    =1801; /* Metadata integrity verification */
static const int AUDIT_INTEGRITY_STATUS	    =1802; /* Integrity enable status */
static const int AUDIT_INTEGRITY_HASH	    =1803; /* Integrity HASH type */
static const int AUDIT_INTEGRITY_PCR	    =1804; /* PCR invalidation msgs */
static const int AUDIT_INTEGRITY_RULE	    =1805; /* policy rule */
]]

ffi.cdef[[
static const int AUDIT_KERNEL		=2000;	/* Asynchronous audit record. NOT A REQUEST. */
]]

ffi.cdef[[
/* Rule flags */
static const int AUDIT_FILTER_USER	=0x00;	/* Apply rule to user-generated messages */
static const int AUDIT_FILTER_TASK	=0x01;	/* Apply rule at task creation (not syscall) */
static const int AUDIT_FILTER_ENTRY	=0x02;	/* Apply rule at syscall entry */
static const int AUDIT_FILTER_WATCH	=0x03;	/* Apply rule to file system watches */
static const int AUDIT_FILTER_EXIT	=0x04;	/* Apply rule at syscall exit */
static const int AUDIT_FILTER_TYPE	=0x05;	/* Apply rule at audit_log_start */

static const int AUDIT_NR_FILTERS	=6;

static const int AUDIT_FILTER_PREPEND	=0x10;	/* Prepend to front of list */
]]

ffi.cdef[[
/* Rule actions */
static const int AUDIT_NEVER    =0;	/* Do not build context if rule matches */
static const int AUDIT_POSSIBLE =1;	/* Build context if rule matches  */
static const int AUDIT_ALWAYS   =2;	/* Generate audit record if rule matches */

/* Rule structure sizes -- if these change, different AUDIT_ADD and
 * AUDIT_LIST commands must be implemented. */
static const int AUDIT_MAX_FIELDS   =64;
static const int AUDIT_MAX_KEY_LEN  =256;
static const int AUDIT_BITMASK_SIZE =64;
]]

--[[
local function AUDIT_WORD(nr) ((uint32_t)((nr)/32))
local function AUDIT_BIT(nr)  (1 << ((nr) - AUDIT_WORD(nr)*32))
--]]

ffi.cdef[[
static const int AUDIT_SYSCALL_CLASSES =16;
static const int AUDIT_CLASS_DIR_WRITE =0;
static const int AUDIT_CLASS_DIR_WRITE_32 =1;
static const int AUDIT_CLASS_CHATTR =2;
static const int AUDIT_CLASS_CHATTR_32 =3;
static const int AUDIT_CLASS_READ =4;
static const int AUDIT_CLASS_READ_32 =5;
static const int AUDIT_CLASS_WRITE =6;
static const int AUDIT_CLASS_WRITE_32 =7;
static const int AUDIT_CLASS_SIGNAL =8;
static const int AUDIT_CLASS_SIGNAL_32 =9;

/* This bitmask is used to validate user input.  It represents all bits that
 * are currently used in an audit field constant understood by the kernel.
 * If you are adding a new static const int AUDIT_<whatever>, please ensure that
 * AUDIT_UNUSED_BITS is updated if need be. */
static const int AUDIT_UNUSED_BITS	=0x07FFFC00;

/* AUDIT_FIELD_COMPARE rule list */
static const int AUDIT_COMPARE_UID_TO_OBJ_UID	=1;
static const int AUDIT_COMPARE_GID_TO_OBJ_GID	=2;
static const int AUDIT_COMPARE_EUID_TO_OBJ_UID	=3;
static const int AUDIT_COMPARE_EGID_TO_OBJ_GID	=4;
static const int AUDIT_COMPARE_AUID_TO_OBJ_UID	=5;
static const int AUDIT_COMPARE_SUID_TO_OBJ_UID	=6;
static const int AUDIT_COMPARE_SGID_TO_OBJ_GID	=7;
static const int AUDIT_COMPARE_FSUID_TO_OBJ_UID	=8;
static const int AUDIT_COMPARE_FSGID_TO_OBJ_GID	=9;

static const int AUDIT_COMPARE_UID_TO_AUID	=10;
static const int AUDIT_COMPARE_UID_TO_EUID	=11;
static const int AUDIT_COMPARE_UID_TO_FSUID	=12;
static const int AUDIT_COMPARE_UID_TO_SUID	=13;

static const int AUDIT_COMPARE_AUID_TO_FSUID	=14;
static const int AUDIT_COMPARE_AUID_TO_SUID	=15;
static const int AUDIT_COMPARE_AUID_TO_EUID	=16;

static const int AUDIT_COMPARE_EUID_TO_SUID	=17;
static const int AUDIT_COMPARE_EUID_TO_FSUID	=18;

static const int AUDIT_COMPARE_SUID_TO_FSUID	=19;

static const int AUDIT_COMPARE_GID_TO_EGID	=20;
static const int AUDIT_COMPARE_GID_TO_FSGID	=21;
static const int AUDIT_COMPARE_GID_TO_SGID	=22;

static const int AUDIT_COMPARE_EGID_TO_FSGID	=23;
static const int AUDIT_COMPARE_EGID_TO_SGID	=24;
static const int AUDIT_COMPARE_SGID_TO_FSGID	=25;

static const int AUDIT_MAX_FIELD_COMPARE		=AUDIT_COMPARE_SGID_TO_FSGID;
]]

ffi.cdef[[
/* Rule fields */
				/* These are useful when checking the
				 * task structure at task creation time
				 * (AUDIT_PER_TASK).  */
static const int AUDIT_PID	=0;
static const int AUDIT_UID	=1;
static const int AUDIT_EUID	=2;
static const int AUDIT_SUID	=3;
static const int AUDIT_FSUID	=4;
static const int AUDIT_GID	=5;
static const int AUDIT_EGID	=6;
static const int AUDIT_SGID	=7;
static const int AUDIT_FSGID	=8;
static const int AUDIT_LOGINUID	=9;
static const int AUDIT_PERS	=10;
static const int AUDIT_ARCH	=11;
static const int AUDIT_MSGTYPE	=12;
static const int AUDIT_SUBJ_USER	=13;	/* security label user */
static const int AUDIT_SUBJ_ROLE	=14;	/* security label role */
static const int AUDIT_SUBJ_TYPE	=15;	/* security label type */
static const int AUDIT_SUBJ_SEN	=16;	/* security label sensitivity label */
static const int AUDIT_SUBJ_CLR	=17;	/* security label clearance label */
static const int AUDIT_PPID	=18;
static const int AUDIT_OBJ_USER	=19;
static const int AUDIT_OBJ_ROLE	=20;
static const int AUDIT_OBJ_TYPE	=21;
static const int AUDIT_OBJ_LEV_LOW	=22;
static const int AUDIT_OBJ_LEV_HIGH	=23;
static const int AUDIT_LOGINUID_SET	=24;
]]

ffi.cdef[[
				/* These are ONLY useful when checking
				 * at syscall exit time (AUDIT_AT_EXIT). */
static const int AUDIT_DEVMAJOR	=100;
static const int AUDIT_DEVMINOR	=101;
static const int AUDIT_INODE	=102;
static const int AUDIT_EXIT	=103;
static const int AUDIT_SUCCESS   =104;	/* exit >= 0; value ignored */
static const int AUDIT_WATCH	=105;
static const int AUDIT_PERM	=106;
static const int AUDIT_DIR	=107;
static const int AUDIT_FILETYPE	=108;
static const int AUDIT_OBJ_UID	=109;
static const int AUDIT_OBJ_GID	=110;
static const int AUDIT_FIELD_COMPARE	=111;

static const int AUDIT_ARG0      =200;
static const int AUDIT_ARG1      =(AUDIT_ARG0+1);
static const int AUDIT_ARG2      =(AUDIT_ARG0+2);
static const int AUDIT_ARG3      =(AUDIT_ARG0+3);

static const int AUDIT_FILTERKEY	=210;

static const int AUDIT_NEGATE			=0x80000000;

/* These are the supported operators.
 *	4  2  1  8
 *	=  >  <  ?
 *	----------
 *	0  0  0	 0	00	nonsense
 *	0  0  0	 1	08	&  bit mask
 *	0  0  1	 0	10	<
 *	0  1  0	 0	20	>
 *	0  1  1	 0	30	!=
 *	1  0  0	 0	40	=
 *	1  0  0	 1	48	&=  bit test
 *	1  0  1	 0	50	<=
 *	1  1  0	 0	60	>=
 *	1  1  1	 1	78	all operators
 */
static const int AUDIT_BIT_MASK			=0x08000000;
static const int AUDIT_LESS_THAN			=0x10000000;
static const int AUDIT_GREATER_THAN		=0x20000000;
static const int AUDIT_NOT_EQUAL		=	0x30000000;
static const int AUDIT_EQUAL			=0x40000000;
static const int AUDIT_BIT_TEST			=(AUDIT_BIT_MASK|AUDIT_EQUAL);
static const int AUDIT_LESS_THAN_OR_EQUAL	=(AUDIT_LESS_THAN|AUDIT_EQUAL);
static const int AUDIT_GREATER_THAN_OR_EQUAL	=(AUDIT_GREATER_THAN|AUDIT_EQUAL);
static const int AUDIT_OPERATORS			=(AUDIT_EQUAL|AUDIT_NOT_EQUAL|AUDIT_BIT_MASK);
]]

ffi.cdef[[
enum {
	Audit_equal,
	Audit_not_equal,
	Audit_bitmask,
	Audit_bittest,
	Audit_lt,
	Audit_gt,
	Audit_le,
	Audit_ge,
	Audit_bad
};
]]

--[[
/* Status symbols */
				/* Mask values */
static const int AUDIT_STATUS_ENABLED		0x0001
static const int AUDIT_STATUS_FAILURE		0x0002
static const int AUDIT_STATUS_PID		0x0004
static const int AUDIT_STATUS_RATE_LIMIT		0x0008
static const int AUDIT_STATUS_BACKLOG_LIMIT	0x0010
static const int AUDIT_STATUS_BACKLOG_WAIT_TIME	0x0020

static const int AUDIT_FEATURE_BITMAP_BACKLOG_LIMIT	0x00000001
static const int AUDIT_FEATURE_BITMAP_BACKLOG_WAIT_TIME	0x00000002
static const int AUDIT_FEATURE_BITMAP_ALL (AUDIT_FEATURE_BITMAP_BACKLOG_LIMIT | \
				  AUDIT_FEATURE_BITMAP_BACKLOG_WAIT_TIME)

/* deprecated: AUDIT_VERSION_* */
static const int AUDIT_VERSION_LATEST 		AUDIT_FEATURE_BITMAP_ALL
static const int AUDIT_VERSION_BACKLOG_LIMIT	AUDIT_FEATURE_BITMAP_BACKLOG_LIMIT
static const int AUDIT_VERSION_BACKLOG_WAIT_TIME	AUDIT_FEATURE_BITMAP_BACKLOG_WAIT_TIME

				/* Failure-to-log actions */
static const int AUDIT_FAIL_SILENT	0
static const int AUDIT_FAIL_PRINTK	1
static const int AUDIT_FAIL_PANIC	2
--]]

ffi.cdef[[
/*
 * These bits disambiguate different calling conventions that share an
 * ELF machine type, bitness, and endianness
 */
static const int __AUDIT_ARCH_CONVENTION_MASK 		= 0x30000000;
static const int __AUDIT_ARCH_CONVENTION_MIPS64_N32 = 0x20000000;
]]

ffi.cdef[[
/* distinguish syscall tables */
static const int __AUDIT_ARCH_64BIT = 0x80000000;
static const int __AUDIT_ARCH_LE	= 0x40000000;
]]

ffi.cdef[[
static const int AUDIT_ARCH_AARCH64	=(EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE);
static const int AUDIT_ARCH_ALPHA	=(EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE);
static const int AUDIT_ARCH_ARM		=(EM_ARM|__AUDIT_ARCH_LE);
static const int AUDIT_ARCH_ARMEB	=(EM_ARM);
static const int AUDIT_ARCH_CRIS	=	(EM_CRIS|__AUDIT_ARCH_LE);
static const int AUDIT_ARCH_FRV		=(EM_FRV);
static const int AUDIT_ARCH_I386		=(EM_386|__AUDIT_ARCH_LE);
static const int AUDIT_ARCH_IA64		=(EM_IA_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE);
static const int AUDIT_ARCH_M32R		=(EM_M32R);
static const int AUDIT_ARCH_M68K		=(EM_68K);
//static const int AUDIT_ARCH_MICROBLAZE	=(EM_MICROBLAZE);
static const int AUDIT_ARCH_MIPS		=(EM_MIPS);
static const int AUDIT_ARCH_MIPSEL	=(EM_MIPS|__AUDIT_ARCH_LE);
static const int AUDIT_ARCH_MIPS64	=(EM_MIPS|__AUDIT_ARCH_64BIT);
static const int AUDIT_ARCH_MIPS64N32	=(EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_CONVENTION_MIPS64_N32);
static const int AUDIT_ARCH_MIPSEL64	=(EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE);
static const int AUDIT_ARCH_MIPSEL64N32	=(EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE|__AUDIT_ARCH_CONVENTION_MIPS64_N32);
static const int AUDIT_ARCH_OPENRISC	=(EM_OPENRISC);
static const int AUDIT_ARCH_PARISC	=(EM_PARISC);
static const int AUDIT_ARCH_PARISC64	=(EM_PARISC|__AUDIT_ARCH_64BIT);
static const int AUDIT_ARCH_PPC		=(EM_PPC);
/* do not define AUDIT_ARCH_PPCLE since it is not supported by audit */
static const int AUDIT_ARCH_PPC64	=(EM_PPC64|__AUDIT_ARCH_64BIT);
static const int AUDIT_ARCH_PPC64LE	=(EM_PPC64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE);
static const int AUDIT_ARCH_S390	=	(EM_S390);
static const int AUDIT_ARCH_S390X	=(EM_S390|__AUDIT_ARCH_64BIT);
static const int AUDIT_ARCH_SH		=(EM_SH);
static const int AUDIT_ARCH_SHEL	=	(EM_SH|__AUDIT_ARCH_LE);
static const int AUDIT_ARCH_SH64	=	(EM_SH|__AUDIT_ARCH_64BIT);
static const int AUDIT_ARCH_SHEL64	=(EM_SH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE);
static const int AUDIT_ARCH_SPARC	=(EM_SPARC);
static const int AUDIT_ARCH_SPARC64	=(EM_SPARCV9|__AUDIT_ARCH_64BIT);
static const int AUDIT_ARCH_X86_64	=(EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE);
]]

ffi.cdef[[
static const int AUDIT_PERM_EXEC	= 1;
static const int AUDIT_PERM_WRITE	= 2;
static const int AUDIT_PERM_READ	= 4;
static const int AUDIT_PERM_ATTR	= 8;
]]

ffi.cdef[[
/* MAX_AUDIT_MESSAGE_LENGTH is set in audit:lib/libaudit.h as:
 * 8970 // PATH_MAX*2+CONTEXT_SIZE*2+11+256+1
 * max header+body+tailer: 44 + 29 + 32 + 262 + 7 + pad
 */
static const int AUDIT_MESSAGE_TEXT_MAX	= 8560;

/* Multicast Netlink socket groups (default up to 32) */
enum audit_nlgrps {
	AUDIT_NLGRP_NONE,	/* Group 0 not used */
	AUDIT_NLGRP_READLOG,	/* "best effort" read only socket */
	__AUDIT_NLGRP_MAX
};
static const int AUDIT_NLGRP_MAX               = (__AUDIT_NLGRP_MAX - 1);
]]

ffi.cdef[[
struct audit_status {
	uint32_t		mask;		/* Bit mask for valid entries */
	uint32_t		enabled;	/* 1 = enabled, 0 = disabled */
	uint32_t		failure;	/* Failure-to-log action */
	uint32_t		pid;		/* pid of auditd process */
	uint32_t		rate_limit;	/* messages rate limit (per second) */
	uint32_t		backlog_limit;	/* waiting messages limit */
	uint32_t		lost;		/* messages lost */
	uint32_t		backlog;	/* messages waiting in queue */
	union {
		uint32_t	version;	/* deprecated: audit api version num */
		uint32_t	feature_bitmap;	/* bitmap of kernel audit features */
	};
	uint32_t		backlog_wait_time;/* message queue wait timeout */
};

struct audit_features {
	uint32_t	vers;
	uint32_t	mask;		/* which bits we are dealing with */
	uint32_t	features;	/* which feature to enable/disable */
	uint32_t	lock;		/* which features to lock */
};
]]

ffi.cdef[[
static const int AUDIT_FEATURE_VERSION	=1;

static const int AUDIT_FEATURE_ONLY_UNSET_LOGINUID	=0;
static const int AUDIT_FEATURE_LOGINUID_IMMUTABLE	=1;
static const int AUDIT_LAST_FEATURE			=AUDIT_FEATURE_LOGINUID_IMMUTABLE;
]]

--local function audit_feature_valid(x)		((x) >= 0 && (x) <= AUDIT_LAST_FEATURE)
--local function AUDIT_FEATURE_TO_MASK(x)	(1 << ((x) & 31)) /* mask for uint32_t */

ffi.cdef[[
struct audit_tty_status {
	uint32_t		enabled;	/* 1 = enabled, 0 = disabled */
	uint32_t		log_passwd;	/* 1 = enabled, 0 = disabled */
};

static const int AUDIT_UID_UNSET = (unsigned int)-1;

]]

ffi.cdef[[
/* audit_rule_data supports filter rules with both integer and string
 * fields.  It corresponds with AUDIT_ADD_RULE, AUDIT_DEL_RULE and
 * AUDIT_LIST_RULES requests.
 */
struct audit_rule_data {
	uint32_t		flags;	/* AUDIT_PER_{TASK,CALL}, AUDIT_PREPEND */
	uint32_t		action;	/* AUDIT_NEVER, AUDIT_POSSIBLE, AUDIT_ALWAYS */
	uint32_t		field_count;
	uint32_t		mask[AUDIT_BITMASK_SIZE]; /* syscall(s) affected */
	uint32_t		fields[AUDIT_MAX_FIELDS];
	uint32_t		values[AUDIT_MAX_FIELDS];
	uint32_t		fieldflags[AUDIT_MAX_FIELDS];
	uint32_t		buflen;	/* total length of string fields */
	char		buf[0];	/* string fields buffer */
};
]]

redpajama_set_name: RedPajamaGithub


text:
package org.tolweb.tapestry.adt;

import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Set;

import org.tolweb.hibernate.MappedNode;

/**
 * class used to model a portion of the tree in memory
 * using a hashtable -- eventually a lot of the functionality
 * in TaxaIndex should be moved here
 * @author dmandel
 */
public class HashtableTree {
	private Hashtable<Long, List<MappedNode>> table;

	public Hashtable<Long, List<MappedNode>> getTable() {
		return table;
	}
	public void setTable(Hashtable<Long, List<MappedNode>> table) {
		this.table = table;
	}
	public Set<Long> getAllNodeIds() {
		Set<Long> ids = new HashSet<Long>();
		ids.addAll(getTable().keySet());
		for (List<MappedNode> nodes : getTable().values()) {
			for (MappedNode node : nodes) {
				ids.add(node.getNodeId());
			}
		}
		return ids;
	}
	public MappedNode getNodeWithId(Long id) {
		for (List<MappedNode> nodes : getTable().values()) {
			for (MappedNode node : nodes) {
				if (node.getNodeId().equals(id)) {
					return node;
				}
			}
		}
		return null;
	}
}


text:
## Multiple Select

Multiple select 是一个通过复选框来选择多元素的 jQuery 插件:).

*当前版本: 1.2.1.2*

## Requirements

* jQuery >= 1.7.0

## Features

* 默认选项允许显示复选框。
* 支持分组显示元素。
* 支持在一行中显示多个选项。
* 支持全选。
* 支持显示默认提示信息。

## Browser Compatibility

* IE 7+
* Chrome 8+
* Firefox 10+
* Safari 3+
* Opera 10.6+

## Examples

### The Basics1

Multiple Select 可以将标准的复选框:

	<select class="w300" multiple="multiple">
		<option value="1">January</option>
		<option value="2">February</option>
	    <option value="3">March</option>
	    <option value="4">April</option>
	    <option value="5">May</option>
	    <option value="6">June</option>
	    <option value="7">July</option>
	    <option value="8">August</option>
	    <option value="9">September</option>
	    <option value="10">October</option>
	    <option value="11">November</option>
	    <option value="12">December</option>
	</select>

转换为:

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
	<select multiple="multiple">
	    <option value="1">January</option>
	    ...
	    <option value="12">December</option>
	</select>
	<script src="multiple-select.js"></script>
	<script>
		$('select').multipleSelect();
	</script>
</body>
```

### The Basics2

Multiple Select 可以将标准的复选框:

	<select class="w300" multiple="multiple" disabled="disabled">
	    <option value="1">January</option>
		<option value="2">February</option>
	    <option value="3">March</option>
	    <option value="4">April</option>
	    <option value="5">May</option>
	    <option value="6">June</option>
	    <option value="7">July</option>
	    <option value="8">August</option>
	    <option value="9">September</option>
	    <option value="10">October</option>
	    <option value="11">November</option>
	    <option value="12">December</option>
	</select>

转换为:

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
	<select multiple="multiple" disabled="disabled">
	    <option value="1">January</option>
	    ...
	    <option value="12">December</option>
	</select>
	<script src="multiple-select.js"></script>
	<script>
		$('select').multipleSelect();
	</script>
</body>
```

### The Basics3

Multiple Select 可以将标准的复选框:

	<select class="w300" multiple="multiple">
	    <option value="1" selected="selected">January</option>
		<option value="2" disabled="disabled">February</option>
	    <option value="3" selected="selected" disabled="disabled">March</option>
	    <option value="4">April</option>
	    <option value="5">May</option>
	    <option value="6">June</option>
	    <option value="7">July</option>
	    <option value="8">August</option>
	    <option value="9">September</option>
	    <option value="10">October</option>
	    <option value="11">November</option>
	    <option value="12">December</option>
	</select>

转换为:

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
	<select multiple="multiple">
	    <option value="1" selected="selected">January</option>
		<option value="2" disabled="disabled">February</option>
	    <option value="3" selected="selected" disabled="disabled">March</option>
	    ...
	</select>
	<script src="multiple-select.js"></script>
	<script>
		$('select').multipleSelect();
	</script>
</body>
```

### With Optgroups1

Multiple Select 可以将标准的复选框:

	<select class="w300" multiple="multiple">
		<optgroup label="Group 1">
			<option value="1">Option 1</option>
			<option value="2">Option 2</option>
			<option value="3">Option 3</option>
		</optgroup>
		<optgroup label="Group 2">
			<option value="4">Option 4</option>
			<option value="5">Option 5</option>
			<option value="6">Option 6</option>
		</optgroup>
		<optgroup label="Group 3">
			<option value="7">Option 7</option>
			<option value="8">Option 8</option>
			<option value="9">Option 9</option>
		</optgroup>
	</select>

转换为:

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
	<select multiple="multiple">
	    <optgroup label="Group 1">
			<option value="1">Option 1</option>
			...
		</optgroup>
		...
		<optgroup label="Group 3">
			...
			<option value="9">Option 9</option>
		</optgroup>
	</select>
	<script src="multiple-select.js"></script>
	<script>
		$('select').multipleSelect();
	</script>
</body>
```

### With Optgroups2

Multiple Select 可以将标准的复选框:

	<select class="w300" multiple="multiple">
		<optgroup label="Group 1" disabled="disabled">
			<option value="1">Option 1</option>
			<option value="2">Option 2</option>
			<option value="3">Option 3</option>
		</optgroup>
		<optgroup label="Group 2">
			<option value="4">Option 4</option>
			<option value="5">Option 5</option>
			<option value="6">Option 6</option>
		</optgroup>
		<optgroup label="Group 3">
			<option value="7">Option 7</option>
			<option value="8">Option 8</option>
			<option value="9">Option 9</option>
		</optgroup>
	</select>

转换为:

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
	<select multiple="multiple">
	    <optgroup label="Group 1" disabled="disabled">
			<option value="1">Option 1</option>
			...
		</optgroup>
		...
		<optgroup label="Group 3">
			...
			<option value="9">Option 9</option>
		</optgroup>
	</select>
	<script src="multiple-select.js"></script>
	<script>
		$('select').multipleSelect();
	</script>
</body>
```

### The Placeholder

	<select class="w300" multiple="multiple">
		<option value="1">January</option>
		<option value="2">February</option>
	    <option value="3">March</option>
	    <option value="4">April</option>
	    <option value="5">May</option>
	    <option value="6">June</option>
	    <option value="7">July</option>
	    <option value="8">August</option>
	    <option value="9">September</option>
	    <option value="10">October</option>
	    <option value="11">November</option>
	    <option value="12">December</option>
	</select>

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
    <select multiple="multiple">
        <option value="1">January</option>
        ...
        <option value="12">December</option>
    </select>
    <script src="multiple-select.js"></script>
    <script>
        $("select").multipleSelect({
        	placeholder: "Here is the placeholder"
        });
    </script>
</body>
```

### The Multiple Items

Multiple Select 支持在一行中显示多个选项:

	<select class="w300" multiple="multiple">
		<option value="1">1</option>
		<option value="2">2</option>
		<option value="3">3</option>
		<option value="4">4</option>
		<option value="5">5</option>
		<option value="6">6</option>
		<option value="7">7</option>
		<option value="8">8</option>
		<option value="9">9</option>
		<option value="10">10</option>
		<option value="11">11</option>
		<option value="12">12</option>
		<option value="13">13</option>
		<option value="14">14</option>
		<option value="15">15</option>
		<option value="16">16</option>
		<option value="17">17</option>
		<option value="18">18</option>
		<option value="19">19</option>
		<option value="20">20</option>
		<option value="21">21</option>
		<option value="22">22</option>
		<option value="23">23</option>
		<option value="24">24</option>
		<option value="25">25</option>
		<option value="26">26</option>
		<option value="27">27</option>
		<option value="28">28</option>
		<option value="29">29</option>
		<option value="30">30</option>
	</select>

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
    <select multiple="multiple">
        <option value="1">1</option>
        ...
        <option value="30">30</option>
    </select>
    <script src="multiple-select.js"></script>
    <script>
        $("select").multipleSelect({
        	width: 460,
        	multiple: true,
            multipleWidth: 55
        });
    </script>
</body>
```

### With Optgroups

Multiple Select 支持在一行中显示多个选项以及支持分组。

	<select class="w300" multiple="multiple">
		<optgroup label="Group 1">
			<option value="1">1</option>
			<option value="2">2</option>
			<option value="3">3</option>
			<option value="4">4</option>
			<option value="5">5</option>
		</optgroup>
		<optgroup label="Group 2">
			<option value="6">6</option>
			<option value="7">7</option>
			<option value="8">8</option>
			<option value="9">9</option>
			<option value="10">10</option>
		</optgroup>
		<optgroup label="Group 3">
			<option value="11">11</option>
			<option value="12">12</option>
			<option value="13">13</option>
			<option value="14">14</option>
			<option value="15">15</option>
		</optgroup>
	</select>

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
    <select multiple="multiple">
        <optgroup label="Group 1">
			<option value="1">1</option>
			...
		</optgroup>
        ...
        <optgroup label="Group 3">
			<option value="15">15</option>
		</optgroup>
    </select>
    <script src="multiple-select.js"></script>
    <script>
        $("select").multipleSelect({
        	multiple: true,
            multipleWidth: 55
        });
    </script>
</body>
```

### The Hide Select All

	<select class="w300" multiple="multiple">
		<option value="1">First</option>
        <option value="2">Second</option>
        <option value="3">Third</option>
        <option value="4">Fourth</option>
	</select>

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
    <select multiple="multiple">
        <option value="1">First</option>
        ...
        <option value="4">Fourth</option>
    </select>
    <script src="multiple-select.js"></script>
    <script>
        $("select").multipleSelect({
        	selectAll: false
        });
    </script>
</body>
```

### The Single Row

	<select class="w300" multiple="multiple">
		<option value="1">First</option>
        <option value="2">Second</option>
        <option value="3">Third</option>
        <option value="4" selected="selected">Fourth</option>
	</select>

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
    <select multiple="multiple">
        <option value="1">First</option>
        ...
        <option value="4" selected="selected">Fourth</option>
    </select>
    <script src="multiple-select.js"></script>
    <script>
        $("select").multipleSelect({
        	single: true
        });
    </script>
</body>
```

### The Position

设置下拉列表显示在上方。

	<select class="w300" multiple="multiple">
	    <option value="1">January</option>
		<option value="2">February</option>
	    <option value="3">March</option>
	    <option value="4">April</option>
	    <option value="5">May</option>
	    <option value="6">June</option>
	    <option value="7">July</option>
	    <option value="8">August</option>
	    <option value="9">September</option>
	    <option value="10">October</option>
	    <option value="11">November</option>
	    <option value="12">December</option>
	</select>

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
	<select multiple="multiple" disabled="disabled">
	    <option value="1">January</option>
	    ...
	    <option value="12">December</option>
	</select>
	<script src="multiple-select.js"></script>
	<script>
		$('select').multipleSelect({
		    position: 'top'
		});
	</script>
</body>
```

### The Filter1

	<select class="w300" multiple="multiple">
		<option value="1">abc</option>
		<option value="2">bcd</option>
		<option value="3">cde</option>
		<option value="4">def</option>
		<option value="5">efg</option>
		<option value="6">fgh</option>
		<option value="7">ghi</option>
		<option value="8">hij</option>
		<option value="9">ijk</option>
		<option value="10">jkl</option>
		<option value="11">klm</option>
		<option value="12">lmn</option>
		<option value="13">mno</option>
		<option value="14">nop</option>
		<option value="15">opq</option>
		<option value="16">pqr</option>
		<option value="17">qrs</option>
		<option value="18">rst</option>
		<option value="19">stu</option>
		<option value="20">tuv</option>
		<option value="21">uvw</option>
		<option value="22">vwx</option>
		<option value="23">wxy</option>
		<option value="24">xyz</option>
		<option value="25">123</option>
		<option value="26">234</option>
		<option value="27">345</option>
		<option value="28">456</option>
		<option value="29">567</option>
		<option value="30">678</option>
		<option value="31">789</option>
	</select>

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
    <select multiple="multiple">
        <option value="1">abc</option>
        ...
        <option value="31">789</option>
    </select>
    <script src="multiple-select.js"></script>
    <script>
        $("select").multipleSelect({
        	filter: true
        });
    </script>
</body>
```

### The Filter2

	<select class="w300" multiple="multiple">
		<optgroup label="Group 1">
			<option value="1">000</option>
			<option value="2">111</option>
			<option value="3">222</option>
			<option value="4">333</option>
			<option value="5">444</option>
			<option value="6">555</option>
			<option value="7">666</option>
			<option value="8">777</option>
			<option value="9">888</option>
			<option value="10">999</option>
		</optgroup>
		<optgroup label="Group 2">
			<option value="11">210</option>
			<option value="12">321</option>
			<option value="13">432</option>
			<option value="14">543</option>
			<option value="15">654</option>
			<option value="16">765</option>
			<option value="17">876</option>
			<option value="18">987</option>
			<option value="19">098</option>
		</optgroup>
		<optgroup label="Group 3">
			<option value="20">012</option>
			<option value="21">123</option>
			<option value="22">234</option>
			<option value="23">345</option>
			<option value="24">456</option>
			<option value="25">567</option>
			<option value="26">678</option>
			<option value="27">789</option>
			<option value="28">890</option>
		</optgroup>
	</select>

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
    <select multiple="multiple">
		<optgroup label="Group 1">
			<option value="1">000</option>
			...
		...
    </select>
    <script src="multiple-select.js"></script>
    <script>
        $("select").multipleSelect({
        	filter: true,
        	multiple: true
        });
    </script>
</body>
```

### SetSelects/GetSelects

	<button id="setSelectsBtn" class="button">SetSelects</button>
	<button id="getSelectsBtn" class="button">GetSelects</button>

	<select class="w300" multiple="multiple">
		<option value="1">Monday</option>
		<option value="2">Tuesday</option>
		<option value="3">Wednesday</option>
		<option value="4">Thursday</option>
		<option value="5">Friday</option>
		<option value="6">Saturday</option>
		<option value="7">Sunday</option>
	</select>

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
	<button id="setSelectsBtn">SetSelects</button>
	<button id="getSelectsBtn">GetSelects</button>
    <select multiple="multiple">
        <option value="1">Monday</option>
        ...
        <option value="7">Sunday</option>
    </select>
    <script src="multiple-select.js"></script>
    <script>
        $("select").multipleSelect();
        $("#setSelectsBtn").click(function() {
        	$("select").multipleSelect("setSelects", [1, 3]);
        });
        $("#getSelectsBtn").click(function() {
        	alert("Selected values: " + $("select").multipleSelect("getSelects"));
            alert("Selected texts: " + $("select").multipleSelect("getSelects", "text"));
        });
    </script>
</body>
```

### Enable/Disable

	<button id="enableBtn" class="button">Enable</button>
	<button id="disableBtn" class="button">Disable</button>

	<select class="w300" multiple="multiple">
		<option value="1">Monday</option>
		<option value="2">Tuesday</option>
		<option value="3">Wednesday</option>
		<option value="4">Thursday</option>
		<option value="5">Friday</option>
		<option value="6">Saturday</option>
		<option value="7">Sunday</option>
	</select>

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
	<button id="enableBtn">Enable</button>
	<button id="disableBtn">Disabled</button>
    <select multiple="multiple">
        <option value="1">Monday</option>
        ...
        <option value="7">Sunday</option>
    </select>
    <script src="multiple-select.js"></script>
    <script>
        $("select").multipleSelect();
        $("#setSelectsBtn").click(function() {
        	$("select").multipleSelect("enable");
        });
        $("#getSelectsBtn").click(function() {
        	$("select").multipleSelect("disable");
        });
    </script>
</body>
```

### CheckAll/UncheckAll

	<button id="checkAllBtn" class="button">CheckAll</button>
	<button id="uncheckAllBtn" class="button">UncheckAll</button>

	<select class="w300" multiple="multiple">
		<option value="1">Monday</option>
		<option value="2">Tuesday</option>
		<option value="3">Wednesday</option>
		<option value="4">Thursday</option>
		<option value="5">Friday</option>
		<option value="6">Saturday</option>
		<option value="7">Sunday</option>
	</select>

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
	<button id="enableBtn">Enable</button>
	<button id="disableBtn">Disabled</button>
    <select multiple="multiple">
        <option value="1">Monday</option>
        ...
        <option value="7">Sunday</option>
    </select>
    <script src="multiple-select.js"></script>
    <script>
        $("select").multipleSelect();
        $("#setSelectsBtn").click(function() {
        	$("select").multipleSelect("checkAll");
        });
        $("#getSelectsBtn").click(function() {
        	$("select").multipleSelect("uncheckAll");
        });
    </script>
</body>
```

### The Refresh

重新加载 Multiple Select:
假如你是通过 AJAX 或者 DOM 来手动添加或者删除 option 选项,可以通过 refresh 方法来重新加载 Multiple Select。

	<input id="refreshInput" type="text" required="required" />
	<button id="refreshAdd" class="button">Add + Refresh</button>

	<input id="refreshSelected" type="checkbox" />Selected?
	<input id="refreshDisabled" type="checkbox" />Disabled?

	<select class="w300" multiple="multiple">
		<option value="1">1</option>
		<option value="2">2</option>
		<option value="3">3</option>
	</select>

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
	<input id="refreshInput" type="text" required="required" />
	<button id="refreshAdd">Add + Refresh</button>
	<br />
	<label><input id="refreshSelected" type="checkbox" />Selected?</label>
	<label><input id="refreshDisabled" type="checkbox" />Disabled?</label>
    <select multiple="multiple">
        <option value="1">1</option>
        ...
        <option value="3">3</option>
    </select>
    <script src="multiple-select.js"></script>
    <script>
        $("select").multipleSelect();
        $("#refreshAdd").click(function() {
        	var $select = $("select"),
        		$input = $("#refreshInput"),
        		$selected = $("#refreshSelected"),
        		$disabled = $("#refreshDisabled"),
        		value = $.trim($input.val()),
        		$opt = $("<option />", {
					value: value,
					text: value
				});
        	if (!value) {
        		$input.focus();
        		return;
        	}
			if ($selected.is(":checked")){
				$opt.prop("selected", true);
			}
			if($disabled.is(":checked")){
				$opt.attr("disabled", true);
			}
			$input.val("");
			$select.append($opt).multipleSelect("refresh");
        });
    </script>
</body>
```

### The Callbacks/Events

这里显示事件的结果。

	<select class="w300" multiple="multiple">
		<optgroup label="Group 1">
			<option value="1">000</option>
			<option value="2">111</option>
			<option value="3">222</option>
			<option value="4">333</option>
			<option value="5">444</option>
			<option value="6">555</option>
			<option value="7">666</option>
			<option value="8">777</option>
			<option value="9">888</option>
			<option value="10">999</option>
		</optgroup>
		<optgroup label="Group 2">
			<option value="11">210</option>
			<option value="12">321</option>
			<option value="13">432</option>
			<option value="14">543</option>
			<option value="15">654</option>
			<option value="16">765</option>
			<option value="17">876</option>
			<option value="18">987</option>
			<option value="19">098</option>
		</optgroup>
		<optgroup label="Group 3">
			<option value="20">012</option>
			<option value="21">123</option>
			<option value="22">234</option>
			<option value="23">345</option>
			<option value="24">456</option>
			<option value="25">567</option>
			<option value="26">678</option>
			<option value="27">789</option>
			<option value="28">890</option>
		</optgroup>
	</select>

``` html
<head>
	<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
	<p id="eventResult">Here is the result of event.</p>
    <select multiple="multiple">
        <optgroup label="Group 1">
			<option value="1">000</option>
			...
		...
    </select>
    <script src="multiple-select.js"></script>
    <script>
        $("select").multipleSelect({
        	onOpen: function() {
        		$eventResult.text('Select opened!');
        	},
        	onClose: function() {
        		$eventResult.text('Select closed!');
        	},
        	onCheckAll: function() {
        		$eventResult.text('Check all clicked!');
        	},
        	onUncheckAll: function() {
        		$eventResult.text('Uncheck all clicked!');
        	},
        	onOptgroupClick: function(view) {
				var values = $.map(view.children, function(child){
					return child.value;
				}).join(', ');
				$eventResult.text('Optgroup ' + view.label + ' ' +
					(view.checked ? 'checked' : 'unchecked') + ': ' + values);
			},
			onClick: function(view) {
				$eventResult.text(view.label + '(' + view.value + ') ' +
					(view.checked ? 'checked' : 'unchecked'));
			}
        });
    </script>
</body>
```

## Documentation

### Constructor

#### isOpen

类型: boolean

是否打开下拉列表。

默认值为 ```false```。

#### placeholder

类型: string

显示默认的提示信息。

默认值为 ```''```。

#### selectAll

类型: boolean

是否显示全选复选框。

默认值为 ```true```。

#### selectAllText

类型: string

全选复选框的显示内容。

默认值为 ```Select all```。

#### multiple

类型: boolean

是否在一行中显示多个选项。

默认值为 ```false```。

#### multipleWidth

类型: integer

一行中每个选项的宽度。

默认值为 ```80```。

#### single

类型: boolean

是否只允许你选择一行。

默认值为 ```false```。

#### position

类型: string

定义下拉列表的位置,只能是 ```bottom``` 或者 ```top```。

默认值为 ```bottom```.

#### filter

类型: boolean

是否开启过滤功能。

默认值为 ```false```。

#### width

类型: integer

定义下拉列表的宽度。

默认值为 ```undefined```。 默认与 select 的宽度相同。

#### maxHeight

类型: integer

下拉列表的最大高度。

默认值为 ```250```。

### Events

#### onOpen

当下拉列表被打开时触发。

#### onClose

当下拉列表被关闭时触发。

#### onCheckAll

点击全选或者调用 "checkall" 方法时触发。

#### onUncheckAll

点击全不选或者调用 "uncheckall" 方法时触发。

#### onOptgroupClick

点击分组时触发。

```javascript
onOptgroupClick: function(view) {
	/*
	view.label: the text of the optgroup
	view.checked: the checked of the optgroup
	view.children: an array of the checkboxes (DOM elements) inside the optgroup
	*/
}
```

#### onClick

点击一个复选框时触发。

```javascript
onOptgroupClick: function(view) {
	/*
	view.label: the text of the checkbox item
	view.checked: the checked of the checkbox item
	*/
}
```

### Methods

#### getSelects

获取 Multiple Select 选择内容。

参数: type

类型: string

选择内容的类型,value 或者 text。

默认值为 ```value```。

``` javascript
alert('Selected values: ' + $('select').multipleSelect('getSelects'));
alert('Selected texts: ' + $('select').multipleSelect('getSelects', 'text'));
```

#### setSelects

设置 Multiple Select 的内容。

参数: values

类型: array

选择框的内容信息。

``` javascript
$('select').multipleSelect('setSelects', [1, 3]);
```

#### enable

启用 Multiple Select。

``` javascript
$('select').multipleSelect('enable');
```

#### disable

禁用 Multiple Select。在这种模式下,不允许用户操作。

``` javascript
$('select').multipleSelect('disable');
```

#### checkAll

全选所有的复选框。

``` javascript
$('select').multipleSelect('checkAll');
```

#### uncheckAll

全不选所有的复选框。

``` javascript
$('select').multipleSelect('uncheckAll');
```

#### refresh

重新加载 Multiple Select。

假如你是通过 AJAX 或者 DOM 来手动添加或者删除 option 选项,可以通过 refresh 方法来重新加载 Multiple Select。

``` javascript
$('select').multipleSelect('refresh');
```

## About

[博客](http://wenzhixin.net.cn)

[scutech](http://www.scutech.com)

## Acknowledgements

© 2012-2014, Multiple Selected is licensed under the The MIT License. Coded by wenzhixin.

我的网站 ([wenzhixin.net.cn](http://wenzhixin.net.cn))

Github ([@wenzhixin](https://github.com/wenzhixin))

微博 ([@_文翼_](http://weibo.com/2292826740))

邮件 (wenzhixin2010@gmail.com)


text:
package continuum.core.atom;

import continuum.atom.AtomID;

/**
 * An atom in a time key values continuum
 * Created by zack on 2/12/16.
 */
public class KAtom extends AAtom {

    // for serde
    public KAtom() { }

    public KAtom(String name, AParticles particles, long timestamp, AFields fields, AValues values) {
        super(name, particles, timestamp, fields, values);
    }

    @Override
    public AtomID ID() {
        // TODO: Cache? Mutability?
        return new KAtomID(this);
    }
}


text:
package com.macro.mall.model;

import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;

public class PmsProductCategoryAttributeRelation implements Serializable {
    private Long id;

    private Long productCategoryId;

    private Long productAttributeId;

    private static final long serialVersionUID = 1L;

    public Long getId() {
        return id;
    }

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

    public Long getProductCategoryId() {
        return productCategoryId;
    }

    public void setProductCategoryId(Long productCategoryId) {
        this.productCategoryId = productCategoryId;
    }

    public Long getProductAttributeId() {
        return productAttributeId;
    }

    public void setProductAttributeId(Long productAttributeId) {
        this.productAttributeId = productAttributeId;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", productCategoryId=").append(productCategoryId);
        sb.append(", productAttributeId=").append(productAttributeId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}


text:
Given /^following comments exist:$/ do |comments_table|
  Comment.destroy_all
  comments_table.hashes.each do |attributes|
    Factory(:comment, attributes)
  end
end


text:
package org.apache.tiles.request.render;

import static org.easymock.classextension.EasyMock.*;
import static org.junit.Assert.*;

import org.apache.tiles.request.ApplicationContext;
import org.junit.Before;
import org.junit.Test;

/**
 * Basic renderer factory implementation.
 *
 * @version $Rev$ $Date$
 */
public class BasicRendererFactoryTest {

    /**
     * The renderer factory.
     */
    private BasicRendererFactory rendererFactory;

    /**
     * Sets up the test.
     */
    @Before
    public void setUp() {
        rendererFactory = new BasicRendererFactory();
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        replay(applicationContext);
    }

    /**
     * Tests execution and
     * {@link BasicRendererFactory#getRenderer(String)}.
     */
    @Test
    public void testInitAndGetRenderer() {
        Renderer renderer1 = createMock(Renderer.class);
        Renderer renderer2 = createMock(Renderer.class);
        Renderer renderer3 = createMock(Renderer.class);
        Renderer renderer4 = createMock(Renderer.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);

        replay(renderer1, renderer2, renderer3, renderer4, applicationContext);
        rendererFactory.registerRenderer("string", renderer1);
        rendererFactory.registerRenderer("test", renderer2);
        rendererFactory.registerRenderer("test2", renderer3);
        rendererFactory.setDefaultRenderer(renderer4);
        Renderer renderer = rendererFactory.getRenderer("string");
        assertSame(renderer1, renderer);
        renderer = rendererFactory.getRenderer("test");
        assertSame(renderer2, renderer);
        renderer = rendererFactory.getRenderer("test2");
        assertSame(renderer3, renderer);
        renderer = rendererFactory.getRenderer(null);
        assertSame(renderer4, renderer);
        verify(renderer1, renderer2, renderer3, renderer4, applicationContext);
    }

    /**
     * Tests execution and
     * {@link BasicRendererFactory#getRenderer(String)}.
     */
    @Test(expected = NoSuchRendererException.class)
    public void testGetRendererException() {
        Renderer renderer1 = createMock(Renderer.class);
        Renderer renderer2 = createMock(Renderer.class);
        Renderer renderer3 = createMock(Renderer.class);
        Renderer renderer4 = createMock(Renderer.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);

        replay(renderer1, renderer2, renderer3, renderer4, applicationContext);
        rendererFactory.registerRenderer("string", renderer1);
        rendererFactory.registerRenderer("test", renderer2);
        rendererFactory.registerRenderer("test2", renderer3);
        rendererFactory.setDefaultRenderer(renderer4);
        try {
            rendererFactory.getRenderer("nothing");
        } finally {
            verify(renderer1, renderer2, renderer3, renderer4, applicationContext);
        }
    }

    /**
     * Tests {@link BasicRendererFactory#initializeRenderer(AttributeRenderer)}.
     */
    @Test
    public void testInitializeRenderer() {
        // TODO This will be removed in future, only named renderers should be available.
    }
}


text:
<?php
namespace Users\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Authentication\AuthenticationService;
use Zend\Authentication\Adapter\DbTable as DbTableAuthAdapter;

use Users\Form\RegisterForm;
use Users\Form\RegisterFilter;

use Users\Form\LoginForm;
use Users\Form\LoginFilter;

use Users\Model\User;

class UsersController extends AbstractActionController
{

  protected $userTable;
  protected $authService;

  public function indexAction()
  {
      return new ViewModel();
  }

  public function registerAction()
  {
    $form = new RegisterForm();

    $form->get('submit')->setValue('Add');

    $request = $this->getRequest();
    if ($request->isPost()) {
      $user = new User();
      $form->setInputFilter(new RegisterFilter()); // dependency injection
      $form->setData($request->getPost());

      if ($form->isValid()) {
        $user->exchangeArray($form->getData());
        $this->getUserTable()->saveUser($user);

        return $this->redirect()->toUrl('/');
      }
    }

    return array('form' => $form);
  }

  public function loginAction()
  {
    $form = new LoginForm();

    $form->get('submit')->setValue('Login');

    $request = $this->getRequest();
    if ($request->isPost()) {

        $this->getAuthService()
          ->getAdapter()
          ->setIdentity($this->request->getPost('email'))
          ->setCredential($this->request->getPost('password'));

        $result = $this->getAuthService()->authenticate();

        if ($result->isValid()) {
          $this->getAuthService()->getStorage()->write($this->request->getPost('email'));
          //\Zend\Debug\Debug::dump();
          return $this->redirect()->toUrl('/');
        }
    }

    return new ViewModel(array(
      'form' => $form,
    ));
  }

  protected function getAuthService() {
    if (! $this->authService) {
      $dbAdapter = $this->getServiceLocator()->get('\Zend\Db\Adapter\Adapter');

      $dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'users', 'email', 'password', 'MD5(?)');

      $authService = new AuthenticationService();
      $authService->setAdapter($dbTableAuthAdapter);

      $this->authService = $authService;
    }

    return $this->authService;
  }

  protected function getUserTable()
  {
    if (!$this->userTable) {
      $sm = $this->getServiceLocator();
      $this->userTable = $sm->get('User\Model\UserTable');
    }
    return $this->userTable;
  }

}


text:
var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'jiameng',
  password : 'jiameng123',
  database : 'blog'
});
connection.connect();
connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
  if (error) throw error;
  console.log('The solution is: ', results[0].solution);
});

var  sql = 'SELECT * FROM posts';
connection.query(sql,function (err, result) {
        if(err){
          console.log('[SELECT ERROR] - ',err.message);
          return;
        }
       console.log('--------------------------SELECT----------------------------');
       console.log(result);
       console.log('------------------------------------------------------------\n\n');
});

connection.end();


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace PivotalTrackerDotNet.Domain
{
    public class AuthenticationToken
    {
        public Guid Guid { get; set; }
        public int Id { get; set; }

        public override string ToString()
        {
            return new XElement("token",
                                new XElement("guid", Guid.ToString()),
                                new XElement("id",
                                            new XAttribute("type", "integer"),
                                            Id)).ToString();
        }
    }
}


text:
'use strict';

var chai = require('chai');
var expect = chai.expect;
var sutPath = '../../lib/util/end-waterfall';
var sut = require(sutPath);

describe('end-waterfall', function(){
  it('returns function', function(){
    expect(sut()).to.be.a.func;
  });
  describe('returned function', function(){
    it('returns result if endReason is true', function(){
      var func = sut(function(err, result){
        expect(result).to.equal('blah');
      });
      func(true, 'blah');
    });
    it('returns error if endReason is error', function(){
      var func = sut(function(err){
        expect(err).to.be.instanceOf(Error);
      });
      func(new Error());
    });
    it('returns result if no endReason', function(){
      var func = sut(function(err, result){
        expect(result).to.equal('blah');
      });
      func(null, 'blah');
    });
  });
});


text:
package tx;

import util.*;
import hydra.*;
import com.gemstone.gemfire.cache.*;

public class TxLoader implements CacheLoader {

public Object load(LoaderHelper helper) throws CacheLoaderException {

   Object key = helper.getKey();
   Object anObj = TxUtil.txUtilInstance.getNewValue(key);
   Log.getLogWriter().info("In TxLoader, returning " + ((BaseValueHolder)anObj).toString());
   return anObj;
}

public void close() {
}

}


text:
layout: post
title: "Five hypekus — because we can"
modified:
categories: blog
excerpt:
tags: ["poetry", "hype", "haiku", "sense", "nonsense"]
date: 2018-01-20T18:00:00-00:00
share: true
---

# Artificial intelligence

> Knowing humankind's

> Usual intelligence

> [Can AI do worse][elon_musk_ai]?

# Blockchain

> When the snake is [forked][fork]

> And schismatizes in two

> What is fool's truth worth?

# Crypto-currency

> Them [coins and tokens][cryptocurrency]

> Soaped up in bubbly wallets

> Yearning for value

# Deep learning

> [Valley][gradient_descent] in sight, when

> [Selection bias][selection_bias] abyss

> Swallows the climber

# Internet of things

> On the Internet

> Each [dog][newyorker_internet] knows a [smelly thing][smell_tech]

> To [sniff][iot_security] that's secret

[fork]: https://en.wikipedia.org/wiki/Fork_(blockchain)
[cryptocurrency]: https://en.wikipedia.org/wiki/Cryptocurrency
[gradient_descent]: https://en.wikipedia.org/wiki/Gradient_descent
[selection_bias]: https://en.wikipedia.org/wiki/Selection_bias
[newyorker_internet]: https://en.wikipedia.org/wiki/On_the_Internet,_nobody_knows_you%27re_a_dog
[elon_musk_ai]: https://www.youtube.com/watch?v=kZp-l22OD-c
[iot]: https://en.wikipedia.org/wiki/Internet_of_things
[iot_security]: https://techcrunch.com/2015/10/24/why-iot-security-is-so-critical/
[smell_tech]: https://internetofbusiness.com/internet-smells-olfaction-via-nanomechanical-sensors/


text:
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
::     http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
::

::
:: Appveyor script for MSYS
::

::
:: Installs third party packages we need for a cmake build
::

@ECHO ON
SETLOCAL EnableDelayedExpansion

CD build\appveyor || EXIT /B

SET APPVEYOR_SCRIPTS=%APPVEYOR_BUILD_FOLDER%\build\appveyor
SET BUILDDIR=%APPVEYOR_BUILD_FOLDER%\..\build\%PROFILE%\%PLATFORM%
SET INSTDIR=%APPVEYOR_BUILD_FOLDER%\..\install\%PROFILE%\%PLATFORM%
SET SRCDIR=%APPVEYOR_BUILD_FOLDER%

ECHO Unsupported PROFILE=%PROFILE% or PLATFORM=%PLATFORM%
EXIT /B 1

SET BASH=C:\msys64\usr\bin\bash
SET CMAKE=/c/msys64/mingw64/bin/cmake.exe

CALL win_showenv.bat || EXIT /B

SET PACKAGES=^
  base-devel ^
  mingw-w64-x86_64-toolchain ^
  bison ^
  flex ^
  make ^
  mingw-w64-x86_64-cmake ^
  mingw-w64-x86_64-libevent ^
  mingw-w64-x86_64-openssl ^
  mingw-w64-x86_64-zlib

:: Upgrade things
%BASH% -lc "pacman --noconfirm -Syu %IGNORE%" || EXIT /B
%BASH% -lc "pacman --noconfirm -Su %IGNORE%" || EXIT /B
%BASH% -lc "pacman --noconfirm --needed -S %PACKAGES%" || EXIT /B

::
:: Configure and build our software with cmake
::

SET CMAKEARGS=^
  -G'%GENERATOR%' ^
  -DBoost_DEBUG=ON ^
  -DBoost_NAMESPACE=libboost ^
  -DBOOST_INCLUDEDIR=%BOOST_INCLUDEDIR% ^
  -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% ^
  -DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
  -DCMAKE_C_COMPILER=gcc.exe ^
  -DCMAKE_CXX_COMPILER=g++.exe ^
  -DCMAKE_MAKE_PROGRAM=make.exe ^
  -DCMAKE_INSTALL_PREFIX=%INSTDIR_MSYS% ^
  -DLIBEVENT_ROOT=%LIBEVENT_ROOT% ^
  -DOPENSSL_LIBRARIES=%OPENSSL_LIBRARIES% ^
  -DOPENSSL_ROOT_DIR=%OPENSSL_ROOT% ^
  -DOPENSSL_USE_STATIC_LIBS=ON ^
  -DWITH_BOOST_STATIC=ON ^
  -DWITH_JAVA=OFF ^
  -DWITH_LIBEVENT=ON ^
  -DWITH_PYTHON=%WITH_PYTHON% ^
  -DWITH_SHARED_LIB=OFF ^
  -DWITH_STATIC_LIB=ON

%BASH% -lc "mkdir %BUILDDIR% && cd %BUILDDIR% && %CMAKE% %SRCDIR_MSYS% %CMAKEARGS% && %CMAKE% --build . --config %CONFIGURATION% && %CMAKE% --install . --config %CONFIGURATION%" || EXIT /B

::
:: Execute our tests
::

:: This test randomly fails on mingw; see Jira THRIFT-4106
SET DISABLED_TESTS=(concurrency_test)
SET DISABLED_TESTS_COMMAND=--exclude-regex '%DISABLED_TESTS%'

%BASH% -lc "cd %BUILDDIR% && ctest.exe --build-config %CONFIGURATION% --timeout 300 --extra-verbose %DISABLED_TESTS_COMMAND%" || EXIT /B


text:
package example.tablelist;

import io.parcoord.MakeTableModel;

import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableRowSorter;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import example.tablelist.renderers.ColourBarCellRenderer;

import swingPlus.shared.MyFrame;
import ui.AnimatedTableUI;
import ui.MultiCellSpanTableUI;
import util.Messages;
import util.ui.NewMetalTheme;

public class ColumnSpanningTable {

	JFrame jframe;
	final static Logger LOGGER = Logger.getLogger (ColumnSpanningTable.class);
	/**
	 * @param args
	 */
	public static void main (final String[] args) {

		MetalLookAndFeel.setCurrentTheme (new NewMetalTheme());
		PropertyConfigurator.configure (Messages.makeProperties ("log4j"));

		LOGGER.info ("Logger activated");

		new ColumnSpanningTable (args.length > 0 ? args[0] : Messages.getString ("ExampleMultiColDataFile"));
	}

	public ColumnSpanningTable (final String dataFileName) {

		final MakeTableModel mtm = new MakeTableModel ();
		final DefaultTableModel dtm = mtm.buildDataModel (dataFileName);
		//final List<Format> columnTextFormatters = mtm.getColumnTextFormatters();

		//TableUtils.makeAverageRows (dtm);

		final JTable jtable3 = new JTable (dtm);
		jtable3.setSelectionMode (ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
		jtable3.setRowSelectionAllowed (true);
		//jt2.setColumnSelectionAllowed (true);
		jtable3.setRowSorter (new TableRowSorter<DefaultTableModel> (dtm));
		final AnimatedTableUI tlui = new MultiCellSpanTableUI ();
		jtable3.setUI (tlui);
		//jtable3.setDefaultRenderer (String.class, new DefaultTableCellRenderer ());

		final TableColumnModel tcm = jtable3.getColumnModel();
		final Color[] columnColours = {Color.red, Color.orange, Color.yellow, Color.green, Color.cyan,
				Color.blue, Color.magenta};

		for (int col = 1; col < tcm.getColumnCount(); col++) {
			tcm.getColumn(col).setCellRenderer (new ColourBarCellRenderer (columnColours [(col - 1) % columnColours.length]));
		}

		SwingUtilities.invokeLater (
			new Runnable () {
				@Override
				public void run() {
					jframe = new MyFrame ("Multi-Column Cell Span Table Demo");
					jframe.setSize (1024, 768);

					final JScrollPane jscp1 = new JScrollPane ();
					jscp1.setViewportView (jtable3);

					jframe.getContentPane().add (jscp1);
					jframe.setVisible (true);

					//jtable3.setRowHeight (3, 24);
					//jtable3.setRowHeight (6, 72);
				}
			}
		);

	}
}


text:
import unittest

from hwt.hdl.constants import Time
from hwt.interfaces.utils import addClkRstn, propagateClkRstn
from hwt.simulator.simTestCase import SimTestCase
from hwt.synthesizer.param import Param
from hwt.synthesizer.unit import Unit
from hwtLib.amba.axis import AxiStream
from hwtLib.xilinx.locallink.axis_conv import LocalLinkToAxiS, AxiSToLocalLink
from pyMathBitPrecise.bit_utils import mask

class LocalLink_AxiSConvTest(Unit):

    def _config(self):
        self.DATA_WIDTH = Param(64)
        self.USER_WIDTH = Param(2)
        self.USE_STRB = Param(True)

    def _declr(self):
        addClkRstn(self)
        with self._paramsShared():
            self.dataIn = AxiStream()
            self.conv0 = AxiSToLocalLink()
            self.conv1 = LocalLinkToAxiS()
            self.dataOut = AxiStream()._m()

    def _impl(self):
        propagateClkRstn(self)
        self.conv0.dataIn(self.dataIn)
        self.conv1.dataIn(self.conv0.dataOut)
        self.dataOut(self.conv1.dataOut)

class AxiS_localLinkConvTC(SimTestCase):

    @classmethod
    def setUpClass(cls):
        cls.u = LocalLink_AxiSConvTest()
        cls.compileSim(cls.u)

    def test_nop(self):
        u = self.u
        self.runSim(200 * Time.ns)

        self.assertEmpty(u.dataOut._ag.data)

    def test_simple(self):
        u = self.u

        # (data, strb, user, last)
        d = [(13, mask(8), 0b01, 0),
             (14, mask(1), 0b10, 1)]

        u.dataIn._ag.data.extend(d)
        self.runSim(200 * Time.ns)

        self.assertValSequenceEqual(u.dataOut._ag.data, d)

if __name__ == "__main__":
    suite = unittest.TestSuite()
    # suite.addTest(AxiS_localLinkConvTC('test_withPause'))
    suite.addTest(unittest.makeSuite(AxiS_localLinkConvTC))
    runner = unittest.TextTestRunner(verbosity=3)
    runner.run(suite)