text:
<?php
    // load up your config file
    //header("Location: main.php");
    //Make a priority queue of most likely classes to take.
    //When you press yes and took, priority goes to 0.
    //Whem you press no, priority goes to 50%

    require_once("resources/API.php");
    require_once("resources/user.php");

    //$current_user = new user();
    //echo "
".$_COOKIE["user"]."
";
    //echo "
".$_COOKIE["priority"]."
";

?>

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Bootstrap 101 Template</title>

    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="main.css" rel="stylesheet">

SUGGESTR

        <form class = "description">

Who are you?

          <?php require_once("resources/DropdownMajor.php"); ?>
          Major

          <?php require_once("resources/DropdownYear.php"); ?>
          Year

          <button class="btn btn-lg btn primary btn-block" type="submit">Start Session</button>
        </form>

      <?php
        //echo "
 TEST
";

        $current_user = new user($conn,$_COOKIE["user"]);
        //$current_user->print_this();
        //DEBUGGER!!!

        //echo "
 priority GET:  ".$current_user->getPriority($conn)."
";
        //echo "
id".$current_user->request_course_id($conn)."
";
        //echo "
course".$current_user->request_course_name($conn,$current_user->request_course_id($conn))."
";
        //echo "
DAWW AW".$current_user->request_course_id($conn)."
";
        $current_user->get_array_similar($conn);
        $current_user->print_this($conn);
        /*
        $selected_courses = $current_user->get_array_similar($conn);
        echo "
";
        while($potential_course = mysqli_fetch_row($selected_courses)){
            echo "
".$potential_course[1]." : ".request_course_name($conn,$potential_course[0])."
";
        }
        echo "
";*/
      ?>


text:
package com.farhankhan.imageresizer;

import java.io.File;

/**
 * @author farhankhan
 * URL: https://github.com/mfarhan133/Android-Image-Resizer-Module
 *
 */
public class IconResizerMain {

    public static String SEPARATOR = "/";

    public static final String SOURCE_ICON_512x512 = "YOUR_PROJECT_PATH/MyTestProject/app/src/main/ic_launcher-web.png";
    public static final String PROJECT_RES_DIRECTORY = "YOUR_PROJECT_PATH/MyTestProject/app/src/main/res" + SEPARATOR;

    public static final String ICON_NAME = "ic_launcher.png";

    public static void main(String[] args) {
        try {

            //Ref: https://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html#size

            createIcon("mipmap-ldpi",    32,  32);
            createIcon("mipmap-mdpi",    48,  48);
            createIcon("mipmap-hdpi",    72,  72);
            createIcon("mipmap-xhdpi",   96,  96);
            createIcon("mipmap-xxhdpi",  144, 144);
            createIcon("mipmap-xxxhdpi", 192, 192);

            System.out.println("\n ****** All different res icons created successfully :) ******\n\n");
        } catch (Exception e) {
            System.out.println("--> ERROR: Some Exception Occurred.");
            System.out.println("--> ERROR: Exception Message: "+ e.getMessage());
            System.out.println("--> ERROR: Stack Trace:");
            e.printStackTrace();
        }
    }

    public static void createIcon(String directory, int width, int height) throws Exception{
        final String destinationDirectory = PROJECT_RES_DIRECTORY + directory + SEPARATOR;
        //create new directory
        new File(destinationDirectory).mkdirs();
        //resize icon
        Utils.resizeImageTo (
            SOURCE_ICON_512x512,
            destinationDirectory,
            ICON_NAME,
            width,
            height
        );
    }

}

redpajama_set_name: RedPajamaGithub


text:
import os, sys, glob, string, subprocess, time, re, socket, datetime
import ConfigParser
from optparse import OptionParser, OptionGroup
from Timer import Timer
from hurry.filesize import size

print "sys.argv = ", sys.argv
CWD = os.getcwd()
if sys.platform.startswith("linux"):
	print "@@@ [script: %s] [pwd: %s] [host: %s] @@@" % (sys.argv[0], CWD, os.popen("ifconfig | grep -A 2 'eth' | grep 'inet addr:' | cut -d':' -f2 | awk '{print $1}'").read().strip())

# optionparser cb
def vararg_cb(option, opt_str, value, parser):
	assert value is None
	value = []
	for arg in parser.rargs:
		if arg[:2]=="--" and len(arg)>2: break
		value.append(arg)
	del parser.rargs[:len(value)]
	setattr(parser.values, option.dest, value)

parse = OptionParser(usage="Usage: %prog [options] test_script [test_scripts]")
parse.add_option("--dry-run", action="store_true", dest="dryrun", default=False, help="dry run mode - Don't actually do it, just pretend and go through the motions.")
parse.add_option("--env", action="store", dest="env", type="string")
parse.add_option("--tag", dest="tag", action="callback", callback=vararg_cb)
parse.add_option("--ie", action="store_true", dest="ie", default=False, help="Use IE WebDriver. This will launch IE instead of the default Firefox.")
parse.add_option("--chrome", action="store_true", dest="chrome", default=False, help="Use Chrome WebDriver. This will launch Chrome instead of the default Firefox.")
parse.add_option("--safari", action="store_true", dest="safari", default=False, help="Use Safari WebDriver. This will launch Safari instead of the default Firefox.")
parse.add_option("--phantomjs", action="store_true", dest="phantom", default=False, help="Use PhantomJS WebDriver. This will launch PhantomJS instead of the default Firefox.")

group = OptionGroup(parse, "Debug options")
group.add_option("-d", "--debug", action="store_true", dest="debug", default=False, help="Break into python debugger on first fail.")
group.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose mode.")
group.add_option("-b", "--batch", action="store_true", dest="batch", default=False, help="RobotFramework batch mode.")
group.add_option("-p", "--pause", action="store", dest="pause", type="string", metavar="[secs pause]", default="1.0", help="Pause in seconds in between each run. [Default set to 1.0s]")

parse.add_option_group(group)

if len(sys.argv)==1 or sys.argv[0]=='-h' or sys.argv[0]=='--help' or sys.argv[0]=='-help':
	parse.print_help()
	sys.exit(1)

(options,args) = parse.parse_args()
if options.verbose:
	print " => options: %s" % str(options)
	print " => args:    %s" % str(args)

# XXX FIXME XXX
import params
if options.ie or options.safari:
	if sys.platform != "win32":
		sys.stderr.write("!!! WARN: You selected to run IE on a non-Windows platform. Defaulting to Firefox !!!\n")
	else:
		if options.ie:
			print " => Using IE Webdriver"
			params.BROWSER = 'Ie'
		elif options.safari:
			print " => Using Safari Webdriver"
			params.BROWSER = 'Safari'
elif options.chrome:
	print " => Using Chrome Webdriver"
	params.BROWSER = 'Chrome'
elif options.phantom:
	print " => Using PhantomJS Webdriver"
	params.BROWSER = 'PhantomJS'
else:
	print " => Using default Firefox Webdriver"
import sst.config
sst.config.browser_type = params.BROWSER

# hosts.ini is only for Windows platform
if HOST==None or DB==None:
	HOSTS_INI = "hosts.ini"
	if os.path.exists(HOSTS_INI):
		config = ConfigParser.ConfigParser()
		config.read(HOSTS_INI)

		if not all(map(config.has_section, ['HOST','DB'])):
			sys.stderr.write(" XXX Fatal Error XXX\n ")
			sys.exit(1)

		if HOST==None:
			HOST = config.get('HOST','host')
		if DB==None:
			DB = config.get('DB','db',None)

	if HOST==None or DB==None:
		sys.stderr.write(" XXX Fatal Error XXX\n ")
		sys.exit(1)
# End of hosts.ini

def seed_sequence_list(l):
	import random
	random.shuffle(l)
	return l

def generate_runlist(l):
	r = []
	for (seq,tc) in enumerate(l,1):
		# from testcase name get actual testcase file (filename). testcase = testcase file - file extension
		files = glob.glob(tc + "*")
		files = sorted(files)

		# check to make sure TC file(s) actually exists and match the TC in runlist
		if len(files)==0:
			sys.stderr.write("!!! WARN: Can't find TC: %s in current dir: %s !!!\n" % (tc,os.getcwd()))
			continue

		filename = files[0]	# container is always first	after sorting

		# if multiple TC files found, need to make sure container file exists
		if len(files)>1:
			if options.verbose: print " [%s] => glob(TC*) returned => %s " % (tc,str(files))

			if os.path.splitext(filename)[-1]!='':
				print "!!! WARN: Inconsistency in TC detected. It appears that you have multiple files for TC (%s) but no container for it. Skipping !!!" % (tc)
				continue

		print "	@@@ (%d) [%s] @@@ " % (seq,filename)
		r.append(create_runner(filename))
	return r

import generic_testloader
loader = generic_testloader.generic_testloader()

def create_runner(file):
	(name,ext) = os.path.splitext(file)
	if   ext == ".txt":
		return PyBotRunner(name, file)
	elif ext == ".py":
		return PyTestRunner(name, file)
	elif ext == ".xml":
		return SoapUIRunner(name, file)
	elif ext == "":
		return ContainerRunner(name, file)
	else:
		raise NotImplementedError("No runner found for this file type.")

class AbstractRunner(object):
	def __init__(self, name, file):
		self.name = name
		self.file = file
		self.seq = 0

	def __str__(self):
		return "#%d. [%s (%s)] => [%s]"%(self.seq,self.file,self.name,self.__class__.__name__)

	def run(self):
		raise NotImplementedError

from functools import wraps
def run(s):
	@wraps(s)
	def wrapper(*args):
		args[0].seq = [ i.name for i in runlist ].index(args[0].name)+1
		status = " [%d / %d] " % (args[0].seq, len(runlist))
		pad = (78-len(status))/2
		print "%s%s%s" % ("<"*pad,status,">"*pad)

		if options.pause:
			if options.verbose:
				print " ... sleeping for %s s between runs ... " % options.pause
			time.sleep(float(options.pause))
		with Timer() as t:
			result = s(*args)
		status = " [%s] " % (str(datetime.timedelta(seconds=t.secs)))
		pad = (78-len(status))/2
		print "%s%s%s" % (">"*pad,status,"<"*pad)

		return result
	return wrapper

class PyBotRunner(AbstractRunner):
	def __init__(self, name, file):
		AbstractRunner.__init__(self, name, file)

	@run
	def run(self):
		if options.verbose: print " @@@ in PyBotRunner (%s) @@@ " % self.file

		rc = 0
		if not options.batch:
			os.putenv('DB_PROPERTIES',db_prop)
			try:
				rc = loader.run_pybot(self.file)
			except AssertionError:
				rc = 1

		else:
			from robot.api import TestSuite, TestSuiteBuilder
			suite = TestSuite(str(self))
			suite.imports.resource("common_resource.txt")
			suite.imports.library("generic_testloader")
			t = suite.tests.create(name=self.name)
			t.keywords.create("Set Environment Variable", args=["DB_PROPERTIES",db_prop])
			t.keywords.create("Run Pybot", args=[self.file])
			rc = suite.run(loglevel=os.getenv('ROBOT_SYSLOG_LEVEL'), outputdir=os.path.join(os.getenv('ROBOT_REPORTDIR'),self.name))
			#debugfile=os.getenv('ROBOT_DEBUGFILE')
			rc = rc.return_code
		return rc

class PyTestRunner(AbstractRunner):
	def __init__(self, name, file):
		AbstractRunner.__init__(self, name, file)

	@run
	def run(self):
		if options.verbose: print " @@@ in PyTestRunner (%s) @@@ " % self.file

		rc = 0
		if not options.batch:
			os.putenv('DB_PROPERTIES',db_prop)
			try:
				rc = loader.run_pytest(self.file, debug=options.debug)
			except AssertionError:
				rc = 1

		else:
			from robot.api import TestSuite, TestSuiteBuilder
			suite = TestSuite(str(self))
			suite.imports.resource("common_resource.txt")
			suite.imports.library("generic_testloader")
			t = suite.tests.create(name=self.name)
			t.keywords.create("Set Environment Variable", args=["SCREENSHOT_DIR",os.getenv('ROBOT_REPORTDIR')+'/'+'SEL-SCREENSHOTS'])
			t.keywords.create("Set Environment Variable", args=["DB_PROPERTIES",db_prop])
			t.keywords.create("Run Pytest", args=[self.file])
			rc = suite.run(loglevel=os.getenv('ROBOT_SYSLOG_LEVEL'), outputdir=os.path.join(os.getenv('ROBOT_REPORTDIR'),self.name))
			#debugfile=os.getenv('ROBOT_DEBUGFILE')
			rc = rc.return_code
		return rc

class SoapUIRunner(AbstractRunner):
	def __init__(self, name, file):
		AbstractRunner.__init__(self, name, file)

	@run
	def run(self):
		if options.verbose: print " @@@ in SoapUIRunner (%s) @@@ " % self.file

		rc = 0
		if not options.batch:
			os.putenv('DB_PROPERTIES',db_prop)
			rc = loader.run_makesuds(self.file)

		else:
			from robot.api import TestSuite, TestSuiteBuilder
			suite = TestSuite(str(self))
			suite.imports.resource("common_resource.txt")
			suite.imports.library("generic_testloader")
			t = suite.tests.create(name=self.name)
			t.keywords.create("Set Environment Variable", args=["NO_SOAPUI_REPORT","1"])
			t.keywords.create("Set Environment Variable", args=["SOAPUI_LOGSDIR",os.getenv('ROBOT_REPORTDIR')+'/'+self.name+'/'+'SOAPUI_LOGS'])
			t.keywords.create("Set Environment Variable", args=["DB_PROPERTIES",db_prop])
			t.keywords.create("Run Makesuds", args=[self.file])
			t.keywords.create("Soapui Project Passed", args=[os.getenv('ROBOT_REPORTDIR')+'/'+self.name+'/'+'SOAPUI_LOGS/soapui-errors.log']) # dirty hack since create doesn't expand vars
			rc = suite.run(loglevel=os.getenv('ROBOT_SYSLOG_LEVEL'), outputdir=os.path.join(os.getenv('ROBOT_REPORTDIR'),self.name))
			#debugfile=os.getenv('ROBOT_DEBUGFILE')
			rc = rc.return_code
		return rc

class ContainerRunner(AbstractRunner):
	def __init__(self, name, file):
		AbstractRunner.__init__(self, name, file)
		lines = open(file).read().split()
		if not all(map(lambda l: os.path.splitext(l)[0]==name, lines)):
			sys.stderr.write(" XXX Serious Error: TestCase (%s) contains sub-testcase(s) that do not belong to it. XXX \n " % name)
			sys.exit(1)
		self.runners = map(lambda l: create_runner(l), lines)

	@run
	def run(self):
		if options.verbose: print " @@@ in ContainerRunner (%s) @@@ " % self.file

		rc = 0
		if not options.batch:
			for r in self.runners:
				if r.run()==1:
					rc=1
					break

		else:
			from robot.running import TestSuite, TestSuiteBuilder
			suite = TestSuite(str(self))
			suite.imports.resource("common_resource.txt")
			suite.imports.library("generic_testloader")
			t = suite.tests.create(name=self.name)

			for r in self.runners:
				if isinstance(r,RobotRunner):
					t.keywords.create("Run Pybot", args=[r.file])
					t.keywords.create("Set Environment Variable", args=["DB_PROPERTIES",db_prop])

				elif isinstance(r,PyTestRunner):
					t.keywords.create("Set Environment Variable", args=["SCREENSHOT_DIR",os.getenv('ROBOT_REPORTDIR')+'/'+'SEL-SCREENSHOTS'])
					t.keywords.create("Set Environment Variable", args=["DB_PROPERTIES",db_prop])
					t.keywords.create("Run Pytest", args=[r.file])

				elif isinstance(r,SoapUIRunner):
					t.keywords.create("Set Environment Variable", args=["NO_SOAPUI_REPORT","1"])
					t.keywords.create("Set Environment Variable", args=["SOAPUI_LOGSDIR",os.getenv('ROBOT_REPORTDIR')+'/'+r.name+'/'+'SOAPUI_LOGS'])
					t.keywords.create("Set Environment Variable", args=["DB_PROPERTIES",db_prop])
					t.keywords.create("Run Makesuds", args=[r.file])
					t.keywords.create("Soapui Project Passed", args=[os.getenv('ROBOT_REPORTDIR')+'/'+r.name+'/'+'SOAPUI_LOGS/soapui-errors.log']) # dirty hack since create doesn't expand vars

			rc = suite.run(loglevel=os.getenv('ROBOT_SYSLOG_LEVEL'), outputdir=os.path.join(os.getenv('ROBOT_REPORTDIR'),r.name)) #debugfile=os.getenv('ROBOT_DEBUGFILE') XXX not working ???
			rc = rc.return_code
		return rc

# run list containing different Runner instances
runlist = []

db_prop = ""
if options.env != None:
	### run using specified env ###
	ENV_INI = options.env_file if options.env_file else os.path.join(os.getenv('TOOLCHAIN'),"conf","env.ini")

	if not os.path.exists(ENV_INI):
		sys.stderr.write(" XXX Fatal Error: ENV_INI - %s not found. XXX\n " % ENV_INI)
		sys.exit(1)

	config = ConfigParser.ConfigParser()
	config.optionxform = str
	config.read(ENV_INI)

	# get tclist: this can be either specified via --tag parameter or via env.ini tag ini variable
	for sect in config.sections():
		def _find_(K,V):
			s=re.compile('\[(.*?)\]').search(V)
			if s:
				V=V.replace(s.group(), config.get(s.group(1), K))
				_find_(K,V)
			return V

		for (k,v) in config.items(sect):
			config.set(sect,k,_find_(k,v))

	env_properties = dict(config.items(options.env.upper()))

	for k,v in { i: env_properties[i] for i in ['user','password','db','dbPort'] }.items():
		db_prop = db_prop + " -P%s=%s " % (k,v)

	# get set of tags and set to options
	options.tag = options.tag if options.tag else env_properties['tag'].split() if 'tag' in env_properties else None

	if options.verbose:
		print " => env_properties: %s" % env_properties
		print " => db_prop: %s" % db_prop

if options.runlist != None:
	### run in list mode ###
	tclist = open(options.runlist).read().split()
	if options.verbose: print " *** tc running sequence: %s *** " % str(tclist)

elif options.tag != None:
	### run in tag mode ###
	TAG_INI = "tag.ini"

	if not os.path.exists(TAG_INI):
		sys.stderr.write(" XXX Fatal Error: tag not found. XXX\n ")
		sys.exit(1)

	tclist = set()
	taglist = map(lambda s: s.upper(), options.tag)

	config = ConfigParser.ConfigParser()
	# generate tc list from tags
	config.read(TAG_INI)

	for tag in taglist:
		try:
			tclist = tclist.union(set(config.get(tag, 'tc').split()))
		except ConfigParser.NoSectionError as e:
			sys.stderr.write(" *** Error! %s *** \n" % str(e))

	if not tclist:
		sys.stderr.write("!!! WARN: No test cases were found !!! \n")
		sys.exit(0)

	tclist = sorted(list(tclist))
	if options.verbose: print " *** tc running sequence: %s *** " % str(tclist)

else:
	### run in user-specified file or glob mode ###
	tclist = []

	for file in args:
		if not os.path.exists(file):
			sys.stderr.write("XXX Error! Can't find the file: [%s] XXX\n" % file)

		elif os.path.isdir(file) and os.getcwd()==os.path.abspath(file):
			tclist.extend(list(set(map(lambda x: os.path.splitext(x)[0], glob.glob("TC*")))))

		else:
			tclist.append(file)

# from tclist generate runlist - runlist contains runner object instances
if len(tclist)==0:
	sys.stderr.write(" XXX Fatal Error: runner was not able to generate TC list. XXX\n ")
	sys.exit(0)

# validate file names to make sure they conform to naming convention TC[0-9]{5}.py
m = map(re.compile("^TC[0-9]{5}$").search, map(lambda x: os.path.splitext(x)[0], tclist))
if not all(m):
	sys.stderr.write(" XXX Fatal Error: TC %s does not meet naming convention. XXX\n " % [ tclist[j] for j in [ i for i in range(len(m)) if not m[i] ] ])
	sys.exit(1)

with Timer() as t:
	runlist = generate_runlist(tclist)
if options.verbose:  print " $$$ generate_runlist took: %s $$$ " % (str(datetime.timedelta(seconds=t.secs)))
if len(runlist) != len(tclist):
	sys.stderr.write("!!! WARN: Detected some TC(s) is/are missing from filesystem. !!!\n")
	_ = [ j for j in tclist if j not in [ i.name for i in runlist ] ]
	sys.stderr.write("The following TC's are missing: %s \n" % _)
	sys.stderr.write("!!! Expected: [%d], Present: [%d], Missing: [%d] !!!\n" % (len(tclist),len(runlist),len(_)))
runlist = seed_sequence_list(runlist)

# check runlist list
if len(runlist)==0:
	sys.stderr.write(" XXX Fatal Error: runner was not able to generate list of TC runner(s). XXX\n ")
	sys.exit(0)

# now start running
if options.dryrun:
	# dry-run mode
	_ = [ i.name for i in runlist]
	print "*** The following testscripts will be run => # [%d]:%s ***" % (len(_),_)
	sys.exit(0)
else:
	# remove all report dirs first before running
	import shutil
	if options.batch:
		for r,d,f in os.walk(os.getcwd()):
			d = map(lambda x: (lambda y: os.path.join(y,x))(r), filter(re.compile(os.getenv('ROBOT_REPORTDIR'), re.I).search, d))
  			if d:
  				if options.verbose:	print " ... removing %s ... " % d
  				shutil.rmtree(d[0], True)
  	else:
  		if options.verbose:	print " ... removing screenshots dir ... "
  		shutil.rmtree(os.path.join(os.getcwd(),"screenshots"),True)
  		if options.verbose:	print " ... removing soapui_logs dir ... "
  		shutil.rmtree(os.path.join(os.getcwd(),"soapui_logs"),True)

	import ext_robot, ext_dbi
	op = ext_robot.ext_robot()
	dbi = ext_dbi.ext_dbi()

	if sys.platform.startswith("linux"):
		import signal
		def _handler_(s,f):
			op.stop_display()
			print " !!! Execution was prematurely interrupted. Quitting !!! "
			sys.exit(1)
		signal.signal(signal.SIGTERM, _handler_)

	with Timer() as t:
		op.start_display()
		dbi.start_jdbc()

		rc = map(lambda r: r.run(), runlist)

		op.stop_display()

	if options.verbose: print " $$$ setup + run + teardown took: %s $$$ " % (str(datetime.timedelta(seconds=t.secs)))

if options.batch:
	'''
	rbxml = []
	import fnmatch
	for r,d,f in os.walk(os.getenv('ROBOT_REPORTDIR')):
		for xml in f:
			if fnmatch.fnmatch(xml,'output.xml'):
				rbxml.append(os.path.join(r,xml))
	'''

	rbxml = map(lambda r: os.path.join(os.getenv('ROBOT_REPORTDIR'),r,'output.xml'), [ i.name for i in runlist ])
	if options.verbose:
		print " => output.xml: ", rbxml
		sizes = map(lambda x: os.stat(x).st_size , rbxml)
		print " => sizes: ", sizes
		print " => total: %s" % size(reduce(lambda x,y: x+y, sizes))

	# generate robotfw report and log html
	from robot.api import ResultWriter
	with Timer() as t:
		ResultWriter(*rbxml).write_results( loglevel=os.getenv('ROBOT_SYSLOG_LEVEL')+":INFO", \
                                        name='%s Test Suite' % ("" if not getattr(options,'tag',None) else options.tag), \
                                        outputdir=os.getenv('ROBOT_REPORTDIR'), \
                                        logtitle="Test Log", \
                                        reporttitle="Test Report", \
                                        output='combined.xml', \
                                        splitlog=True )
	if options.verbose: print " $$$ ResultWriter.write_results took: %s $$$ " % (str(datetime.timedelta(seconds=t.secs)))

	# Start of dirty hack
	buildxml = '''\
    <project name="report" default="report" basedir=".">
        <target name="report">
            <mkdir dir="@@"/>
	        <junitreport todir="@@">
                <fileset dir="." includes="**/TEST*.xml"/>
                <report format="frames" todir="@@">
                    <param name="TITLE" expression="SoapUI Test Results."/>
                </report>
            </junitreport>
        </target>
    </project>\
    '''
	buildxml = string.replace(buildxml, "@@", "soapui")

	with open(os.path.join(os.getenv('ROBOT_REPORTDIR'), "build.xml"),"w") as f:
		f.write(buildxml)

	print " Generating soapui reports. This could take a while ... "
	with Timer() as t:
		os.popen('ant -q -f %s' % os.path.join(os.getenv('ROBOT_REPORTDIR'),'build.xml')).close()
	print " ... done! \n"
	if options.verbose: print " $$$ ant took: %s $$$ " % (str(datetime.timedelta(seconds=t.secs)))
	# End of dirty hack

if options.verbose:
	print " => rc: ", rc
	print " => runlist: ", [ i.name for i in runlist ]

if any(rc):
	failed = [ runlist[i].name for i in [ i for i in range(len(rc)) if rc[i] ] ]
	print "=> FAILED ! :( [%03.2f%% fail]|[%d]|%s" % (float(sum(rc))*100/len(runlist),sum(rc),str(failed))
	print '''
      ______
     (( ____ \-
     (( _____
     ((_____
     ((____   ----
          /  /
         (_((

	'''

	sys.exit(1)
else:
	print "=> PASSED ! :)"
	print '''
          _
         /(|
        (  :
       __\  \  _____
     (____)  -|
    (____)|   |
     (____).__|
      (___)__.|_____

	'''

	sys.exit(0)


text:
function __processArg(obj, key) {
    var arg = null;
    if (obj) {
        arg = obj[key] || null;
        delete obj[key];
    }
    return arg;
}

function Controller() {
    function nextQuestion() {
        if (Alloy.Globals.question < 10) {
            var questionView = Alloy.createController("card").getView();
            questionView.open({
                transition: Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT
            });
        } else {
            var winners = Alloy.createController("winnersboard").getView();
            winners.open({
                transition: Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT
            });
        }
    }
    require("alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments));
    this.__controllerPath = "points";
    if (arguments[0]) {
        {
            __processArg(arguments[0], "__parentSymbol");
        }
        {
            __processArg(arguments[0], "$model");
        }
        {
            __processArg(arguments[0], "__itemTemplate");
        }
    }
    var $ = this;
    var exports = {};
    var __defers = {};
    $.__views.pointsWindow = Ti.UI.createWindow({
        id: "pointsWindow",
        backgroundImage: "/images/background/points.jpg",
        backgroundColor: "#FBC9BA",
        barColor: "black",
        statusBarStyle: Titanium.UI.iPhone.StatusBar.OPAQUE_BLACK
    });
    $.__views.pointsWindow && $.addTopLevelView($.__views.pointsWindow);
    $.__views.nextQuestionButton = Ti.UI.createButton({
        id: "nextQuestionButton",
        title: "Next Question",
        style: "fontSize:'12'",
        bottom: "0",
        backgroundColor: "black",
        left: "5"
    });
    $.__views.pointsWindow.add($.__views.nextQuestionButton);
    nextQuestion ? $.__views.nextQuestionButton.addEventListener("click", nextQuestion) : __defers["$.__views.nextQuestionButton!click!nextQuestion"] = true;
    exports.destroy = function() {};
    _.extend($, $.__views);
    arguments[0] || {};
    __defers["$.__views.nextQuestionButton!click!nextQuestion"] && $.__views.nextQuestionButton.addEventListener("click", nextQuestion);
    _.extend($, exports);
}

var Alloy = require("alloy"), Backbone = Alloy.Backbone, _ = Alloy._;

module.exports = Controller;


text:
using System.Collections.Generic;

namespace DecisionTree.Controls
{
    public interface ISerializable
    {
        List<string> PropertiesToSerialize { get; }
    }
}


text:
class ResourceSerializer < ActiveModel::Serializer
  attributes :id, :kind, :name, :item, :user_id
  ##has_many :boards, serializer: BoardResourcesSerializer
  ##has_one :user##, serializer: UserResourceSerializer
  ##has_many :notes, serializer: ResourceNoteSerializer
end


text:
/***********************************************************************//**
 * @file		lpc17xx_clkpwr.h
 * @brief		Contains all macro definitions and function prototypes
 * 				support for Clock and Power Control firmware library on LPC17xx
 * @version		2.0
 * @date		21. May. 2010
 * @author		NXP MCU SW Application Team
 **************************************************************************
 * Software that is described herein is for illustrative purposes only
 * which provides customers with programming information regarding the
 * products. This software is supplied "AS IS" without any warranties.
 * NXP Semiconductors assumes no responsibility or liability for the
 * use of the software, conveys no license or title under any patent,
 * copyright, or mask work right to the product. NXP Semiconductors
 * reserves the right to make changes in the software without
 * notification. NXP Semiconductors also make no representation or
 * warranty that such application will be suitable for the specified
 * use without further testing or modification.
 **************************************************************************/

/* Peripheral group ----------------------------------------------------------- */
/** @defgroup CLKPWR CLKPWR
 * @ingroup LPC1700CMSIS_FwLib_Drivers
 * @{
 */

#ifndef LPC17XX_CLKPWR_H_
#define LPC17XX_CLKPWR_H_

/* Includes ------------------------------------------------------------------- */
#include "LPC17xx.h"
#include "lpc_types.h"

#ifdef __cplusplus
extern "C"
{
#endif

/* Public Macros -------------------------------------------------------------- */
/** @defgroup CLKPWR_Public_Macros CLKPWR Public Macros
 * @{
 */

/**********************************************************************
 * Peripheral Clock Selection Definitions
 **********************************************************************/
/** Peripheral clock divider bit position for WDT */
#define	CLKPWR_PCLKSEL_WDT  		((uint32_t)(0))
/** Peripheral clock divider bit position for TIMER0 */
#define	CLKPWR_PCLKSEL_TIMER0  		((uint32_t)(2))
/** Peripheral clock divider bit position for TIMER1 */
#define	CLKPWR_PCLKSEL_TIMER1  		((uint32_t)(4))
/** Peripheral clock divider bit position for UART0 */
#define	CLKPWR_PCLKSEL_UART0  		((uint32_t)(6))
/** Peripheral clock divider bit position for UART1 */
#define	CLKPWR_PCLKSEL_UART1  		((uint32_t)(8))
/** Peripheral clock divider bit position for PWM1 */
#define	CLKPWR_PCLKSEL_PWM1  		((uint32_t)(12))
/** Peripheral clock divider bit position for I2C0 */
#define	CLKPWR_PCLKSEL_I2C0  		((uint32_t)(14))
/** Peripheral clock divider bit position for SPI */
#define	CLKPWR_PCLKSEL_SPI  		((uint32_t)(16))
/** Peripheral clock divider bit position for SSP1 */
#define	CLKPWR_PCLKSEL_SSP1  		((uint32_t)(20))
/** Peripheral clock divider bit position for DAC */
#define	CLKPWR_PCLKSEL_DAC  		((uint32_t)(22))
/** Peripheral clock divider bit position for ADC */
#define	CLKPWR_PCLKSEL_ADC  		((uint32_t)(24))
/** Peripheral clock divider bit position for CAN1 */
#define	CLKPWR_PCLKSEL_CAN1 		((uint32_t)(26))
/** Peripheral clock divider bit position for CAN2 */
#define	CLKPWR_PCLKSEL_CAN2 		((uint32_t)(28))
/** Peripheral clock divider bit position for ACF */
#define	CLKPWR_PCLKSEL_ACF  		((uint32_t)(30))
/** Peripheral clock divider bit position for QEI */
#define	CLKPWR_PCLKSEL_QEI  		((uint32_t)(32))
/** Peripheral clock divider bit position for PCB */
#define	CLKPWR_PCLKSEL_PCB  		((uint32_t)(36))
/** Peripheral clock divider bit position for  I2C1 */
#define	CLKPWR_PCLKSEL_I2C1  		((uint32_t)(38))
/** Peripheral clock divider bit position for SSP0 */
#define	CLKPWR_PCLKSEL_SSP0  		((uint32_t)(42))
/** Peripheral clock divider bit position for TIMER2 */
#define	CLKPWR_PCLKSEL_TIMER2  		((uint32_t)(44))
/** Peripheral clock divider bit position for  TIMER3 */
#define	CLKPWR_PCLKSEL_TIMER3  		((uint32_t)(46))
/** Peripheral clock divider bit position for UART2 */
#define	CLKPWR_PCLKSEL_UART2  		((uint32_t)(48))
/** Peripheral clock divider bit position for UART3 */
#define	CLKPWR_PCLKSEL_UART3  		((uint32_t)(50))
/** Peripheral clock divider bit position for I2C2 */
#define	CLKPWR_PCLKSEL_I2C2  		((uint32_t)(52))
/** Peripheral clock divider bit position for I2S */
#define	CLKPWR_PCLKSEL_I2S  		((uint32_t)(54))
/** Peripheral clock divider bit position for RIT */
#define	CLKPWR_PCLKSEL_RIT  		((uint32_t)(58))
/** Peripheral clock divider bit position for SYSCON */
#define	CLKPWR_PCLKSEL_SYSCON  		((uint32_t)(60))
/** Peripheral clock divider bit position for MC */
#define	CLKPWR_PCLKSEL_MC  			((uint32_t)(62))

/** Macro for Peripheral Clock Selection register bit values
 * Note: When CCLK_DIV_8, Peripheral's clock is selected to
 * PCLK_xyz = CCLK/8 except for CAN1, CAN2, and CAN filtering
 * when '11'selects PCLK_xyz = CCLK/6 */
/* Peripheral clock divider is set to 4 from CCLK */
#define	CLKPWR_PCLKSEL_CCLK_DIV_4  ((uint32_t)(0))
/** Peripheral clock divider is the same with CCLK */
#define	CLKPWR_PCLKSEL_CCLK_DIV_1  ((uint32_t)(1))
/** Peripheral clock divider is set to 2 from CCLK */
#define	CLKPWR_PCLKSEL_CCLK_DIV_2  ((uint32_t)(2))

/********************************************************************
* Power Control for Peripherals Definitions
**********************************************************************/
/** Timer/Counter 0 power/clock control bit */
#define	 CLKPWR_PCONP_PCTIM0	((uint32_t)(1<<1))
/* Timer/Counter 1 power/clock control bit */
#define	 CLKPWR_PCONP_PCTIM1	((uint32_t)(1<<2))
/** UART0 power/clock control bit */
#define	 CLKPWR_PCONP_PCUART0  	((uint32_t)(1<<3))
/** UART1 power/clock control bit */
#define	 CLKPWR_PCONP_PCUART1  	((uint32_t)(1<<4))
/** PWM1 power/clock control bit */
#define	 CLKPWR_PCONP_PCPWM1	((uint32_t)(1<<6))
/** The I2C0 interface power/clock control bit */
#define	 CLKPWR_PCONP_PCI2C0	((uint32_t)(1<<7))
/** The SPI interface power/clock control bit */
#define	 CLKPWR_PCONP_PCSPI  	((uint32_t)(1<<8))
/** The RTC power/clock control bit */
#define	 CLKPWR_PCONP_PCRTC  	((uint32_t)(1<<9))
/** The SSP1 interface power/clock control bit */
#define	 CLKPWR_PCONP_PCSSP1	((uint32_t)(1<<10))
/** A/D converter 0 (ADC0) power/clock control bit */
#define	 CLKPWR_PCONP_PCAD  	((uint32_t)(1<<12))
/** CAN Controller 1 power/clock control bit */
#define	 CLKPWR_PCONP_PCAN1  	((uint32_t)(1<<13))
/** CAN Controller 2 power/clock control bit */
#define	 CLKPWR_PCONP_PCAN2 	((uint32_t)(1<<14))
/** GPIO power/clock control bit */
#define	CLKPWR_PCONP_PCGPIO 	((uint32_t)(1<<15))
/** Repetitive Interrupt Timer power/clock control bit */
#define	CLKPWR_PCONP_PCRIT 		((uint32_t)(1<<16))
/** Motor Control PWM */
#define CLKPWR_PCONP_PCMC 		((uint32_t)(1<<17))
/** Quadrature Encoder Interface power/clock control bit */
#define CLKPWR_PCONP_PCQEI 		((uint32_t)(1<<18))
/** The I2C1 interface power/clock control bit */
#define	 CLKPWR_PCONP_PCI2C1  	((uint32_t)(1<<19))
/** The SSP0 interface power/clock control bit */
#define	 CLKPWR_PCONP_PCSSP0	((uint32_t)(1<<21))
/** Timer 2 power/clock control bit */
#define	 CLKPWR_PCONP_PCTIM2	((uint32_t)(1<<22))
/** Timer 3 power/clock control bit */
#define	 CLKPWR_PCONP_PCTIM3	((uint32_t)(1<<23))
/** UART 2 power/clock control bit */
#define	 CLKPWR_PCONP_PCUART2  	((uint32_t)(1<<24))
/** UART 3 power/clock control bit */
#define	 CLKPWR_PCONP_PCUART3  	((uint32_t)(1<<25))
/** I2C interface 2 power/clock control bit */
#define	 CLKPWR_PCONP_PCI2C2	((uint32_t)(1<<26))
/** I2S interface power/clock control bit*/
#define	 CLKPWR_PCONP_PCI2S  	((uint32_t)(1<<27))
/** GP DMA function power/clock control bit*/
#define	 CLKPWR_PCONP_PCGPDMA  	((uint32_t)(1<<29))
/** Ethernet block power/clock control bit*/
#define	 CLKPWR_PCONP_PCENET	((uint32_t)(1<<30))
/** USB interface power/clock control bit*/
#define	 CLKPWR_PCONP_PCUSB  	((uint32_t)(1<<31))

/**
 * @}
 */
/* Private Macros ------------------------------------------------------------- */
/** @defgroup CLKPWR_Private_Macros CLKPWR Private Macros
 * @{
 */

/* --------------------- BIT DEFINITIONS -------------------------------------- */
/*********************************************************************//**
 * Macro defines for Clock Source Select Register
 **********************************************************************/
/** Internal RC oscillator */
#define CLKPWR_CLKSRCSEL_CLKSRC_IRC			((uint32_t)(0x00))
/** Main oscillator */
#define CLKPWR_CLKSRCSEL_CLKSRC_MAINOSC		((uint32_t)(0x01))
/** RTC oscillator */
#define CLKPWR_CLKSRCSEL_CLKSRC_RTC			((uint32_t)(0x02))
/** Clock source selection bit mask */
#define CLKPWR_CLKSRCSEL_BITMASK			((uint32_t)(0x03))

/*********************************************************************//**
 * Macro defines for Clock Output Configuration Register
 **********************************************************************/
/* Clock Output Configuration register definition */
/** Selects the CPU clock as the CLKOUT source */
#define CLKPWR_CLKOUTCFG_CLKOUTSEL_CPU		((uint32_t)(0x00))
/** Selects the main oscillator as the CLKOUT source */
#define CLKPWR_CLKOUTCFG_CLKOUTSEL_MAINOSC	((uint32_t)(0x01))
/** Selects the Internal RC oscillator as the CLKOUT source */
#define CLKPWR_CLKOUTCFG_CLKOUTSEL_RC		((uint32_t)(0x02))
/** Selects the USB clock as the CLKOUT source */
#define CLKPWR_CLKOUTCFG_CLKOUTSEL_USB		((uint32_t)(0x03))
/** Selects the RTC oscillator as the CLKOUT source */
#define CLKPWR_CLKOUTCFG_CLKOUTSEL_RTC		((uint32_t)(0x04))
/** Integer value to divide the output clock by, minus one */
#define CLKPWR_CLKOUTCFG_CLKOUTDIV(n)		((uint32_t)((n&0x0F)<<4))
/** CLKOUT enable control */
#define CLKPWR_CLKOUTCFG_CLKOUT_EN			((uint32_t)(1<<8))
/** CLKOUT activity indication */
#define CLKPWR_CLKOUTCFG_CLKOUT_ACT			((uint32_t)(1<<9))
/** Clock source selection bit mask */
#define CLKPWR_CLKOUTCFG_BITMASK			((uint32_t)(0x3FF))

/*********************************************************************//**
 * Macro defines for PPL0 Control Register
 **********************************************************************/
/** PLL 0 control enable */
#define CLKPWR_PLL0CON_ENABLE		((uint32_t)(0x01))
/** PLL 0 control connect */
#define CLKPWR_PLL0CON_CONNECT		((uint32_t)(0x02))
/** PLL 0 control bit mask */
#define CLKPWR_PLL0CON_BITMASK		((uint32_t)(0x03))

/*********************************************************************//**
 * Macro defines for PPL0 Configuration Register
 **********************************************************************/
/** PLL 0 Configuration MSEL field */
#define CLKPWR_PLL0CFG_MSEL(n)		((uint32_t)(n&0x7FFF))
/** PLL 0 Configuration NSEL field */
#define CLKPWR_PLL0CFG_NSEL(n)		((uint32_t)((n<<16)&0xFF0000))
/** PLL 0 Configuration bit mask */
#define CLKPWR_PLL0CFG_BITMASK		((uint32_t)(0xFF7FFF))

/*********************************************************************//**
 * Macro defines for PPL0 Status Register
 **********************************************************************/
/** PLL 0 MSEL value */
#define CLKPWR_PLL0STAT_MSEL(n)		((uint32_t)(n&0x7FFF))
/** PLL NSEL get value  */
#define CLKPWR_PLL0STAT_NSEL(n)		((uint32_t)((n>>16)&0xFF))
/** PLL status enable bit */
#define CLKPWR_PLL0STAT_PLLE		((uint32_t)(1<<24))
/** PLL status Connect bit */
#define CLKPWR_PLL0STAT_PLLC		((uint32_t)(1<<25))
/** PLL status lock */
#define CLKPWR_PLL0STAT_PLOCK		((uint32_t)(1<<26))

/*********************************************************************//**
 * Macro defines for PPL0 Feed Register
 **********************************************************************/
/** PLL0 Feed bit mask */
#define CLKPWR_PLL0FEED_BITMASK			((uint32_t)0xFF)

/*********************************************************************//**
 * Macro defines for PLL1 Control Register
 **********************************************************************/
/** USB PLL control enable */
#define CLKPWR_PLL1CON_ENABLE		((uint32_t)(0x01))
/** USB PLL control connect */
#define CLKPWR_PLL1CON_CONNECT		((uint32_t)(0x02))
/** USB PLL control bit mask */
#define CLKPWR_PLL1CON_BITMASK		((uint32_t)(0x03))

/*********************************************************************//**
 * Macro defines for PLL1 Configuration Register
 **********************************************************************/
/** USB PLL MSEL set value */
#define CLKPWR_PLL1CFG_MSEL(n)		((uint32_t)(n&0x1F))
/** USB PLL PSEL set value */
#define CLKPWR_PLL1CFG_PSEL(n)		((uint32_t)((n&0x03)<<5))
/** USB PLL configuration bit mask */
#define CLKPWR_PLL1CFG_BITMASK		((uint32_t)(0x7F))

/*********************************************************************//**
 * Macro defines for PLL1 Status Register
 **********************************************************************/
/** USB PLL MSEL get value  */
#define CLKPWR_PLL1STAT_MSEL(n)		((uint32_t)(n&0x1F))
/** USB PLL PSEL get value  */
#define CLKPWR_PLL1STAT_PSEL(n)		((uint32_t)((n>>5)&0x03))
/** USB PLL status enable bit */
#define CLKPWR_PLL1STAT_PLLE		((uint32_t)(1<<8))
/** USB PLL status Connect bit */
#define CLKPWR_PLL1STAT_PLLC		((uint32_t)(1<<9))
/** USB PLL status lock */
#define CLKPWR_PLL1STAT_PLOCK		((uint32_t)(1<<10))

/*********************************************************************//**
 * Macro defines for PLL1 Feed Register
 **********************************************************************/
/** PLL1 Feed bit mask */
#define CLKPWR_PLL1FEED_BITMASK		((uint32_t)0xFF)

/*********************************************************************//**
 * Macro defines for CPU Clock Configuration Register
 **********************************************************************/
/** CPU Clock configuration bit mask */
#define CLKPWR_CCLKCFG_BITMASK		((uint32_t)(0xFF))

/*********************************************************************//**
 * Macro defines for USB Clock Configuration Register
 **********************************************************************/
/** USB Clock Configuration bit mask */
#define CLKPWR_USBCLKCFG_BITMASK	((uint32_t)(0x0F))

/*********************************************************************//**
 * Macro defines for IRC Trim Register
 **********************************************************************/
/** IRC Trim bit mask */
#define CLKPWR_IRCTRIM_BITMASK		((uint32_t)(0x0F))

/*********************************************************************//**
 * Macro defines for Peripheral Clock Selection Register 0 and 1
 **********************************************************************/
/** Peripheral Clock Selection 0 mask bit */
#define CLKPWR_PCLKSEL0_BITMASK		((uint32_t)(0xFFF3F3FF))
/** Peripheral Clock Selection 1 mask bit */
#define CLKPWR_PCLKSEL1_BITMASK		((uint32_t)(0xFCF3F0F3))
/** Macro to set peripheral clock of each type
 * p: position of two bits that hold divider of peripheral clock
 * n: value of divider of peripheral clock  to be set */
#define CLKPWR_PCLKSEL_SET(p,n)		_SBF(p,n)
/** Macro to mask peripheral clock of each type */
#define CLKPWR_PCLKSEL_BITMASK(p)	_SBF(p,0x03)
/** Macro to get peripheral clock of each type */
#define CLKPWR_PCLKSEL_GET(p, n)	((uint32_t)((n>>p)&0x03))

/*********************************************************************//**
 * Macro defines for Power Mode Control Register
 **********************************************************************/
/** Power mode control bit 0 */
#define CLKPWR_PCON_PM0			((uint32_t)(1<<0))
/** Power mode control bit 1 */
#define CLKPWR_PCON_PM1			((uint32_t)(1<<1))
/** Brown-Out Reduced Power Mode */
#define CLKPWR_PCON_BODPDM		((uint32_t)(1<<2))
/** Brown-Out Global Disable */
#define CLKPWR_PCON_BOGD		((uint32_t)(1<<3))
/** Brown Out Reset Disable */
#define CLKPWR_PCON_BORD		((uint32_t)(1<<4))
/** Sleep Mode entry flag */
#define CLKPWR_PCON_SMFLAG		((uint32_t)(1<<8))
/** Deep Sleep entry flag */
#define CLKPWR_PCON_DSFLAG		((uint32_t)(1<<9))
/** Power-down entry flag */
#define CLKPWR_PCON_PDFLAG		((uint32_t)(1<<10))
/** Deep Power-down entry flag */
#define CLKPWR_PCON_DPDFLAG		((uint32_t)(1<<11))

/*********************************************************************//**
 * Macro defines for Power Control for Peripheral Register
 **********************************************************************/
/** Power Control for Peripherals bit mask */
#define CLKPWR_PCONP_BITMASK	0xEFEFF7DE

/**
 * @}
 */

/* Public Functions ----------------------------------------------------------- */
/** @defgroup CLKPWR_Public_Functions CLKPWR Public Functions
 * @{
 */

void CLKPWR_SetPCLKDiv (uint32_t ClkType, uint32_t DivVal);
uint32_t CLKPWR_GetPCLKSEL (uint32_t ClkType);
uint32_t CLKPWR_GetPCLK (uint32_t ClkType);
void CLKPWR_ConfigPPWR (uint32_t PPType, FunctionalState NewState);
void CLKPWR_Sleep(void);
void CLKPWR_DeepSleep(void);
void CLKPWR_PowerDown(void);
void CLKPWR_DeepPowerDown(void);

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif /* LPC17XX_CLKPWR_H_ */

/**
 * @}
 */

/* --------------------------------- End Of File ------------------------------ */


text:
<?php

namespace Test\Integration\Version4x0;

include_once(__DIR__. '/../Version3x2/ListsCommandsTest.php');

class ListsCommandsTest extends \Test\Integration\Version3x2\ListsCommandsTest {

}


text:
#include <utki/config.hpp>

#if M_OS == M_OS_LINUX || M_OS == M_OS_MACOSX || M_OS == M_OS_UNIX
#	include <netinet/in.h>
#	include <netinet/tcp.h>
#	include <fcntl.h>
#	include <unistd.h>
#elif M_OS == M_OS_WINDOWS
#	include <ws2tcpip.h>
#endif

using namespace setka;

socket::~socket()noexcept{
	this->close();
}

void socket::close()noexcept{
//		TRACE(<< "socket::Close(): invoked " << this << std::endl)
	ASSERT_INFO(!this->is_added(), "socket::close(): trying to close socket which is added to the WaitSet. Remove the socket from WaitSet before closing.")

	if(*this){
		ASSERT(!this->is_added())

#if M_OS == M_OS_WINDOWS
		// Closing socket in Win32.
		// refer to http://tangentsoft.net/wskfaq/newbie.html#howclose for details
		shutdown(this->sock, SD_BOTH);
		closesocket(this->sock);

		this->close_event_for_waitable();
#elif M_OS == M_OS_LINUX || M_OS == M_OS_MACOSX || M_OS == M_OS_UNIX
		::close(this->sock);
#else
#	error "Unsupported OS"
#endif
	}
	this->readiness_flags.clear();
	this->sock = invalid_socket;
}

setka::socket& socket::operator=(socket&& s){
//	TRACE(<< "socket::operator=(): invoked " << this << std::endl)
	if(this == &s){//detect self-assignment
		return *this;
	}

	// first, assign as Waitable, it may throw an exception
	// if the waitable is added to some waitset
	this->waitable::operator=(std::move(s));

	this->close();
	this->sock = s.sock;

#if M_OS == M_OS_WINDOWS
	this->event_for_waitable = s.event_for_waitable;
	const_cast<socket&>(s).event_for_waitable= WSA_INVALID_EVENT;
#endif

	const_cast<socket&>(s).sock = invalid_socket;
	return *this;
}

void socket::disable_naggle(){
	if(!*this){
		throw std::logic_error("socket::disable_naggle(): socket is not valid");
	}

#if M_OS == M_OS_WINDOWS || M_OS == M_OS_LINUX || M_OS == M_OS_MACOSX || M_OS == M_OS_UNIX
	{
		int yes = 1;
		setsockopt(this->sock, IPPROTO_TCP, TCP_NODELAY, (char*)&yes, sizeof(yes));
	}
#else
#	error "Unsupported OS"
#endif
}

void socket::set_nonblocking_mode(){
	if(!*this){
		throw std::logic_error("socket::set_nonblocking_mode(): socket is not valid");
	}

#if M_OS == M_OS_WINDOWS
	{
		u_long mode = 1;
		if(ioctlsocket(this->sock, FIONBIO, &mode) != 0){
			throw std::system_error(WSAGetLastError(), std::generic_category(), "could not set socket non-blocking mode, ioctlsocket(FIONBIO) failed");
		}
	}

#elif M_OS == M_OS_LINUX || M_OS == M_OS_MACOSX || M_OS == M_OS_UNIX
	{
		int flags = fcntl(this->sock, F_GETFL, 0);
		if(flags == -1){
			throw std::system_error(errno, std::generic_category(), "could not set socket non-blocking mode, fcntl(F_GETFL) failed");
		}
		if(fcntl(this->sock, F_SETFL, flags | O_NONBLOCK) != 0){
			throw std::system_error(errno, std::generic_category(), "could not set socket non-blocking mode, fcntl(F_SETFL) failed");
		}
	}
#else
#	error "Unsupported OS"
#endif
}

uint16_t socket::get_local_port(){
	if(!*this){
		throw std::logic_error("socket::GetLocalPort(): socket is not valid");
	}

	sockaddr_storage addr;

#if M_OS == M_OS_WINDOWS
	int len = sizeof(addr);
#elif M_OS == M_OS_LINUX || M_OS == M_OS_MACOSX || M_OS == M_OS_UNIX
	socklen_t len = sizeof(addr);
#else
#	error "Unsupported OS"
#endif

	if(getsockname(
			this->sock,
			reinterpret_cast<sockaddr*>(&addr),
			&len
		) < 0)
	{
		throw std::system_error(errno, std::generic_category(), "could not get local port, getsockname() failed");
	}

	if(addr.ss_family == AF_INET){
		sockaddr_in& a = reinterpret_cast<sockaddr_in&>(addr);
		return uint16_t(ntohs(a.sin_port));
	}else{
		ASSERT(addr.ss_family == AF_INET6)
		sockaddr_in6& a = reinterpret_cast<sockaddr_in6&>(addr);
		return uint16_t(ntohs(a.sin6_port));
	}
}

#if M_OS == M_OS_WINDOWS
HANDLE socket::get_handle(){
	return this->event_for_waitable;
}

bool socket::check_signaled(){
	WSANETWORKEVENTS events;
	memset(&events, 0, sizeof(events));
	ASSERT(*this)
	if(WSAEnumNetworkEvents(this->sock, this->event_for_waitable, &events) != 0){
		throw std::system_error(WSAGetLastError(), std::generic_category(), "could not check for network events, WSAEnumNetworkEvents() failed");
	}

	// NOTE: sometimes no events are reported, don't know why.
//	ASSERT(events.lNetworkEvents != 0)

	if((events.lNetworkEvents & FD_CLOSE) != 0){
		this->readiness_flags.set(opros::ready::error);
	}

	if((events.lNetworkEvents & FD_READ) != 0){
		this->readiness_flags.set(opros::ready::read);
		ASSERT(FD_READ_BIT < FD_MAX_EVENTS)
		if(events.iErrorCode[FD_READ_BIT] != 0){
			this->readiness_flags.set(opros::ready::error);
		}
	}

	if((events.lNetworkEvents & FD_ACCEPT) != 0){
		this->readiness_flags.set(opros::ready::read);
		ASSERT(FD_ACCEPT_BIT < FD_MAX_EVENTS)
		if(events.iErrorCode[FD_ACCEPT_BIT] != 0){
			this->readiness_flags.set(opros::ready::error);
		}
	}

	if((events.lNetworkEvents & FD_WRITE) != 0){
		this->readiness_flags.set(opros::ready::write);
		ASSERT(FD_WRITE_BIT < FD_MAX_EVENTS)
		if(events.iErrorCode[FD_WRITE_BIT] != 0){
			this->readiness_flags.set(opros::ready::error);
		}
	}

	if((events.lNetworkEvents & FD_CONNECT) != 0){
		this->readiness_flags.set(opros::ready::write);
		ASSERT(FD_CONNECT_BIT < FD_MAX_EVENTS)
		if(events.iErrorCode[FD_CONNECT_BIT] != 0){
			this->readiness_flags.set(opros::ready::error);
		}
	}

#ifdef DEBUG
	// if some event occurred then some of readiness flags should be set
	if(events.lNetworkEvents != 0){
		ASSERT_ALWAYS(!this->readiness_flags.is_clear())
	}
#endif

	return this->waitable::check_signaled();
}

void socket::create_event_for_waitable(){
	ASSERT(this->event_for_waitable== WSA_INVALID_EVENT)
	this->event_for_waitable= WSACreateEvent();
	if(this->event_for_waitable== WSA_INVALID_EVENT){
		throw std::system_error(WSAGetLastError(), std::generic_category(), "could not create event, WSACreateEvent() failed");
	}
}

void socket::close_event_for_waitable(){
	ASSERT(this->event_for_waitable != WSA_INVALID_EVENT)
	WSACloseEvent(this->event_for_waitable);
	this->event_for_waitable= WSA_INVALID_EVENT;
}

void socket::set_waiting_events_for_windows(long flags){
	ASSERT_INFO(*this && (this->event_for_waitable != WSA_INVALID_EVENT), "HINT: Most probably, you are trying to remove the _closed_ socket from WaitSet. If so, you should first remove the socket from WaitSet and only then call the Close() method.")

	if(WSAEventSelect(
			this->sock,
			this->event_for_waitable,
			flags
		) != 0)
	{
		throw std::system_error(WSAGetLastError(), std::generic_category(), "could not associate event with socket, WSAEventSelect() failed");
	}
}

#elif M_OS == M_OS_LINUX || M_OS == M_OS_MACOSX || M_OS == M_OS_UNIX

int socket::get_handle(){
	return this->sock;
}

#else
#	error "unsupported OS"
#endif


text:
var TransitionableChildView = require('./TransitionableChildView');
var TorsoView = require('../../../modules/View');
var _ = require('underscore');

module.exports = ParentView = TorsoView.extend({
  template: "
test

",
  initialize: function(args) {
    args = args || {};
    this.transitionTime = args.transitionTime || 500;
    args.numberOfChildren = args.numberOfChildren || 3;
    this.myChildViews = [];
    _.times(args.numberOfChildren, function(i) {
      this.myChildViews.push(new TransitionableChildView({index: i}));
    }, this);
    this.listenTo(this.viewState, 'change:current', this.render);
    this.set('current', 0);
  },
  attachTrackedViews: function() {
    this.transitionPromise = this.attachView('current', this.getCurrentView(), {
      useTransition: true,
      transitionTime: 500
    });
  },
  setCurrentView: function(view) {
    this.set('current', this.myChildViews.indexOf(view));
  },
  getCurrentView: function() {
    return this.myChildViews[this.get('current')];
  }
});


text:
<?php

Schema::dropIfExists('modules');

Schema::create('modules', function($table)
{
	$table->increments('id');

	$table->string('slug')->unique();
	$table->integer('enabled')->default(0);
	$table->integer('installed')->default(0);
	$table->integer('is_core')->default(0);
});


text:
'use strict';

let cap_gen;

async function run() {
  document.getElementById('run_button').disabled = true;
  try {
    await set_progress(0);
    if (!cap_gen) {
      await load_models();
    }
    await run_generation();
  } catch (ex) {
    alert('Failed: ' + ex);
    throw ex;
  } finally {
    document.getElementById('run_button').disabled = false;
  }
}

function set_progress(performing) {
  for (let i = 0; i < 3; i++) {
    let color = i > performing ? 'white' : (i < performing ? 'lightgreen' : 'pink');

    document.querySelector('.progress-item-' + i).style.backgroundColor = color;
  }
  return new Promise(function (resolve, reject) {
    setTimeout(resolve, 10);
  })
}

class ImageCaptionGenerator {
  constructor(runner_image, runner_caption, word_data) {
    this.runner_image = runner_image;
    this.runner_caption = runner_caption;
    this.word_data = word_data;

    let image_in_views = this.runner_image.getInputViews();
    let image_out_views = this.runner_image.getOutputViews();
    this.view_image_raw_in = image_in_views[0];
    this.view_image_feature_out = image_out_views[0];

    let cap_in_views = this.runner_caption.getInputViews();
    let cap_out_views = this.runner_caption.getOutputViews();
    this.view_cap_image_feature_in = cap_in_views[0];
    this.view_cap_word_in = cap_in_views[1];
    this.view_cap_image_switch = cap_in_views[2];
    this.view_cap_word_switch = cap_in_views[3];
    this.view_cap_h_in = cap_in_views[4];
    this.view_cap_c_in = cap_in_views[5];
    this.view_cap_word_prob = cap_out_views[0];
    this.view_cap_h_out = cap_out_views[1];
    this.view_cap_c_out = cap_out_views[2];

    this.switch_off = new Float32Array(word_data.hidden_num);
    this.zero_state = this.switch_off;//share same size 0 vector
    this.switch_on = new Float32Array(word_data.hidden_num);
    this.switch_on.fill(1);

    this.beam_stack = null;
    this.beam_width = 10;
    this.max_length = 20;
  }

  async generate_caption(image_data) {
    await set_progress(1);
    console.log('Extracting feature');
    let image_feature = await this.extract_image_feature(image_data);
    await set_progress(2);
    console.log('Initializing caption model');
    return await this.generate_caption_from_image_feature(image_feature);
  }

  async generate_caption_from_image_feature(image_feature) {
    await this.set_image_feature(image_feature);

    for (let i = 0; i < this.max_length; i++) {
      let next_stack = [];
      let any_updated = false;
      for (let j = 0; j < this.beam_stack.length; j++) {
        let current_status = this.beam_stack[j];
        if (current_status[2] == this.word_data.eos_id) {
          next_stack.push(current_status);
        } else {
          await this.predict_next_word(current_status, next_stack);
          any_updated = true;
        }
      }

      // sort by likelihood desc
      next_stack.sort((a, b) => b[3] - a[3]);
      next_stack.splice(this.beam_width);

      this.beam_stack = next_stack;

      if (!any_updated) {
        break;
      }
    }

    let sentence_strs = [];
    for (let i = 0; i < this.beam_stack.length; i++) {
      let current_status = this.beam_stack[i];
      let words = current_status[1].map(word_id => this.word_data.id_to_word[word_id]);
      words.splice(-1);//remove EOS
      let sentence_str = words.join(' ');
      sentence_strs.push(sentence_str);
    }

    await set_progress(3);
    return sentence_strs;
  }

  async extract_image_feature(image_data) {
    this.view_image_raw_in.set(image_data);
    await this.runner_image.run();
    return this.view_image_feature_out.toActual();
  }

  async set_image_feature(image_feature) {
    this.view_cap_image_feature_in.set(image_feature);
    this.view_cap_word_in.set(new Float32Array([0]));
    this.view_cap_image_switch.set(this.switch_on);
    this.view_cap_word_switch.set(this.switch_off);
    this.view_cap_h_in.set(this.zero_state);
    this.view_cap_c_in.set(this.zero_state);

    await this.runner_caption.run();

    // lstm_states, sentence, last_word, likelihood
    this.beam_stack = [[{ h: this.view_cap_h_out.toActual().slice(), c: this.view_cap_c_out.toActual().slice() },
    [], this.word_data.bos_id, 0.0]];

    this.view_cap_image_switch.set(this.switch_off);
    this.view_cap_word_switch.set(this.switch_on);
  }

  async predict_next_word(current_status, next_stack) {
    this.view_cap_word_in.set(new Float32Array([current_status[2]]));
    this.view_cap_h_in.set(current_status[0].h);
    this.view_cap_c_in.set(current_status[0].c);

    await this.runner_caption.run();

    let h_array = this.view_cap_h_out.toActual().slice();
    let c_array = this.view_cap_c_out.toActual().slice();

    let word_probs = this.view_cap_word_prob.toActual();
    let top_words = WebDNN.Math.argmax(word_probs, this.beam_width);

    for (let i = 0; i < top_words.length; i++) {
      let selected_word = top_words[i];
      let new_sentence = current_status[1].concat(selected_word);
      let new_likelihood = current_status[3] + Math.log(word_probs[selected_word]);
      next_stack.push([{ h: h_array, c: c_array }, new_sentence, selected_word, new_likelihood]);
    }

  }
}

async function run_generation() {
  console.log('start running');
  let image_data = await WebDNN.Image.getImageArray(document.getElementById('image'), {
    order: WebDNN.Image.Order.CHW,
    color: WebDNN.Image.Color.BGR,
    bias: [123.68, 116.779, 103.939]
  });
  let sentences = await cap_gen.generate_caption(image_data);
  document.getElementById('sentences').textContent = sentences.join('\n');
}

async function load_models() {
  let word_data = await (await fetch('./image-caption-model/word_data.json')).json();
  let runner_image = await WebDNN.load('./image-caption-model/image-feature', { backendOrder: ["webgpu", "webassembly"] });
  let runner_caption = await WebDNN.load('./image-caption-model/caption-generation', { backendOrder: ["webassembly"] });
  cap_gen = new ImageCaptionGenerator(runner_image, runner_caption, word_data);
}

// based on http://phiary.me/html5-canvas-drag-and-drop-image-draw/
window.onload = function () {
  // allow drag-and-drop image file on canvas
  var canvas = document.getElementById('image');
  var ctx = canvas.getContext('2d');
  var render = function (image) {
    ctx.drawImage(image, 0, 0, 224, 224);
  };

  var cancelEvent = function (e) {
    e.preventDefault();
    e.stopPropagation();
    return false;
  };

  document.addEventListener("dragover", cancelEvent, false);
  document.addEventListener("dragenter", cancelEvent, false);
  document.addEventListener("drop", function (e) {
    e.preventDefault();

    var file = e.dataTransfer.files[0];
    var image = new Image();
    image.onload = function () {
      render(this);
    };

    var reader = new FileReader();
    reader.onload = function (e) {
      image.src = e.target.result;
    };
    reader.readAsDataURL(file);
  }, false);

  // show initial sample image
  var sample_image = new Image();
  sample_image.onload = function () {
    ctx.drawImage(sample_image, 0, 0, 224, 224);
  };

  sample_image.src = './asakusa.jpg';

  let load_local_image_element = document.getElementById("load_local_image");
  load_local_image_element.addEventListener("change", function (e) {
    let file = this.files[0];
    if (file) {
      let image_blob = window.URL.createObjectURL(file);
      sample_image.src = image_blob;
    }
  })
};

// for debugging purpose
let sample_data;
async function run_sample_data() {
  console.log('start running');
  sample_data = await (await fetch('./image-caption-model/example_io.json')).json();
  console.log('loaded sample');
  let switch_off = new Float32Array(cap_gen.word_data.hidden_num);
  let switch_on = new Float32Array(cap_gen.word_data.hidden_num);
  switch_on.fill(1.0);

  let in_views = cap_gen.runner_caption.getInputViews();
  let out_views = cap_gen.runner_caption.getOutputViews();
  let img_feat = new Float32Array(sample_data.input_img_embedded);
  in_views[0].set(img_feat);//var_input_img
  in_views[1].set(new Float32Array(1)); //var_input_word
  in_views[2].set(switch_on);//var_switch_img
  in_views[3].set(switch_off);//var_switch_word
  in_views[4].set(new Float32Array(cap_gen.word_data.hidden_num));//var_last_h
  in_views[5].set(new Float32Array(cap_gen.word_data.hidden_num));//var_last_c

  await cap_gen.runner_caption.run();

  console.log('var_word_prob_biased', out_views[0].toActual());
  console.log('var_lstm_h', new Float32Array(out_views[1].toActual()));
  console.log('expected_var_lstm_h', new Float32Array(sample_data.image_lstm_output));
  console.log('var_lstm_c', new Float32Array(out_views[2].toActual()));

  in_views[1].set(new Float32Array(sample_data.bos_raw_vec));
  in_views[2].set(switch_off);
  in_views[3].set(switch_on);
  in_views[4].set(out_views[1].toActual());
  in_views[5].set(out_views[2].toActual());

  await cap_gen.runner_caption.run();

  console.log('var_word_prob_biased', out_views[0].toActual());
  console.log('expected_var_word_prob_biased', new Float32Array(sample_data.bos_word_prob));
  console.log('var_lstm_h', new Float32Array(out_views[1].toActual()));
  console.log('expected_var_lstm_h', new Float32Array(sample_data.bos_lstm_output));
  console.log('var_lstm_c', new Float32Array(out_views[2].toActual()));
}

async function run_generation_sample_data() {
  console.log('start running');
  sample_data = await (await fetch('./image-caption-model/example_io.json')).json();
  console.log('loaded sample');
  let sentences = await cap_gen.generate_caption_from_image_feature(new Float32Array(sample_data.input_img_embedded));
  document.getElementById('sentences').textContent = sentences.join('\n');
}


text:
package org.wildfly.swarm.microprofile.jwtauth.deployment.auth.jaas;

import java.security.Principal;
import java.security.acl.Group;
import java.util.Map;

import javax.security.auth.Subject;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.LoginException;

import io.smallrye.jwt.auth.principal.JWTCallerPrincipal;
import io.smallrye.jwt.auth.principal.JWTCallerPrincipalFactory;
import io.smallrye.jwt.auth.principal.ParseException;
import org.eclipse.microprofile.jwt.JsonWebToken;
import org.jboss.security.SimpleGroup;
import org.jboss.security.SimplePrincipal;
import org.jboss.security.auth.callback.SecurityAssociationCallback;
import org.jboss.security.auth.spi.RoleMappingLoginModule;

/**
 *
 */
public class JWTLoginModule extends RoleMappingLoginModule {
    private static final String LOG_EXCEPTIONS = "logExceptions";
    private static final String[] ALL_VALID_OPTIONS = {
            LOG_EXCEPTIONS
    };

    private JsonWebToken jwtPrincipal;
    private boolean logExceptions = false;

    @Override
    public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
        addValidOptions(ALL_VALID_OPTIONS);
        super.initialize(subject, callbackHandler, sharedState, options);
        if (options.containsKey("logExceptions")) {
            logExceptions = Boolean.valueOf(options.get("logExceptions").toString());
        }
    }

    @Override
    public boolean login() throws LoginException {
        SecurityAssociationCallback sac = new SecurityAssociationCallback();
        try {
            callbackHandler.handle(new Callback[]{sac});
            JWTCredential jwtCredential = (JWTCredential) sac.getCredential();
            // Validate the credential by
            jwtPrincipal = validate(jwtCredential);
        } catch (Exception e) {
            if (logExceptions) {
                log.infof(e, "Failed to validate token");
            }
            LoginException ex = new LoginException("Failed to validate token");
            ex.initCause(e);
            throw ex;
        }

        loginOk = true;
        return true;
    }

    @Override
    public boolean commit() throws LoginException {
        subject.getPrincipals().add(jwtPrincipal);
        SimpleGroup roles = new SimpleGroup("Roles");
        for (String name : jwtPrincipal.getGroups()) {
            roles.addMember(new SimplePrincipal(name));
        }
        subject.getPrincipals().add(roles);
        sharedState.put("JsonWebToken", jwtPrincipal);
        return super.commit();
    }

    /**
     * Validate the bearer token passed in with the authorization header
     *
     * @param jwtCredential - the input bearer token
     * @return return the validated JWTCallerPrincipal
     * @throws ParseException - thrown on token parse or validation failure
     */
    protected JWTCallerPrincipal validate(JWTCredential jwtCredential) throws ParseException {
        JWTCallerPrincipalFactory factory = JWTCallerPrincipalFactory.instance();
        JWTCallerPrincipal callerPrincipal = factory.parse(jwtCredential.getBearerToken(), jwtCredential.getAuthContextInfo());
        return callerPrincipal;
    }

    @Override
    protected Group[] getRoleSets() throws LoginException {
        if (options.containsKey("rolesProperties")) {
            return super.getRoleSets();
        } else {
            Principal group =  subject.getPrincipals().stream()
                .filter(p -> p instanceof Group && "Roles".equals(p.getName())).findFirst().get();
            return new Group[] {(Group)group};
        }
    }
}