text:
<?php
/*
 * Copy this script to the folder above and populate $versions array with your migrations
 * For more info see: http://www.dbupgrade.org/Main_Page#Migrations_($versions_array)
 *
 * Note: this script should be versioned in your code repository so it always reflects current code's
 *       requirements for the database structure.
*/
require_once(dirname(__FILE__).'/dbupgrade/lib.php');

$versions = array();
// Add new migrations on top, right below this line.

/* -------------------------------------------------------------------------------------------------------
 * VERSION 31
 * Switching metric tables to INNODB engine for better performance
*/
$versions[31]['up'][] = 'ALTER TABLE yslow2 ENGINE = INNODB';
$versions[31]['up'][] = 'ALTER TABLE pagetest ENGINE = INNODB';
$versions[31]['up'][] = 'ALTER TABLE metric ENGINE = INNODB';
$versions[31]['up'][] = 'ALTER TABLE har ENGINE = INNODB';
$versions[31]['up'][] = 'ALTER TABLE event ENGINE = INNODB';
$versions[31]['up'][] = 'ALTER TABLE dynatrace ENGINE = INNODB';
$versions[31]['up'][] = 'ALTER TABLE dommonster ENGINE = INNODB';
$versions[31]['up'][] = 'ALTER TABLE pagespeed ENGINE = INNODB';
$versions[31]['down'][] = 'ALTER TABLE pagespeed ENGINE = MyISAM';
$versions[31]['down'][] = 'ALTER TABLE dommonster ENGINE = MyISAM';
$versions[31]['down'][] = 'ALTER TABLE dynatrace ENGINE = MyISAM';
$versions[31]['down'][] = 'ALTER TABLE event ENGINE = MyISAM';
$versions[31]['down'][] = 'ALTER TABLE har ENGINE = MyISAM';
$versions[31]['down'][] = 'ALTER TABLE metric ENGINE = MyISAM';
$versions[31]['down'][] = 'ALTER TABLE pagetest ENGINE = MyISAM';
$versions[31]['down'][] = 'ALTER TABLE yslow2 ENGINE = MyISAM';

/* -------------------------------------------------------------------------------------------------------
 * VERSION 30
 * Switching urls table to INNODB engine for better performance
*/
$versions[30]['up'][] = 'ALTER TABLE urls ENGINE = INNODB';
$versions[30]['down'][] = 'ALTER TABLE urls ENGINE = MyISAM';

/* -------------------------------------------------------------------------------------------------------
 * VERSION 29
 * Switching to INNODB engine for better performance
*/
$versions[29]['up'][] = 'ALTER TABLE user_urls ENGINE = INNODB';
$versions[29]['down'][] = 'ALTER TABLE user_urls ENGINE = MyISAM';

/* -------------------------------------------------------------------------------------------------------
 * VERSION 28
 * Adding more WebPageTest fields
*/
$versions[28]['up'][] = "ALTER TABLE `pagetest`
DROP test_url,
ADD `version` VARCHAR( 255 ) NULL COMMENT 'WPT version' AFTER `url_id`,
ADD `r_aft` MEDIUMINT(3) UNSIGNED NULL COMMENT '[first view] Above The Fold Time (ms)' AFTER r_TTFB,
ADD `f_aft` MEDIUMINT(3) UNSIGNED NULL COMMENT '[repeat view] Above The Fold Time (ms)' AFTER r_TTFB,
ADD `r_domElements` SMALLINT(2) UNSIGNED NULL COMMENT '[repeat view] Number of DOM Elements' AFTER r_render,
ADD `f_domElements` SMALLINT(2) UNSIGNED NULL COMMENT '[first view] Number of DOM Elements' AFTER r_render,
ADD `r_connections` SMALLINT(2) UNSIGNED NULL COMMENT '[repeat view] Number of connections' AFTER r_requestsDoc,
ADD `f_connections` SMALLINT(2) UNSIGNED NULL COMMENT '[first view] Number of connections' AFTER r_requestsDoc,
ADD f_score_cache TINYINT(1) UNSIGNED NULL COMMENT 'Cache Static',
ADD r_score_cache TINYINT(1) UNSIGNED NULL COMMENT 'Cache Static',
ADD f_score_cdn TINYINT(1) UNSIGNED NULL COMMENT 'Use a CD',
ADD r_score_cdn TINYINT(1) UNSIGNED NULL COMMENT 'Use a CD',
ADD f_score_gzip TINYINT(1) UNSIGNED NULL COMMENT 'GZIP text',
ADD r_score_gzip TINYINT(1) UNSIGNED NULL COMMENT 'GZIP text',
ADD f_score_cookies TINYINT(1) UNSIGNED NULL COMMENT 'Cookies',
ADD r_score_cookies TINYINT(1) UNSIGNED NULL COMMENT 'Cookies',
ADD f_score_keep_alive TINYINT(1) UNSIGNED NULL COMMENT 'Persistent connections (keep-alive)',
ADD r_score_keep_alive TINYINT(1) UNSIGNED NULL COMMENT 'Persistent connections (keep-alive)',
ADD f_score_minify TINYINT(1) UNSIGNED NULL COMMENT 'Minify JavaScript',
ADD r_score_minify TINYINT(1) UNSIGNED NULL COMMENT 'Minify JavaScript',
ADD f_score_combine TINYINT(1) UNSIGNED NULL COMMENT 'Combine CSS/JS',
ADD r_score_combine TINYINT(1) UNSIGNED NULL COMMENT 'Combine CSS/JS',
ADD f_score_compress TINYINT(1) UNSIGNED NULL COMMENT 'Compress Images',
ADD r_score_compress TINYINT(1) UNSIGNED NULL COMMENT 'Compress Images',
ADD f_score_etags TINYINT(1) UNSIGNED NULL COMMENT 'No Etags',
ADD r_score_etags TINYINT(1) UNSIGNED NULL COMMENT 'No Etags',
ADD f_gzip_total MEDIUMINT(3) UNSIGNED NULL COMMENT 'Total size of compressible text',
ADD r_gzip_total MEDIUMINT(3) UNSIGNED NULL COMMENT 'Total size of compressible text',
ADD f_gzip_savings MEDIUMINT(3) UNSIGNED NULL COMMENT 'Potential text compression savings',
ADD r_gzip_savings MEDIUMINT(3) UNSIGNED NULL COMMENT 'Potential text compression savings',
ADD f_minify_total MEDIUMINT(3) UNSIGNED NULL COMMENT 'Total size of minifiable text',
ADD r_minify_total MEDIUMINT(3) UNSIGNED NULL COMMENT 'Total size of minifiable text',
ADD f_minify_savings MEDIUMINT(3) UNSIGNED NULL COMMENT 'Potential text minification savings',
ADD r_minify_savings MEDIUMINT(3) UNSIGNED NULL COMMENT 'Potential text minification savings',
ADD f_image_total MEDIUMINT(3) UNSIGNED NULL COMMENT 'Total size of compressible images',
ADD r_image_total MEDIUMINT(3) UNSIGNED NULL COMMENT 'Total size of compressible images',
ADD f_image_savings MEDIUMINT(3) UNSIGNED NULL COMMENT 'Potential image compression savings',
ADD r_image_savings MEDIUMINT(3) UNSIGNED NULL COMMENT 'Potential image compression savings',
ADD UNIQUE (`test_id`)
";

$versions[28]['up'][] = "ALTER TABLE urls
ADD pagetest_last_id BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Last measurement ID for WebPageTest beacon' AFTER har_last_id,
ADD pagetest_refresh_request TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT 0 COMMENT  'Set it to one when WebPageTest score needs refreshing' AFTER dt_refresh_request
";

$versions[28]['down'][] = "ALTER TABLE urls
DROP pagetest_last_id,
DROP pagetest_refresh_request";
$versions[28]['down'][] = "ALTER TABLE `pagetest`
DROP `version`,
DROP f_aft,
DROP r_aft,
DROP f_connections,
DROP r_connections,
DROP f_domElements,
DROP r_domElements,
DROP f_score_cache,
DROP r_score_cache,
DROP f_score_cdn,
DROP r_score_cdn,
DROP f_score_gzip,
DROP r_score_gzip,
DROP f_score_cookies,
DROP r_score_cookies,
DROP f_score_keep_alive,
DROP r_score_keep_alive,
DROP f_score_minify,
DROP r_score_minify,
DROP f_score_combine,
DROP r_score_combine,
DROP f_score_compress,
DROP r_score_compress,
DROP f_score_etags,
DROP r_score_etags,
DROP f_gzip_total,
DROP r_gzip_total,
DROP f_gzip_savings,
DROP r_gzip_savings,
DROP f_minify_total,
DROP r_minify_total,
DROP f_minify_savings,
DROP r_minify_savings,
DROP f_image_total,
DROP r_image_total,
DROP f_image_savings,
DROP r_image_savings,
ADD `test_url` BLOB NOT NULL COMMENT 'PageTest result URL to redirect to' AFTER test_id,
DROP INDEX (`test_id`)
";

/* -------------------------------------------------------------------------------------------------------
 * VERSION 27
 * Making PageSpeed metrics optional in case some rules didn't run or didn't produce valid result
*/
$versions[27]['up'][] = "ALTER TABLE `pagespeed`
MODIFY `pMinifyCSS` FLOAT UNSIGNED NULL,
MODIFY `pMinifyJS` FLOAT UNSIGNED NULL,
MODIFY `pOptImgs` FLOAT UNSIGNED NULL,
MODIFY `pImgDims` FLOAT UNSIGNED NULL,
MODIFY `pCombineJS` FLOAT UNSIGNED NULL,
MODIFY `pCombineCSS` FLOAT UNSIGNED NULL,
MODIFY `pBrowserCache` FLOAT UNSIGNED NULL,
MODIFY `pCacheValid` FLOAT UNSIGNED NULL,
MODIFY `pNoCookie` FLOAT UNSIGNED NULL,
MODIFY `pParallelDl` FLOAT UNSIGNED NULL,
MODIFY `pCssSelect` FLOAT UNSIGNED NULL,
MODIFY `pDeferJS` FLOAT UNSIGNED NULL,
MODIFY `pGzip` FLOAT UNSIGNED NULL,
MODIFY `pMinRedirect` FLOAT UNSIGNED NULL,
MODIFY `pCssExpr` FLOAT UNSIGNED NULL,
MODIFY `pUnusedCSS` FLOAT UNSIGNED NULL,
MODIFY `pMinDns` FLOAT UNSIGNED NULL,
MODIFY `pDupeRsrc` FLOAT UNSIGNED NULL,
MODIFY `pScaleImgs` FLOAT UNSIGNED NULL,
MODIFY `pMinifyHTML` FLOAT UNSIGNED NULL,
MODIFY `pMinReqSize` FLOAT UNSIGNED NULL,
MODIFY `pCssJsOrder` FLOAT UNSIGNED NULL,
MODIFY `pCssInHead` FLOAT UNSIGNED NULL,
MODIFY `pCharsetEarly` FLOAT UNSIGNED NULL,
MODIFY `pBadReqs` FLOAT UNSIGNED NULL,
MODIFY `pCssImport` FLOAT UNSIGNED NULL,
MODIFY `pDocWrite` FLOAT UNSIGNED NULL,
MODIFY `pPreferAsync` FLOAT UNSIGNED NULL,
MODIFY `pRemoveQuery` FLOAT UNSIGNED NULL,
MODIFY `pVaryAE` FLOAT UNSIGNED NULL,
MODIFY `pSprite` FLOAT UNSIGNED NULL";

$versions[27]['down'][] = "ALTER TABLE `pagespeed`
MODIFY `pSprite` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pVaryAE` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pRemoveQuery` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pPreferAsync` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pDocWrite` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pCssImport` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pBadReqs` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pCharsetEarly` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pCssInHead` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pCssJsOrder` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pMinReqSize` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pMinifyHTML` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pScaleImgs` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pDupeRsrc` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pMinDns` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pUnusedCSS` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pCssExpr` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pMinRedirect` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pGzip` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pDeferJS` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pCssSelect` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pParallelDl` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pNoCookie` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pCacheValid` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pBrowserCache` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pCombineCSS` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pCombineJS` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pImgDims` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pOptImgs` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pMinifyJS` FLOAT UNSIGNED NOT NULL DEFAULT '0',
MODIFY `pMinifyCSS` FLOAT UNSIGNED NOT NULL DEFAULT '0'";

/* -------------------------------------------------------------------------------------------------------
 * VERSION 26
 * Adding some indexes for faster loads
*/
$versions[26]['up'][] = "ALTER TABLE `dynatrace` ADD INDEX (`url_id`)";
$versions[26]['up'][] = "ALTER TABLE `har` ADD INDEX (`url_id`)";
$versions[26]['up'][] = "ALTER TABLE `dommonster` ADD INDEX (`url_id`)";
$versions[26]['up'][] = "ALTER TABLE `metric` ADD INDEX (`url_id`)";
$versions[26]['up'][] = "ALTER TABLE `pagetest` ADD INDEX (`url_id`)";

$versions[26]['down'][] = "ALTER TABLE `pagetest` DROP INDEX `url_id`";
$versions[26]['down'][] = "ALTER TABLE `metric` DROP INDEX `url_id`";
$versions[26]['down'][] = "ALTER TABLE `dommonster` DROP INDEX `url_id`";
$versions[26]['down'][] = "ALTER TABLE `har` DROP INDEX `url_id`";
$versions[26]['down'][] = "ALTER TABLE `dynatrace` DROP INDEX `url_id`";

/* -------------------------------------------------------------------------------------------------------
 * VERSION 24-25, 14-15
 * removed userbase database setup - leave it to userbase's scripts
*/
$versions[25]['up'][]		= "SELECT 1";
$versions[25]['udown'][]	= "SELECT 1";
$versions[24]['up'][]		= "SELECT 1";
$versions[24]['udown'][]	= "SELECT 1";
$versions[15]['up'][]		= "SELECT 1";
$versions[15]['udown'][]	= "SELECT 1";
$versions[14]['up'][]		= "SELECT 1";
$versions[14]['udown'][]	= "SELECT 1";

/* -------------------------------------------------------------------------------------------------------
 * VERSION 23
 * Added HAR beacon last_id
*/
$versions[23]['up'][] = "ALTER TABLE urls ADD har_last_id BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Last measurement ID for HAR beacon'";
$versions[23]['down'][] = "ALTER TABLE urls DROP har_last_id";

/* -------------------------------------------------------------------------------------------------------
 * VERSION 22
 * Adding explicit default values for refresher bits
*/
$versions[22]['up'][]	= "ALTER TABLE  `urls` CHANGE  `y_refresh_request`  `y_refresh_request` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT 0 COMMENT  'Set it to one when YSlow score needs refreshing'";
$versions[22]['up'][]	= "ALTER TABLE  `urls` CHANGE  `p_refresh_request`  `p_refresh_request` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT 0 COMMENT  'Set it to one when YSlow score needs refreshing'";
$versions[22]['up'][]	= "ALTER TABLE  `urls` CHANGE  `dt_refresh_request`  `dt_refresh_request` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT 0 COMMENT  'Set it to one when YSlow score needs refreshing'";

$versions[22]['down'][]	= "ALTER TABLE  `urls` CHANGE  `y_refresh_request`  `y_refresh_request` TINYINT( 1 ) UNSIGNED NOT NULL COMMENT  'Set it to one when YSlow score needs refreshing'";
$versions[22]['down'][]	= "ALTER TABLE  `urls` CHANGE  `p_refresh_request`  `p_refresh_request` TINYINT( 1 ) UNSIGNED NOT NULL COMMENT  'Set it to one when YSlow score needs refreshing'";
$versions[22]['down'][]	= "ALTER TABLE  `urls` CHANGE  `dt_refresh_request`  `dt_refresh_request` TINYINT( 1 ) UNSIGNED NOT NULL COMMENT  'Set it to one when YSlow score needs refreshing'";

/* -------------------------------------------------------------------------------------------------------
 * VERSION 21
 * Added DOM Monstermetrics
*/
$versions[21]['up'][] = "ALTER TABLE urls ADD dommonster_last_id BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Last measurement ID for DOM Monster beacon'";
$versions[21]['up'][] = "CREATE TABLE `dommonster` (
  `id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Measurement ID',
  `version` varchar(255) default NULL COMMENT 'Version of DOM Monster bookmarklet',
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP COMMENT 'Measurement time',
  `url_id` bigint(20) unsigned NOT NULL COMMENT 'URL ID',
  elements bigint(20) unsigned NOT NULL COMMENT 'number of elements [number]',
  nodecount bigint(20) unsigned NOT NULL COMMENT 'number of DOM nodes [number]',
  textnodes bigint(20) unsigned NOT NULL COMMENT 'number of Text nodes [number]',
  textnodessize bigint(20) unsigned NOT NULL COMMENT 'size of Text nodes [bytes]',
  contentpercent decimal(5,2) unsigned NOT NULL COMMENT 'content percentage [percentage]',
  average decimal(10,1) unsigned NOT NULL COMMENT 'average nesting depth [number]',
  domsize bigint(20) unsigned NOT NULL COMMENT 'serialized DOM size [bytes]',
  bodycount bigint(20) unsigned default NULL COMMENT 'DOM tree serialization time [ms]',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM";

$versions[21]['down'][] = "ALTER TABLE urls DROP dommonster_last_id";
$versions[21]['down'][] = "DROP TABLE `dommonster`;";

/* -------------------------------------------------------------------------------------------------------
 * VERSION 20
 * Allow test requests
*/
$versions[20]['up'][]	= "ALTER TABLE  `urls` ADD  `y_refresh_request` TINYINT( 1 ) UNSIGNED NOT NULL COMMENT  'Set it to one when YSlow score needs refreshing'";
$versions[20]['up'][]	= "ALTER TABLE  `urls` ADD  `p_refresh_request` TINYINT( 1 ) UNSIGNED NOT NULL COMMENT  'Set it to one when PageSpeed score needs refreshing'";
$versions[20]['up'][]	= "ALTER TABLE  `urls` ADD  `dt_refresh_request` TINYINT( 1 ) UNSIGNED NOT NULL COMMENT  'Set it to one when dynaTrace score needs refreshing'";
$versions[20]['down'][]	= "ALTER TABLE  `urls` DROP  `dt_refresh_request`";
$versions[20]['down'][]	= "ALTER TABLE  `urls` DROP  `p_refresh_request`";
$versions[20]['down'][]	= "ALTER TABLE  `urls` DROP  `y_refresh_request`";

/* -------------------------------------------------------------------------------------------------------
 * VERSION 19
 * Adding har link parameter
*/
$versions[19]['up'][]	= "ALTER TABLE  `har` CHANGE  `har`  `har` LONGBLOB NULL COMMENT  'HAR contents'";
$versions[19]['up'][]	= "ALTER TABLE  `har` ADD  `link` BLOB NULL COMMENT  'URL of HAR file'";
$versions[19]['down'][]	= "ALTER TABLE  `har` DROP  `link`";
$versions[19]['down'][]	= "ALTER TABLE  `har` CHANGE  `har`  `har` LONGBLOB NOT NULL COMMENT  'HAR contents'";

/* -------------------------------------------------------------------------------------------------------
 * VERSION 18
 * IP is not required anymore
*/
$versions[18]['up'][]	= "ALTER TABLE `pagespeed` CHANGE `ip` `ip` INT(4) UNSIGNED NULL DEFAULT '0'";
$versions[18]['up'][]	= "ALTER TABLE `yslow2` CHANGE `ip` `ip` INT(4) UNSIGNED NULL DEFAULT '0' COMMENT 'IP address of the agent'";
$versions[18]['down'][]	= "ALTER TABLE `yslow2` CHANGE `ip` `ip` INT(4) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'IP address of the agent'";
$versions[18]['down'][]	= "ALTER TABLE `pagespeed` CHANGE `ip` `ip` INT(4) UNSIGNED NOT NULL DEFAULT '0'";

/* -------------------------------------------------------------------------------------------------------
 * VERSION 17
 * Adding "Avoid Empty Image src" rule to yslow
 * Making all scores unsigned types
*/
$versions[17]['up'][] = "ALTER TABLE `yslow2`
	ADD `yemptysrc` SMALLINT(3) UNSIGNED COMMENT 'Avoid Empty Image src' AFTER `yexpires`,
	MODIFY `ynumreq` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Make fewer HTTP requests',
	MODIFY `ycdn` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Using CDN',
	MODIFY `yexpires` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Expires Headers',
	MODIFY `ycompress` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Gzip components',
	MODIFY `ycsstop` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'CSS at the top',
	MODIFY `yjsbottom` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'JS at the bottom',
	MODIFY `yexpressions` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'CSS expressions',
	MODIFY `yexternal` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Make JavaScript and CSS external',
	MODIFY `ydns` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Reduce DNS lookups',
	MODIFY `yminify` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Minify JavaScript and CSS',
	MODIFY `yredirects` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Avoid URL redirects',
	MODIFY `ydupes` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Remove duplicate JavaScript and CSS',
	MODIFY `yetags` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Configure entity tags (ETags)',
	MODIFY `yxhr` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Make AJAX cacheable',
	MODIFY `yxhrmethod` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Use GET for AJAX requests',
	MODIFY `ymindom` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Reduce the number of DOM elements',
	MODIFY `yno404` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Avoid HTTP 404 (Not Found) error',
	MODIFY `ymincookie` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Reduce cookie size',
	MODIFY `ycookiefree` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Use cookie-free domains',
	MODIFY `ynofilter` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Avoid AlphaImageLoader filter',
	MODIFY `yimgnoscale` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Do not scale images in HTML',
	MODIFY `yfavicon` smallint(3) UNSIGNED DEFAULT NULL COMMENT 'Make favicon small and cacheable'";

$versions[17]['down'][] = "ALTER TABLE `yslow2`
	DROP yemptysrc,
	MODIFY `ynumreq` smallint(6) DEFAULT NULL COMMENT 'Make fewer HTTP requests',
	MODIFY `ycdn` smallint(6) DEFAULT NULL COMMENT 'Using CDN',
	MODIFY `yexpires` smallint(6) DEFAULT NULL COMMENT 'Expires Headers',
	MODIFY `ycompress` smallint(6) DEFAULT NULL COMMENT 'Gzip components',
	MODIFY `ycsstop` smallint(6) DEFAULT NULL COMMENT 'CSS at the top',
	MODIFY `yjsbottom` smallint(6) DEFAULT NULL COMMENT 'JS at the bottom',
	MODIFY `yexpressions` smallint(6) DEFAULT NULL COMMENT 'CSS expressions',
	MODIFY `yexternal` smallint(6) DEFAULT NULL COMMENT 'Make JavaScript and CSS external',
	MODIFY `ydns` smallint(6) DEFAULT NULL COMMENT 'Reduce DNS lookups',
	MODIFY `yminify` smallint(6) DEFAULT NULL COMMENT 'Minify JavaScript and CSS',
	MODIFY `yredirects` smallint(6) DEFAULT NULL COMMENT 'Avoid URL redirects',
	MODIFY `ydupes` smallint(6) DEFAULT NULL COMMENT 'Remove duplicate JavaScript and CSS',
	MODIFY `yetags` smallint(6) DEFAULT NULL COMMENT 'Configure entity tags (ETags)',
	MODIFY `yxhr` smallint(6) DEFAULT NULL COMMENT 'Make AJAX cacheable',
	MODIFY `yxhrmethod` smallint(6) DEFAULT NULL COMMENT 'Use GET for AJAX requests',
	MODIFY `ymindom` smallint(6) DEFAULT NULL COMMENT 'Reduce the number of DOM elements',
	MODIFY `yno404` smallint(6) DEFAULT NULL COMMENT 'Avoid HTTP 404 (Not Found) error',
	MODIFY `ymincookie` smallint(6) DEFAULT NULL COMMENT 'Reduce cookie size',
	MODIFY `ycookiefree` smallint(6) DEFAULT NULL COMMENT 'Use cookie-free domains',
	MODIFY `ynofilter` smallint(6) DEFAULT NULL COMMENT 'Avoid AlphaImageLoader filter',
	MODIFY `yimgnoscale` smallint(6) DEFAULT NULL COMMENT 'Do not scale images in HTML',
	MODIFY `yfavicon` smallint(6) DEFAULT NULL COMMENT 'Make favicon small and cacheable'";

/* -------------------------------------------------------------------------------------------------------
 * VERSION 16
 * Adding mroe details for PageTest
*/
$versions[16]['up'][]	= "ALTER TABLE `pagetest`
ADD `f_loadTime` MEDIUMINT(3) UNSIGNED COMMENT '[first view] Load Time (ms)',
ADD `r_loadTime` MEDIUMINT(3) UNSIGNED COMMENT '[repeat view] Load Time (ms)',
ADD `f_TTFB` MEDIUMINT(3) UNSIGNED COMMENT '[first view] Time to First Byte (ms)',
ADD `r_TTFB` MEDIUMINT(3) UNSIGNED COMMENT '[repeat view] Time to First Byte (ms)',
ADD `f_bytesIn` INT(4) UNSIGNED COMMENT '[first view] Bytes In',
ADD `r_bytesIn` INT(4) UNSIGNED COMMENT '[repeat view] Bytes In',
ADD `f_bytesInDoc` INT(4) UNSIGNED COMMENT '[first view] Bytes In (Document)',
ADD `r_bytesInDoc` INT(4) UNSIGNED COMMENT '[repeat view] Bytes In (Document)',
ADD `f_requests` SMALLINT(2) UNSIGNED COMMENT '[first view] Number of Requests',
ADD `r_requests` SMALLINT(2) UNSIGNED COMMENT '[repeat view] Number of Requests',
ADD `f_requestsDoc` SMALLINT(2) UNSIGNED COMMENT '[first view] Number of Requests (Document)',
ADD `r_requestsDoc` SMALLINT(2) UNSIGNED COMMENT '[repeat view] Number of Requests (Document)',
ADD `f_render` MEDIUMINT(3) UNSIGNED COMMENT '[first view] Time to Start Render (ms)',
ADD `r_render` MEDIUMINT(3) UNSIGNED COMMENT '[repeat view] Time to Start Render (ms)',
ADD `f_fullyLoaded` MEDIUMINT(3) UNSIGNED COMMENT '[first view] Time to Fully Loaded (ms)',
ADD `r_fullyLoaded` MEDIUMINT(3) UNSIGNED COMMENT '[repeat view] Time to Fully Loaded (ms)',
ADD `f_docTime` MEDIUMINT(3) UNSIGNED COMMENT '[first view] Document Complete Time (ms)',
ADD `r_docTime` MEDIUMINT(3) UNSIGNED COMMENT '[repeat view] Document Complete Time (ms)',
ADD `f_domTime` MEDIUMINT(3) UNSIGNED COMMENT '[first view] DOM Element Time (ms)',
ADD `r_domTime` MEDIUMINT(3) UNSIGNED COMMENT '[repeat view] DOM Element Time (ms)'";
$versions[16]['down'][]	= "ALTER TABLE `pagetest`
  DROP `f_loadTime`,
  DROP `r_loadTime`,
  DROP `f_TTFB`,
  DROP `r_TTFB`,
  DROP `f_bytesIn`,
  DROP `r_bytesIn`,
  DROP `f_bytesInDoc`,
  DROP `r_bytesInDoc`,
  DROP `f_requests`,
  DROP `r_requests`,
  DROP `f_requestsDoc`,
  DROP `r_requestsDoc`,
  DROP `f_render`,
  DROP `r_render`,
  DROP `f_fullyLoaded`,
  DROP `r_fullyLoaded`,
  DROP `f_docTime`,
  DROP `r_docTime`,
  DROP `f_domTime`,
  DROP `r_domTime`
";

/* version 13
 *
 * PageSpeed 1.9 support
*/

// up
$versions[13]['up'][] = "ALTER TABLE `pagespeed` CHANGE `pSpecifyCharsetEarly` `pCharsetEarly` FLOAT UNSIGNED NOT NULL DEFAULT  '0';";
$versions[13]['up'][] = "ALTER TABLE `pagespeed` CHANGE `pProxyCache` `pCacheValid` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";
$versions[13]['up'][] = "ALTER TABLE `pagespeed` CHANGE `pPutCssInTheDocumentHead` `pCssInHead` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";
$versions[13]['up'][] = "ALTER TABLE `pagespeed` CHANGE `pOptimizeTheOrderOfStylesAndScripts` `pCssJsOrder` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";
$versions[13]['up'][] = "ALTER TABLE `pagespeed` CHANGE `pMinimizeRequestSize` `pMinReqSize` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";

$versions[13]['up'][] = "ALTER TABLE `pagespeed` ADD COLUMN `pBadReqs` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";
$versions[13]['up'][] = "ALTER TABLE `pagespeed` ADD COLUMN `pCssImport` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";
$versions[13]['up'][] = "ALTER TABLE `pagespeed` ADD COLUMN `pDocWrite` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";
$versions[13]['up'][] = "ALTER TABLE `pagespeed` ADD COLUMN `pPreferAsync` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";
$versions[13]['up'][] = "ALTER TABLE `pagespeed` ADD COLUMN `pRemoveQuery` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";
$versions[13]['up'][] = "ALTER TABLE `pagespeed` ADD COLUMN `pVaryAE` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";
$versions[13]['up'][] = "ALTER TABLE `pagespeed` ADD COLUMN `pSprite` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";

// down
$versions[13]['down'][] = "ALTER TABLE `pagespeed` CHANGE `pCharsetEarly` `pSpecifyCharsetEarly` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";
$versions[13]['down'][] = "ALTER TABLE `pagespeed` CHANGE `pCacheValid` `pProxyCache` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";
$versions[13]['down'][] = "ALTER TABLE `pagespeed` CHANGE `pCssInHead` `pPutCssInTheDocumentHead` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";
$versions[13]['down'][] = "ALTER TABLE `pagespeed` CHANGE `pCssJsOrder` `pOptimizeTheOrderOfStylesAndScripts` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";
$versions[13]['down'][] = "ALTER TABLE `pagespeed` CHANGE `pMinReqSize` `pMinimizeRequestSize` FLOAT UNSIGNED NOT NULL DEFAULT  '0'";

$versions[13]['down'][] = "ALTER TABLE `pagespeed` DROP COLUMN `pBadReqs`";
$versions[13]['down'][] = "ALTER TABLE `pagespeed` DROP COLUMN `pCssImport`";
$versions[13]['down'][] = "ALTER TABLE `pagespeed` DROP COLUMN `pDocWrite`";
$versions[13]['down'][] = "ALTER TABLE `pagespeed` DROP COLUMN `pPreferAsync`";
$versions[13]['down'][] = "ALTER TABLE `pagespeed` DROP COLUMN `pRemoveQuery`";
$versions[13]['down'][] = "ALTER TABLE `pagespeed` DROP COLUMN `pVaryAE`";
$versions[13]['down'][] = "ALTER TABLE `pagespeed` DROP COLUMN `pSprite`";

/* version 12
 *
 * timestamps don't need to be updatable
*/
$versions[12]['up'][] = "ALTER TABLE  `yslow2` CHANGE  `timestamp`  `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT  'Measurement timestamp'";
$versions[12]['down'][] = "ALTER TABLE  `yslow2` CHANGE  `timestamp`  `timestamp` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT  'Measurement timestamp'";

/* version 11
 *
 * Storing PageTest locations
*/
$versions[11]['up'][] = "ALTER TABLE pagetest ADD location TEXT DEFAULT NULL COMMENT 'Test location'";
$versions[11]['down'][] = "ALTER TABLE pagetest DROP location";

/* version 10
 *
 * Adding PageTest history
 */
$versions[10] = array(
	'up' => "CREATE TABLE `pagetest` (
 `id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Unique id',
 `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 `url_id` BIGINT( 20 ) UNSIGNED NOT NULL COMMENT 'URL id',
 `test_id` varchar(255) NOT NULL COMMENT 'PageTest test id',
 `test_url` BLOB NOT NULL COMMENT 'PageTest result URL to redirect to'
) ENGINE=MyISAM;",
	'down' => 'DROP TABLE pagetest',
);

/* version 9
 *
 * Adding dynaTrace beacon's details
*/
$versions[9]['up'][] = "ALTER TABLE dynatrace ADD details TEXT DEFAULT NULL COMMENT 'Beacon details'";
$versions[9]['down'][] = "ALTER TABLE dynatrace DROP details";

// Add new migrations on top, right below this line.

/* version 8
 *
 * Adding dynaTrace beacon
*/
$versions[8]['up'][] = "ALTER TABLE urls ADD dynatrace_last_id BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Last measurement ID for dynaTrace beacon'";
$versions[8]['up'][] = "CREATE TABLE `dynatrace` (
  `id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Measurement ID',
  `version` varchar(255) default NULL COMMENT 'Version of the format used',
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP COMMENT 'Measurement time',
  `url_id` bigint(20) unsigned NOT NULL COMMENT 'URL ID',
  `rank` smallint(5) unsigned NOT NULL COMMENT 'verall Page Rank (1-100)',
  `cache` smallint(5) unsigned default NULL COMMENT 'Page Rank on Caching Best Practices (1-100)',
  `net` smallint(5) unsigned default NULL COMMENT 'Page Rank on Network Requests (1-100)',
  `server` smallint(5) unsigned default NULL COMMENT 'Page Rank on Server-Side Execution Time (1-100)',
  `js` smallint(5) unsigned default NULL COMMENT 'Page Rank on JavaScript executions (1-100)',
  `timetoimpression` bigint(20) unsigned default NULL COMMENT 'Time to First Impression [ms]',
  `timetoonload` bigint(20) unsigned default NULL COMMENT 'Time to onLoad [ms]',
  `timetofullload` bigint(20) unsigned default NULL COMMENT 'Time to Full Page Load [ms]',
  `reqnumber` smallint(6) unsigned default NULL COMMENT '# of Requests [Count]',
  `xhrnumber` smallint(6) unsigned default NULL COMMENT '# of XHR Requests [Count]',
  `pagesize` bigint(20) unsigned default NULL COMMENT 'Total Page Size [bytes]',
  `cachablesize` bigint(20) unsigned default NULL COMMENT 'Total Cachable Size [bytes]',
  `noncachablesize` bigint(20) unsigned default NULL COMMENT 'Total Non-Cachable Size [bytes]',
  `timeonnetwork` bigint(20) unsigned default NULL COMMENT 'Total Time on Network [ms]',
  `timeinjs` bigint(20) unsigned default NULL COMMENT 'Total Time in JavaScript [ms]',
  `timeinrendering` bigint(20) unsigned default NULL COMMENT 'Total Time in Rendering [ms]',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM";

$versions[8]['down'][] = "ALTER TABLE urls DROP dynatrace_last_id";
$versions[8]['down'][] = "DROP TABLE `dynatrace`;";

/* version 7
 *
 * Adding URL creation time to be able to monitor new URLs quickly
*/
$versions[7]['up'][] = "ALTER TABLE urls MODIFY last_update TIMESTAMP NULL DEFAULT NULL";
$versions[7]['up'][] = "ALTER TABLE urls ADD added TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'Time when URL was added to the table' AFTER  `url`";

$versions[7]['down'][] = "ALTER TABLE urls DROP added";
$versions[7]['down'][] = "ALTER TABLE urls MODIFY last_update TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NULL DEFAULT NULL";

/* version 6
 *
 * Adding userbase instance
*/
$versions[6]['up'][] = "CREATE TABLE `user_urls` (
  `user_id` int(10) unsigned NOT NULL COMMENT 'User ID',
  `url_id` bigint(20) unsigned NOT NULL COMMENT 'URL ID to measure',
  PRIMARY KEY  (`user_id`,`url_id`)
) ENGINE=MyISAM;";

$versions[6]['down'][] = "DROP TABLE IF EXISTS `user_urls`";

/* version 5
 *
 * Making last_update NULL unless actually updated
*/

$versions[5]['up'][] = "ALTER TABLE urls MODIFY last_update TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP";
$versions[5]['down'][] = "ALTER TABLE urls MODIFY last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";

/* version 4
 *
 * Combining renamed PageSpeed's metrics
*/
$versions[4]['up'][] = "UPDATE pagespeed SET pOptimizeTheOrderOfStylesAndScripts = pCssJsOrder WHERE pCssJsOrder > pOptimizeTheOrderOfStylesAndScripts";
$versions[4]['up'][] = "ALTER TABLE pagespeed DROP COLUMN pCssJsOrder";

$versions[4]['up'][] = "UPDATE pagespeed SET pPutCssInTheDocumentHead = pCssInHead WHERE pCssInHead > pPutCssInTheDocumentHead";
$versions[4]['up'][] = "ALTER TABLE pagespeed DROP COLUMN pCssInHead";

$versions[4]['up'][] = "UPDATE pagespeed SET pMinimizeRequestSize = pCookieSize WHERE pCookieSize > pMinimizeRequestSize";
$versions[4]['up'][] = "ALTER TABLE pagespeed DROP COLUMN pCookieSize";

$versions[4]['down'][] = "ALTER TABLE pagespeed ADD pCssJsOrder FLOAT UNSIGNED NOT NULL DEFAULT '0'";
$versions[4]['down'][] = "ALTER TABLE pagespeed ADD pCssInHead FLOAT UNSIGNED NOT NULL DEFAULT '0'";
$versions[4]['down'][] = "ALTER TABLE pagespeed ADD pCookieSize FLOAT UNSIGNED NOT NULL DEFAULT '0'";

/* version 3
 *
 * Adding last measurement ID to the urls table for faster retrieval by primary key
 */
$versions[3]['up'][] = "ALTER TABLE urls ADD yslow2_last_id BIGINT(20) UNSIGNED NULL COMMENT 'Last measurement ID for YSlow beacon'";
$versions[3]['up'][] = "ALTER TABLE urls ADD pagespeed_last_id BIGINT(20) UNSIGNED NULL COMMENT 'Last measurement ID for PageSpeed beacon'";
$versions[3]['up'][] = "ALTER TABLE urls DROP w, DROP o, DROP r, DROP ps_w, DROP ps_o, DROP ps_l, DROP ps_r, DROP ps_t";

// migrating data
$versions[3]['up'][] = 'CREATE TEMPORARY TABLE yslow_max_ids SELECT url_id, max(id) as max_id FROM yslow2 GROUP BY url_id';
$versions[3]['up'][] = 'CREATE TEMPORARY TABLE pagespeed_max_ids SELECT url_id, max(id) as max_id FROM pagespeed GROUP BY url_id';
$versions[3]['up'][] = 'UPDATE urls LEFT JOIN yslow_max_ids ON urls.id = yslow_max_ids.url_id LEFT JOIN pagespeed_max_ids ON urls.id = pagespeed_max_ids.url_id SET urls.yslow2_last_id = yslow_max_ids.max_id, urls.pagespeed_last_id = pagespeed_max_ids.max_id';

// downgrading
$versions[3]['down'][] = 'ALTER TABLE urls DROP COLUMN yslow2_last_id';
$versions[3]['down'][] = 'ALTER TABLE urls DROP COLUMN pagespeed_last_id';

// restoring aggregates (no data backporting - lazy)
$versions[3]['down'][] = "ALTER TABLE urls ADD COLUMN w bigint(20) unsigned NOT NULL default '0' COMMENT 'latest size of the page in bytes'";
$versions[3]['down'][] = "ALTER TABLE urls ADD COLUMN o smallint(6) unsigned default NULL COMMENT 'latest overall YSlow grade calculated for this profile'";
$versions[3]['down'][] = "ALTER TABLE urls ADD COLUMN r smallint(6) unsigned NOT NULL default '0' COMMENT 'latest amount of requests with empty cache'";
$versions[3]['down'][] = "ALTER TABLE urls ADD COLUMN ps_w bigint(20) unsigned NOT NULL default '0'";
$versions[3]['down'][] = "ALTER TABLE urls ADD COLUMN ps_o float unsigned default NULL";
$versions[3]['down'][] = "ALTER TABLE urls ADD COLUMN ps_l bigint(20) unsigned NOT NULL default '0'";
$versions[3]['down'][] = "ALTER TABLE urls ADD COLUMN ps_r smallint(6) unsigned NOT NULL default '0'";
$versions[3]['down'][] = "ALTER TABLE urls ADD COLUMN ps_t bigint(20) unsigned NOT NULL default '0'";

/* version 2
 *
 * Adding HAR beacon
 */
$versions[2] = array(
	'up' => "CREATE TABLE  `har` (
 `id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT  'Unique HAR id',
 `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
 `url_id` BIGINT( 20 ) UNSIGNED NOT NULL COMMENT  'URL id',
 `har` LONGBLOB NOT NULL COMMENT  'HAR contents',
 `compressed` TINYINT(1) NOT NULL DEFAULT 0 COMMENT  'Indicates that HAR data is stored compressed'
) ENGINE = MYISAM",
	'down' => 'DROP TABLE har',
);

// version 1
// moved tables.sql here to unify upgrade and install process
$versions[1]['up'][] = "CREATE TABLE `event` (
  `id` bigint(20) unsigned NOT NULL auto_increment,
  `type` varchar(25) default NULL COMMENT 'string representing type of the event',
  `url_prefix` blob NOT NULL COMMENT 'URL prefix to match the urls - usually protocol and host name',
  `title` text NOT NULL COMMENT 'event message',
  `start` timestamp NOT NULL default CURRENT_TIMESTAMP COMMENT 'start date of event',
  `end` timestamp NULL default NULL COMMENT 'end date of event (if null, start is the same as end)',
  `resource_url` blob COMMENT 'additional URL to resource related to the event.',
  PRIMARY KEY  (`id`),
  KEY `start` (`start`)
) ENGINE=MyISAM";
$versions[1]['up'][] = "CREATE TABLE `metric` (
  `id` bigint(20) unsigned NOT NULL auto_increment,
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `url_id` bigint(20) unsigned NOT NULL default '0',
  `metric_id` mediumint(8) unsigned NOT NULL default '0',
  `value` float NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM";
$versions[1]['up'][] = "CREATE TABLE `pagespeed` (
  `id` bigint(20) unsigned NOT NULL auto_increment,
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `ip` int(4) unsigned NOT NULL default '0',
  `user_agent` text NOT NULL,
  `url_id` bigint(20) unsigned NOT NULL default '0',
  `w` bigint(20) unsigned NOT NULL default '0',
  `o` float unsigned NOT NULL default '0',
  `l` bigint(20) unsigned NOT NULL default '0',
  `r` smallint(6) unsigned NOT NULL default '0',
  `t` bigint(20) unsigned NOT NULL default '0',
  `v` text NOT NULL,
  `pMinifyCSS` float unsigned NOT NULL default '0',
  `pMinifyJS` float unsigned NOT NULL default '0',
  `pOptImgs` float unsigned NOT NULL default '0',
  `pImgDims` float unsigned NOT NULL default '0',
  `pCombineJS` float unsigned NOT NULL default '0',
  `pCombineCSS` float unsigned NOT NULL default '0',
  `pCssInHead` float unsigned NOT NULL default '0',
  `pBrowserCache` float unsigned NOT NULL default '0',
  `pProxyCache` float unsigned NOT NULL default '0',
  `pNoCookie` float unsigned NOT NULL default '0',
  `pCookieSize` float unsigned NOT NULL default '0',
  `pParallelDl` float unsigned NOT NULL default '0',
  `pCssSelect` float unsigned NOT NULL default '0',
  `pCssJsOrder` float unsigned NOT NULL default '0',
  `pDeferJS` float unsigned NOT NULL default '0',
  `pGzip` float unsigned NOT NULL default '0',
  `pMinRedirect` float unsigned NOT NULL default '0',
  `pCssExpr` float unsigned NOT NULL default '0',
  `pUnusedCSS` float unsigned NOT NULL default '0',
  `pMinDns` float unsigned NOT NULL default '0',
  `pDupeRsrc` float unsigned NOT NULL default '0',
  `pScaleImgs` float unsigned NOT NULL default '0' COMMENT 'Scale Images',
  `pMinifyHTML` float unsigned NOT NULL default '0',
  `pMinimizeRequestSize` float unsigned NOT NULL default '0',
  `pOptimizeTheOrderOfStylesAndScripts` float unsigned NOT NULL default '0',
  `pPutCssInTheDocumentHead` float unsigned NOT NULL default '0',
  `pSpecifyCharsetEarly` float unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `url_id` (`url_id`)
) ENGINE=MyISAM";
$versions[1]['up'][] = "CREATE TABLE `urls` (
  `id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'id to reference',
  `url` blob NOT NULL COMMENT 'url',
  `last_update` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `last_event_update` timestamp NOT NULL default '0000-00-00 00:00:00' COMMENT 'Last time events were updated for this URL',
  `w` bigint(20) unsigned NOT NULL default '0' COMMENT 'latest size of the page in bytes',
  `o` smallint(6) unsigned default NULL COMMENT 'latest overall YSlow grade calculated for this profile',
  `r` smallint(6) unsigned NOT NULL default '0' COMMENT 'latest amount of requests with empty cache',
  `ps_w` bigint(20) unsigned NOT NULL default '0',
  `ps_o` float unsigned default NULL,
  `ps_l` bigint(20) unsigned NOT NULL default '0',
  `ps_r` smallint(6) unsigned NOT NULL default '0',
  `ps_t` bigint(20) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `last_update` (`last_update`)
) ENGINE=MyISAM";
$versions[1]['up'][] = "CREATE TABLE `yslow2` (
  `id` bigint(20) unsigned NOT NULL auto_increment COMMENT 'Entry id',
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT 'Measurement timestamp',
  `ip` int(4) unsigned NOT NULL default '0' COMMENT 'IP address of the agent',
  `user_agent` text NOT NULL COMMENT 'User agent string',
  `url_id` bigint(20) unsigned NOT NULL default '0',
  `w` bigint(20) unsigned NOT NULL default '0' COMMENT 'size of the page in bytes',
  `o` smallint(5) unsigned NOT NULL default '0' COMMENT 'overall YSlow grade calculated for this profile',
  `r` smallint(6) unsigned NOT NULL default '0' COMMENT 'total amount of requests with empty cache',
  `i` text NOT NULL COMMENT 'testing profile used',
  `lt` bigint(20) unsigned NOT NULL default '0' COMMENT 'page load time',
  `ynumreq` smallint(6) default NULL COMMENT 'Make fewer HTTP requests',
  `ycdn` smallint(6) default NULL COMMENT 'Using CDN',
  `yexpires` smallint(6) default NULL COMMENT 'Expires Headers',
  `ycompress` smallint(6) default NULL COMMENT 'Gzip components',
  `ycsstop` smallint(6) default NULL COMMENT 'CSS at the top',
  `yjsbottom` smallint(6) default NULL COMMENT 'JS at the bottom',
  `yexpressions` smallint(6) default NULL COMMENT 'CSS expressions',
  `yexternal` smallint(6) default NULL COMMENT 'Make JavaScript and CSS external',
  `ydns` smallint(6) default NULL COMMENT 'Reduce DNS lookups',
  `yminify` smallint(6) default NULL COMMENT 'Minify JavaScript and CSS',
  `yredirects` smallint(6) default NULL COMMENT 'Avoid URL redirects',
  `ydupes` smallint(6) default NULL COMMENT 'Remove duplicate JavaScript and CSS',
  `yetags` smallint(6) default NULL COMMENT 'Configure entity tags (ETags)',
  `yxhr` smallint(6) default NULL COMMENT 'Make AJAX cacheable',
  `yxhrmethod` smallint(6) default NULL COMMENT 'Use GET for AJAX requests',
  `ymindom` smallint(6) default NULL COMMENT 'Reduce the number of DOM elements',
  `yno404` smallint(6) default NULL COMMENT 'Avoid HTTP 404 (Not Found) error',
  `ymincookie` smallint(6) default NULL COMMENT 'Reduce cookie size',
  `ycookiefree` smallint(6) default NULL COMMENT 'Use cookie-free domains',
  `ynofilter` smallint(6) default NULL COMMENT 'Avoid AlphaImageLoader filter',
  `yimgnoscale` smallint(6) default NULL COMMENT 'Do not scale images in HTML',
  `yfavicon` smallint(6) default NULL COMMENT 'Make favicon small and cacheable',
  `details` text COMMENT 'Beacon details',
  PRIMARY KEY  (`id`),
  KEY `url_id` (`url_id`)
) ENGINE=MyISAM";

$versions[1]['down'][] = "DROP TABLE event";
$versions[1]['down'][] = "DROP TABLE metric";
$versions[1]['down'][] = "DROP TABLE pagespeed";
$versions[1]['down'][] = "DROP TABLE urls";
$versions[1]['down'][] = "DROP TABLE yslow2";

require_once(dirname(__FILE__).'/global.php');

// creating DBUpgrade object with your database credentials and $versions defined above
$dbupgrade = new DBUpgrade(new mysqli($host, $user, $pass, $db, $port), $versions);

require_once(dirname(__FILE__).'/dbupgrade/client.php');


text:
package org.apache.causeway.persistence.jpa.metamodel.facets.prop.transients;

import org.apache.causeway.core.metamodel.facetapi.Facet;

public interface JpaTransientFacet extends Facet {

}

redpajama_set_name: RedPajamaGithub


text:
package cards;

import server.*;

import java.util.Collections;
import java.util.Set;

public class Embargo extends Card {

	@Override
	public String name() {
		return "Embargo";
	}

	@Override
	public Set<Type> types() {
		return types(Type.ACTION);
	}

	@Override
	public int cost() {
		return 2;
	}

	@Override
	public String[] description() {
		return new String[] {
				"<+2$>",
				"Trash this_card. Put an_Embargo token on_top_of a_Supply_pile.",
				"When a_player buys a_card, they_gain a_[Curse] card per_Embargo token on_that_pile."
		};
	}

	@Override
	public boolean onPlay(Player player, Game game, boolean hasMoved) {
		plusCoins(player, game, 2);
		boolean movedToTrash = false;
		if (!hasMoved) {
			// trash this
			game.messageAll("trashing the " + this.htmlNameRaw());
			player.removeFromPlay(this);
			game.trash(player, this);
			movedToTrash = true;
		}
		// put an embargo token on top of a supply pile
		Object pile = chooseEmbargoPile(player, game);
		if (pile instanceof Card) {
			Card card = (Card) pile;
			game.messageAll("putting an embargo token on the " + card.htmlName() + " pile");
			game.addEmbargoToken(card);
		} else if (pile instanceof Card.MixedPileId) {
			Card.MixedPileId id = (Card.MixedPileId) pile;
			game.messageAll("putting an embargo token on the " + id.toString() + " pile");
			game.addEmbargoToken(id);
		}
		return movedToTrash;
	}

	private Object chooseEmbargoPile(Player player, Game game) {
		if (player instanceof Bot) {
			Object pile = ((Bot) player).embargoPile(Collections.unmodifiableSet(game.supply.keySet()), Collections.unmodifiableSet(game.mixedPiles.keySet()));
			if (!((pile instanceof Card && game.supply.containsKey(pile)) ||
					(pile instanceof Card.MixedPileId && game.mixedPiles.containsKey(pile)))) {
				throw new IllegalStateException();
			}
			return pile;
		}
		return promptChoosePile(
		        player,
                game,
                Prompt.Type.NORMAL,
                this.toString() + ": Put an embargo token on a supply pile.",
                null
        );
	}

}


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.xinyou</groupId>
    <artifactId>frame</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <artifactId>frame-domain</artifactId>
  <dependencies>
  	<dependency>
  		<groupId>com.xinyou</groupId>
  		<artifactId>frame-util</artifactId>
  		<version>0.0.1-SNAPSHOT</version>
  	</dependency>
  	<dependency>
			<groupId>javax.ws.rs</groupId>
			<artifactId>jsr311-api</artifactId>
			<version>1.1.1</version>
		</dependency>
				<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
			<version>3.1</version>
		</dependency>
  </dependencies>
</project>


text:
![JDK 1.8](https://img.shields.io/badge/JDK-1.8-orange.png)
![Bukkit 1.9](https://img.shields.io/badge/Bukkit-1.9-blue.png)

MiniCmd is a command framework for Bukkit that allows plugin developers to implmenent commands into their plugins
dynamically, without having to register them in the `plugin.yml` file. The framework uses Bukkit's command preprocess
events to handle command executions without having to use Bukkit internals.

The user guide and a few examples can be found in the **Wiki**.

This project is published under the **New BSD License**.


text:
begin;
create function num_dirty(relid oid) returns bigint as
$$
   select count(*) from dirty_buffers()
     as (tablespace oid, database oid, relfilenode oid, block int)
     where relfilenode in
           (select relfilenode from pg_class
            where oid=$1);
$$ language sql;

-- Wait until number of dirty buffers for the specified relfiles drops
-- to 0 or timeout occurs.  Returns false if timeout occurred.
create function wait_for_bgwriter(
   relid oid,
   timeout int)
returns boolean as
$$
declare
   d bigint;
   i  int;
begin
   i := 0;
   loop
      select sum(num_dirty($1)) into d from gp_dist_random('gp_id');
      if (d = 0) then
         return true;
      end if;
      if i >= $2 then
         return false;
      end if;
      perform pg_sleep(.5);
      i := i + 1;
   end loop;
end;
$$ language plpgsql;

create table fsync_test1(a int, b int) distributed by (a);
create table fsync_test2(a int, b int) distributed by (a);
insert into fsync_test1 select i, i from generate_series(1,100)i;
insert into fsync_test2 select -i, i from generate_series(1,100)i;
end;

vacuum pg_proc;
-- Reset all faults.
--
-- NOTICE: important.
--
-- we use gp_inject_fault_infinite here instead of
-- gp_inject_fault so cache of pg_proc that contains
-- gp_inject_fault_infinite is loaded before checkpoint and
-- the following gp_inject_fault_infinite don't dirty the
-- buffer again.
select gp_inject_fault_infinite('all', 'reset', dbid) from gp_segment_configuration;

-- Start with a clean slate (no dirty buffers).
checkpoint;

-- Skip checkpoints.
select gp_inject_fault_infinite('checkpoint', 'skip', dbid)
from gp_segment_configuration where role = 'p' and content > -1;

-- Suspend bgwriter.
select gp_inject_fault_infinite('fault_in_background_writer_main', 'suspend', dbid)
from gp_segment_configuration where role = 'p' and content > -1;

-- Ensure no buffers are dirty before we start.
select * from dirty_buffers()
 as (tablespace oid, database oid, relfilenode oid, block int);
select dirty_buffers() from gp_dist_random('gp_id')
 as (tablespace oid, database oid, relfilenode oid, block int);

-- Make buffers dirty.  At least two relfiles must be sync'ed during
-- next checkpoint.
insert into fsync_test1 select i, i from generate_series(1,1000)i;
delete from fsync_test2;

-- Should return at least one dirty buffer.
select sum(num_dirty('fsync_test1'::regclass)) > 0 as passed
 from gp_dist_random('gp_id');
select sum(num_dirty('fsync_test2'::regclass)) > 0 as passed
 from gp_dist_random('gp_id');

-- Flush all dirty pages by BgBufferSync()
select gp_inject_fault_infinite('bg_buffer_sync_default_logic', 'skip', dbid)
from gp_segment_configuration where role = 'p' and content > -1;

-- Resume bgwriter.
select gp_inject_fault('fault_in_background_writer_main', 'resume', dbid)
from gp_segment_configuration where role = 'p' and content > -1;

-- Wait until bgwriter sweeps through and writes out dirty buffers.
-- The 10 indicates timeout in terms of number of iterations to be
-- executed by the waiting function.  Each iteration sleeps for .5
-- seconds.
select wait_for_bgwriter('fsync_test1'::regclass, 25) as passed;
select wait_for_bgwriter('fsync_test2'::regclass, 25) as passed;

-- Inject fault to count relfiles fsync'ed by checkpointer.
select gp_inject_fault_infinite('fsync_counter', 'skip', dbid)
from gp_segment_configuration where role = 'p' and content > -1;

-- Resume checkpoints.
select gp_inject_fault('checkpoint', 'reset', dbid)
from gp_segment_configuration where role = 'p' and content > -1;

checkpoint;

-- There should be no dirty buffers after checkpoint.
select dirty_buffers() from gp_dist_random('gp_id')
 as (tablespace oid, database oid, relfilenode oid, block int);

-- Validate that the number of files fsync'ed by checkpointer is at
-- least 2.  The two files fsync'ed should be corresponding to
-- fsync_test1 and fsync_test2 tables. `num times hit` is corresponding
-- to the number of files synced by `fsync_counter` fault type.
select gp_inject_fault('fsync_counter', 'status', 2::smallint);

-- Reset all faults.
select gp_inject_fault('all', 'reset', dbid) from gp_segment_configuration;


text:
'''In this example, we use the built-in property decorator to illustrate Python's approach to private variables and
'setters' & 'getters'. A getter is a method that is triggered when a program using a class attempts to access the value
of an object property. This trigger allows us to impose rules in regard to what must happen when this occurs. A setter
performs a similar function in respect of a request to change or 'set' a property's value. This also allows us to create
'virtual' properties that behave like real ones - area in this example.

Note the '@property' syntax for the getter. The setter uses '@variable_name.setter syntax.
'''
import math

class Circle(object):
    def __init__(self, radius):
        self.radius = radius

    @property
    def circumference(self):
        return 2 * math.pi * self._radius

    @property
    def area(self):
        return math.pi * self._radius ** 2

    @property
    def radius(self):
        return self._radius

    @radius.setter
    def radius(self, newval):
        if 0 < newval < 10:
            self._radius = newval
        else:
            self._radius = 1

    # Below is an alternative syntax. We write getradius and setradius to do the getting and setting as opposed to
    # defining methods with the same name as the property and wrapping them.
    #
    # def getradius(self):
    #     return self._radius
    # def setradius(self, newval):
    #     if 0 < newval < 10:
    #         self._radius = newval
    #     else:
    #         self._radius = 1
    #
    # radius = property(fget=getradius, fset=setradius)

my_circle1 = Circle(99)
my_circle2 = Circle(4)

print("RAD: {}, AREA: {} CIRCUM: {}".format(my_circle1.radius, my_circle1.area, my_circle1.circumference))
print("RAD: {}, AREA: {} CIRCUM: {}".format(my_circle2.radius, my_circle2.area, my_circle2.circumference))

my_circle2.radius = 5
print("RAD: {}, AREA: {} CIRCUM: {}".format(my_circle2.radius, my_circle2.area, my_circle2.circumference))


text:
/**
 * @flow
 */

function functionFoo3(x: number): number { return x; }

module.exports = functionFoo3;


text:
"""Stub module for reading plist string XML."""

import plistlib
import xml.parsers.expat

class Error(Exception):
  """Class for domain specific exceptions."""

class ApplePlist(object):
  """Stub class for parsing a plist string."""

  def __init__(self, str_xml):
    self._xml = str_xml
    self.plist = None

  def Parse(self):
    try:
      self.plist = plistlib.readPlistFromString(self._xml)
    except xml.parsers.expat.ExpatError as e:
      raise Error(str(e))

  def GetContents(self):
    return self.plist


text:
package org.lumongo.ui.client.charting.options;

public enum ZoomType {
	NONE(""),
	X("x"),
	Y("y"),
	XY("xy");

	private final String name;

	ZoomType(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}
}


text:
\documentclass[11pt, a4paper]{report}  % article, report, book

\usepackage{ifthen}
\newboolean{draft}

\input{Config.methods}

% Recommended for XeLaTeX
  \usepackage{fontspec}
  \usepackage{xltxtra}

% Typography
  \usepackage[notext, light]{kpfonts}
  \mathversion{rm}
  \setmainfont[
    Mapping=tex-text,
    Ligatures={Common},
    ItalicFont={Source Sans Pro Light Italic},
    BoldFont={Source Sans Pro},
    BoldItalicFont={Source Sans Pro Italic}]{Source Sans Pro Light}
  \setmonofont[Mapping=tex-text, Scale=0.85]{Source Code Pro ExtraLight}
  %\usepackage{unicode-math}  % needed for setmathfont
  %\setmathfont{STIX Math}
  \usepackage{microtype}

% Layout. http://de.wikipedia.org/wiki/Normseite
  %\usepackage{multicol}
  %\usepackage[a4paper]{geometry}
  %\usepackage{stdpage}

% Global \noindent
  \setlength\parindent{0pt}

% Vertical Line Spacing
  \usepackage{setspace}
  \onehalfspacing

% Language
  \usepackage{polyglossia}
  \setdefaultlanguage[latesthyphen=true]{german}
  \setotherlanguage{english}

% Hyphenation
  \tolerance=0
  \emergencystretch=\maxdimen
  \hyphenpenalty=0
  \hbadness=0

% Biblography Style: \citet{}, \citep[][]{}
  \usepackage{natbib}  % Info: http://merkel.zoneo.net/Latex/natbib.php

% Glossary: (Listed in Table of Contents)
  \usepackage[toc, nonumberlist]{glossaries}
  \makeglossaries

% Colors
  \usepackage[svgnames]{xcolor}

% For macro: \url{}
  \usepackage[hyphens]{url}

% Caption options (left align)
  \usepackage[
    justification=justified,
    singlelinecheck=false,
    font=footnotesize,
    labelfont=bf,
    textfont=singlespacing,
    indention=.5cm]{caption}

% Make inlike Multicolum pages
  \usepackage{multicol}

% Marginal Note: \mpar{A note} (http://de.wikibooks.org/wiki/LaTeX-Wörterbuch:_marginpar)
  \newcommand\mpar[1]{\marginpar {\flushleft\footnotesize #1}}
  \setlength{\marginparwidth}{3cm}

% PDF with Links
  \usepackage[
    colorlinks=false,
    urlcolor=black,
    bookmarks=true,
    unicode=false,
    pdfencoding=auto
    pdfstartview=FitH]{hyperref}
  \hypersetup{
    pdftitle={\thema},
    pdfauthor={\autor},
    pdfsubject={\subtitle},
    pdfkeywords={\keywords}
  }

% TODO Annotations: \todo{Whats to do...}
  \usepackage{todonotes}

% Enumerations with pattern
  \usepackage{paralist}

% Listings
  \usepackage{listings}

  \lstset{
    frame=tb,
    language=bash,  % default language
    aboveskip=3mm,
    belowskip=3mm,
    showstringspaces=false,
    columns=flexible,
    basicstyle={\fontsize{9}{10}\ttfamily},
    numbers=left,
    numberstyle=\tiny\color{gray},
    keywordstyle=\color{blue},
    commentstyle=\color{dkgreen},
    stringstyle=\color{mauve},
    frame=single,
    breaklines=true,
    breakatwhitespace=true,
    tabsize=2,
    extendedchars=\true,
    inputencoding=utf8,
    escapeinside={\%*}{*)}  % http://tex.stackexchange.com/questions/24528/
  }

  \definecolor{dkgreen}{rgb}{0,0.6,0}
  \definecolor{gray}{rgb}{0.5,0.5,0.5}
  \definecolor{mauve}{rgb}{0.58,0,0.82}

  \lstdefinelanguage{Scala}{
    morekeywords={abstract,case,catch,class,def,
      do,else,extends,false,final,finally,
      for,if,implicit,import,match,mixin,
      new,null,object,override,package,
      private,protected,requires,return,sealed,
      super,this,throw,trait,true,try,
      type,val,var,while,with,yield},
    otherkeywords={=>,<-,<\%,<:,>:,\#,@},
    sensitive=true,
    morecomment=[l]{//},
    morecomment=[n]{/*}{*/},
    morestring=[b]",
    morestring=[b]',
    morestring=[b]"""
  } % http://tihlde.org/~eivindw/latex-listings-for-scala/

  \lstdefinelanguage{JavaScript}{
    keywords={
      typeof, new, true, false, catch, function, return, null,
      catch, switch, var, if, in, while, do, else, case, break
    },
    ndkeywords={class, export, boolean, throw, implements, import, this},
    sensitive=false,
    comment=[l]{//},
    morecomment=[s]{/*}{*/},
    morestring=[b]',
    morestring=[b]"
  } % http://lenaherrmann.net/2010/05/20/javascript-syntax-highlighting-in-the-latex-listings-package


text:
+ Edit the config.json file to setup a build environment, the keywords are as
    follows:
  * name: Name of the project to be created ex: "project"
  * build\_dir: Output directory of the project ex: "build"
  * device: Device part number ex: "xc6slx9-tqg144-3"
  * verilog: A list of verilog files or paths
      - If the entry is a directory then all items in the diretory will be added
      - If the "recursive" flag is set to true then it will also be recusively
        searched
  * top\_module: Top verilog module in the project
  * constraint\_files: List of constraint files to be used
  * coregen: Settings for coregen
      - flags: Flags that can be set for the coregen, any flag specified by
    the user will override the default values set in
  * xst: Setting for xst synthesizer
      - flags: Flags that can be set for the synthesizer, any flag specified
        by the user will override the default values set in
        site_scons/xst_default_flags.json
  * ngdbuild: Settings for ngdbuild translator
      - flags: Flags that can be set for the translator, any flag specified
        by the user will override the default values set in
        site_scons/ngd_default_flags.json
  * map: Settings for map
      - flags: Flags that can be set for the translator, any flag specified
        by the user will override the default values set in
        site_scons/map_default_flags.json
  * par: Settings for place and route
      - flags: Flags that can be set for the translator, any flag specified
        by the user will override the default values set in
        site_scons/par_default_flags.json
  * trce: Settings for trace timing analysis
      - flags: Flags that can be set for the translator, any flag specified
        by the user will override the default values set in
        site_scons/trace_default_flags.json
  * bitgen: Settings for bitgen
      - flags: Flags that can be set for the translator, any flag specified
        by the user will override the default values set in
        site_scons/bitgen_default_flags.json
      - configuration: Override the default configuration, any value set in
        this block will override the default vlues set in
        site_scons/bitgen_configuration.json

  * ***NOTE:*** by setting a flag to "\_true" then the flag will be inserted as
  a standalone flag: eg "-my\_flag":"\_true" will show up as:
  ...-my\_flag... for the tool, NOT ...-my\_flag \_true...
  * ***NOTE:*** Do not specify a flag to allow the default flags to override
  (the default flags can be viewed in site\_scons/??\_default\_flags.json)
  * ***NOTE:*** Setting a flag to blank will override the default flag with
  nothing

+ Build the project by typing either 'scons' to build all targets or scons
  plus a Target (listed below)

##Command Line Options:

###Targets:
  * cores: generate cores in the cores directory (cores -> .ngc)
  * xst: synthesize (verilog, [cores]) -> .ncd
  * ngd\_build: netlist translation (from abstract constructs to Xilinx
      specific constructs)
      (.ngc -> .ngd)
  * map: mapping the xilinx specific netlist (logical design) into the
      specified xilinx component (using slices, BRAMs, and I/Os)
      (.ngd -> .ncd)
  * par: place and route the component within the FPGA
      (.ncd -> _par.ncd)
  * bitgen: generating a bit file that can be downloaded to the FPGA
      (_par.ncd -> .bit)
  * trace: analyzing the design for timing violations
      (_par.ncd -> .twr)

###Flags:
  * --debug\_build: view debug messages helpful to debug the builder
  * --config\_file: specify a different configuration file than 'config.json'
  * --clean\_build: remove all directories create by the build process
                    config["build\_dir"] directory
                    _xmsgs directory
  * --clean\_cores: clean the cores, cores take a long time to build so it
                    doesn't make sense to rebuild them every run so unless
                    explicitly declared the default clean (scons -c) scons
                    will not remove the generated cores

* * *
##Notes About Cores:
Cores are very useful and can add a lot of functionality to code here is how
to use them in this build environment.

Use Coregen GUI to generate your core. It's alright if the part number/family
doesn't match up with the final build the build tool will fix this (Just make
sure that your device can accomodate the core, i.e. don't put a PCIE core
on a spartan 3)

After coregen generates your core copy the (core\_name).xco (as is) to the
'cores' directory. copy the (core\_name).v file to the rtl directory. This is
the interface to your core. It looks strange becaus the sythesis implementation
only declares ports and parameters but this is like a header file in c where
the synthesizer will know to look for an NGC file created by coregen to
attach the backend of that module to.

For example if you generated a complex multiplier for use with a
xc6slx4-tgq144-2 part and you are currently building for a xc6slx9-tqg144-3
part the tool will fix the necessary project settings and generate your core.

###Example:
If you named the complex multiplier cm in coregen, it will output
a lot of files two of them being cm.xco and cm.v. Put cm.xco in the 'cores'
directory and cm.v in the 'rtl' directory.

* * *

##To Do:

  [\_] Add support for vhdl
  [x] Add Support for SmartGuide (reusing previous builds to speed up new
      builds)
  [\_] Add support for multiple verilog/VHDL libraries
  [x] Add support for cores
  [\_] Add support for bmm
  [\_] Test build environment on 32-bit Linux Box
  [\_] Test build environment on 32-bit Windows Box
  [\_] Test build environemnt on 64-bit Windows Box


text:
<?php declare(strict_types=1);

namespace Monolog\Handler;

use Monolog\Logger;
use Monolog\Formatter\NormalizerFormatter;
use Monolog\Formatter\FormatterInterface;

/**
 * Class to record a log on a NewRelic application.
 * Enabling New Relic High Security mode may prevent capture of useful information.
 *
 * @see https://docs.newrelic.com/docs/agents/php-agent
 * @see https://docs.newrelic.com/docs/accounts-partnerships/accounts/security/high-security
 */
class NewRelicHandler extends AbstractProcessingHandler
{
    /**
     * Name of the New Relic application that will receive logs from this handler.
     *
     * @var string
     */
    protected $appName;

    /**
     * Name of the current transaction
     *
     * @var string
     */
    protected $transactionName;

    /**
     * Some context and extra data is passed into the handler as arrays of values. Do we send them as is
     * (useful if we are using the API), or explode them for display on the NewRelic RPM website?
     *
     * @var bool
     */
    protected $explodeArrays;

    /**
     * {@inheritDoc}
     *
     * @param string $appName
     * @param bool   $explodeArrays
     * @param string $transactionName
     */
    public function __construct(
        $level = Logger::ERROR,
        $bubble = true,
        $appName = null,
        $explodeArrays = false,
        $transactionName = null
    ) {
        parent::__construct($level, $bubble);

        $this->appName       = $appName;
        $this->explodeArrays = $explodeArrays;
        $this->transactionName = $transactionName;
    }

    /**
     * {@inheritDoc}
     */
    protected function write(array $record)
    {
        if (!$this->isNewRelicEnabled()) {
            throw new MissingExtensionException('The newrelic PHP extension is required to use the NewRelicHandler');
        }

        if ($appName = $this->getAppName($record['context'])) {
            $this->setNewRelicAppName($appName);
        }

        if ($transactionName = $this->getTransactionName($record['context'])) {
            $this->setNewRelicTransactionName($transactionName);
            unset($record['formatted']['context']['transaction_name']);
        }

        if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) {
            newrelic_notice_error($record['message'], $record['context']['exception']);
            unset($record['formatted']['context']['exception']);
        } else {
            newrelic_notice_error($record['message']);
        }

        if (isset($record['formatted']['context']) && is_array($record['formatted']['context'])) {
            foreach ($record['formatted']['context'] as $key => $parameter) {
                if (is_array($parameter) && $this->explodeArrays) {
                    foreach ($parameter as $paramKey => $paramValue) {
                        $this->setNewRelicParameter('context_' . $key . '_' . $paramKey, $paramValue);
                    }
                } else {
                    $this->setNewRelicParameter('context_' . $key, $parameter);
                }
            }
        }

        if (isset($record['formatted']['extra']) && is_array($record['formatted']['extra'])) {
            foreach ($record['formatted']['extra'] as $key => $parameter) {
                if (is_array($parameter) && $this->explodeArrays) {
                    foreach ($parameter as $paramKey => $paramValue) {
                        $this->setNewRelicParameter('extra_' . $key . '_' . $paramKey, $paramValue);
                    }
                } else {
                    $this->setNewRelicParameter('extra_' . $key, $parameter);
                }
            }
        }
    }

    /**
     * Checks whether the NewRelic extension is enabled in the system.
     *
     * @return bool
     */
    protected function isNewRelicEnabled()
    {
        return extension_loaded('newrelic');
    }

    /**
     * Returns the appname where this log should be sent. Each log can override the default appname, set in this
     * handler's constructor, by providing the appname in it's context.
     *
     * @param  array       $context
     * @return null|string
     */
    protected function getAppName(array $context)
    {
        if (isset($context['appname'])) {
            return $context['appname'];
        }

        return $this->appName;
    }

    /**
     * Returns the name of the current transaction. Each log can override the default transaction name, set in this
     * handler's constructor, by providing the transaction_name in it's context
     *
     * @param array $context
     *
     * @return null|string
     */
    protected function getTransactionName(array $context)
    {
        if (isset($context['transaction_name'])) {
            return $context['transaction_name'];
        }

        return $this->transactionName;
    }

    /**
     * Sets the NewRelic application that should receive this log.
     *
     * @param string $appName
     */
    protected function setNewRelicAppName($appName)
    {
        newrelic_set_appname($appName);
    }

    /**
     * Overwrites the name of the current transaction
     *
     * @param string $transactionName
     */
    protected function setNewRelicTransactionName($transactionName)
    {
        newrelic_name_transaction($transactionName);
    }

    /**
     * @param string $key
     * @param mixed  $value
     */
    protected function setNewRelicParameter($key, $value)
    {
        if (null === $value || is_scalar($value)) {
            newrelic_add_custom_parameter($key, $value);
        } else {
            newrelic_add_custom_parameter($key, @json_encode($value));
        }
    }

    /**
     * {@inheritDoc}
     */
    protected function getDefaultFormatter(): FormatterInterface
    {
        return new NormalizerFormatter();
    }
}


text:
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Trans. Am. phil. Soc. , New Series 4(2): 154 (1832)

#### Original name
Polyporus connatus Weinm., 1826

### Remarks
null


text:
export function IdentityService() {
	const isLocal: boolean = location.hostname === "localhost" || location.hostname === "127.0.0.1";
	return isLocal ? "http://localhost:3000" : "https://identity.sailing-channels.com";
}

export function DataService() {
	const isLocal: boolean = location.hostname === "localhost" || location.hostname === "127.0.0.1";
	return isLocal ? "http://localhost:5000" : "https://data.sailing-channels.com";
}


text:
//all: test

//test: test.cc download.cc download.h curl_duplex.h logging.cc logging.h logging-internal.h smalloc.h smalloc.c compression.c compression.h zlib-duplex.h sha1.c sha1.h debug.c debug.h hash.cc hash.h md5.h cvmfs_config.h util.cc util.h compat.h compat_linux.h compat_macosx.h
//        gcc -c -O2 smalloc.c
//        gcc -c -O2 compression.c
//        gcc -c -O2 sha1.c
//        gcc -c -O2 debug.c
//        g++ -g -Wall -D_BUILT_IN_LIBCURL -DDEBUGMSG -O0 -o test test.cc download.cc util.cc logging.cc hash.cc sha1.o debug.o compression.o smalloc.o curl-7.24.0/lib/.libs/libcurl.a ../V2_1/build/externals/c-ares/src/.libs/libcares.a -lz -lssl -lrt

#include <unistd.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>

#include <cassert>
#include <cstdio>
#include <cstring>

#include <string>
#include <vector>

#include "download.h"
#include "logging.h"
#include "hash.h"
#include "util.h"

extern "C" {
#include "smalloc.h"
}

using namespace std;

static void Run() {
  LogCvmfs(kLogDownload, kLogStdout, "Downloading file into path");
  string url_published = "http://cvmappi10.cern.ch/opt/atlas/.cvmfspublished";
  string destination = "/tmp/testdownload";
  download::JobInfo info(&url_published,  false, false, &destination, NULL);
  int retval = download::Fetch(&info);
  assert(retval == download::kFailOk);

  LogCvmfs(kLogDownload, kLogStdout, "Downloading file into file");
  info.destination = download::kDestinationFile;
  info.destination_file = fopen("/tmp/testdownload.file", "w+");
  retval = download::Fetch(&info);
  assert(retval == download::kFailOk);
  assert(fclose(info.destination_file) == 0);

  LogCvmfs(kLogDownload, kLogStdout, "Downloading file into memory");
  info.destination = download::kDestinationMem;
  retval = download::Fetch(&info);
  assert(retval == download::kFailOk);

  LogCvmfs(kLogDownload, kLogStdout, "Compare");
  void *compare = smalloc(info.destination_mem.size);
  FILE *f = fopen("/tmp/testdownload", "r");
  assert(f);
  assert(fread(compare, 1, info.destination_mem.size, f) ==
         info.destination_mem.size);
  assert(memcmp(compare, info.destination_mem.data, info.destination_mem.size)
         == 0);
  fclose(f);
  f = fopen("/tmp/testdownload.file", "r");
  assert(fread(compare, 1, info.destination_mem.size, f) ==
         info.destination_mem.size);
  assert(memcmp(compare, info.destination_mem.data, info.destination_mem.size)
         == 0);

  fclose(f);
  free(info.destination_mem.data);
  info.destination_mem.data = NULL;

  LogCvmfs(kLogDownload, kLogStdout, "Unsupported Protocol");
  string unsupported_url = "https://cvmappi10.cern.ch/opt/atlas/.cvmfspublished";
  info.url = &unsupported_url;
  retval = download::Fetch(&info);
  assert(retval == download::kFailBadUrl);

  //  LogCvmfs(kLogDownload, kLogStdout, "Bad URL");
  //  info.url = "blablabla";
  //  retval = download::Fetch(&info);
  //  assert(retval == download::kFailBadUrl);

  LogCvmfs(kLogDownload, kLogStdout, "Decompression Failure (Memory)");
  string url = "http://cvmappi10.cern.ch/opt/atlas/.cvmfspublished";
  info.url = &url;
  info.compressed = true;
  retval = download::Fetch(&info);
  assert(retval == download::kFailBadData);

  LogCvmfs(kLogDownload, kLogStdout, "Decompression Failure (File)");
  info.destination = download::kDestinationPath;
  retval = download::Fetch(&info);
  assert(retval == download::kFailBadData);

  /*LogCvmfs(kLogDownload, kLogStdout, "Decompression");
  info.compressed = false;
  info.destination = download::kDestinationMem;
  retval = download::Fetch(&info);
  assert(retval == download::kFailOk);
  string hash(((char *)info.destination_mem.data)+1, 40);
  string caturl = "http://cvmappi10.cern.ch/opt/atlas/data/" +
                  hash.substr(0, 2) + "/" + hash.substr(2) + "C";
  info.url = &caturl;
  info.compressed = true;
  info.destination = download::kDestinationPath;
  hash::t_sha1 sha1;
  sha1.from_hash_str(hash);
  info.expected_hash = &sha1;
  retval = download::Fetch(&info);
  assert(retval == download::kFailOk);

  LogCvmfs(kLogDownload, kLogStdout, "Hash verification failure");
  hash::t_sha1 sha1_null;
  info.expected_hash = &sha1_null;
  retval = download::Fetch(&info);
  assert(retval == download::kFailBadData);*/
}

void *MultiThreadedRun(void *data) {
  LogCvmfs(kLogDownload, kLogStdout, "Running thread %p", pthread_self());
  string url_published = "http://cvmappi10.cern.ch/opt/atlas/.cvmfspublished";
  download::JobInfo info(&url_published, false, false, NULL);
  for (int i = 0; i < 1000; ++i) {
    LogCvmfs(kLogDownload, kLogStdout, "Downloading file into memory");
    int retval = download::Fetch(&info);
    assert(retval == download::kFailOk);
    free(info.destination_mem.data);
    info.destination_mem.data = NULL;
  }

  return NULL;
}

void *ThreadDnsSink(void *data) {
  const int MSGBUFSIZE = 512;
  int fd_recv;
  struct sockaddr_in addr_this;
  int retval;

  fd_recv = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
  assert(fd_recv >= 0);

  memset(&addr_this, 0, sizeof(addr_this));
  addr_this.sin_family = AF_INET;
  addr_this.sin_addr.s_addr = inet_addr("127.0.0.1");
  addr_this.sin_port = htons(53);

  retval = bind(fd_recv, (struct sockaddr *)&addr_this, sizeof(addr_this));
  assert(retval == 0);

  char msgbuf[MSGBUFSIZE];
  struct sockaddr_in addr_sender;
  socklen_t addr_sender_len = sizeof(addr_sender);
  int nbytes;
  LogCvmfs(kLogDownload, kLogStdout, "Starting DNS Sink");
  while (1) {
    nbytes = recvfrom(fd_recv, msgbuf, MSGBUFSIZE-1, 0,
                      (struct sockaddr *)&addr_sender, &addr_sender_len);
    if (nbytes < 0)
      break;

    if (nbytes > 0)
    {
      msgbuf[nbytes] = 0;
      LogCvmfs(kLogDownload, kLogStdout, "DNS sink received %s", msgbuf);
    } else {
      LogCvmfs(kLogDownload, kLogStdout, "DNS sink received 0 bytes", msgbuf);
    }
  }

  return NULL;
}

void *ThreadHttpConnectSink(void *data) {
  const int MSGBUFSIZE = 512;
  int fd_recv;
  struct sockaddr_in addr_this;
  int retval;

  fd_recv = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  assert(fd_recv >= 0);

  memset(&addr_this, 0, sizeof(addr_this));
  addr_this.sin_family = AF_INET;
  addr_this.sin_addr.s_addr = inet_addr("127.0.0.1");
  addr_this.sin_port = htons(80);

  retval = bind(fd_recv, (struct sockaddr *)&addr_this, sizeof(addr_this));
  assert(retval == 0);

  retval = listen(fd_recv, 1);
  assert(retval == 0);

  char msgbuf[MSGBUFSIZE];
  struct sockaddr_in addr_sender;
  socklen_t addr_sender_len = sizeof(addr_sender);
  int nbytes;
  LogCvmfs(kLogDownload, kLogStdout, "Starting Http Connect Sink");
  while (1) {
    nbytes = recvfrom(fd_recv, msgbuf, MSGBUFSIZE-1, 0,
                      (struct sockaddr *)&addr_sender, &addr_sender_len);
    if (nbytes < 0)
      break;

    if (nbytes > 0)
    {
      msgbuf[nbytes] = 0;
      LogCvmfs(kLogDownload, kLogStdout, "Http connect sink received %s", msgbuf);
    } else {
      LogCvmfs(kLogDownload, kLogStdout, "Http connect sink received 0 bytes", msgbuf);
    }
  }

  return NULL;
}

void *ThreadHttpSink(void *data) {
  const int MSGBUFSIZE = 512;
  int fd_recv;
  struct sockaddr_in addr_this;
  int retval;

  fd_recv = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  assert(fd_recv >= 0);

  memset(&addr_this, 0, sizeof(addr_this));
  addr_this.sin_family = AF_INET;
  addr_this.sin_addr.s_addr = inet_addr("127.0.0.1");
  addr_this.sin_port = htons(81);

  retval = bind(fd_recv, (struct sockaddr *)&addr_this, sizeof(addr_this));
  assert(retval == 0);

  retval = listen(fd_recv, 1);
  assert(retval == 0);

  struct sockaddr sender;
  socklen_t address_len;

  LogCvmfs(kLogDownload, kLogStdout, "Starting Http Sink");
  while (1) {
    int conn_fd = accept(fd_recv, &sender, &address_len);
    assert(conn_fd >= 0);

    LogCvmfs(kLogDownload, kLogStdout, "New connection Sink");

    char msgbuf[MSGBUFSIZE];
    int nbytes;
    nbytes = read(conn_fd, msgbuf, MSGBUFSIZE-1);
    if (nbytes < 0)
      break;

    if (nbytes > 0)
    {
      msgbuf[nbytes] = 0;
      LogCvmfs(kLogDownload, kLogStdout, "Http sink received %s", msgbuf);
    } else {
      LogCvmfs(kLogDownload, kLogStdout, "Http sink received 0 bytes", msgbuf);
    }
  }

  return NULL;
}

void TestTimeout() {
  LogCvmfs(kLogDownload, kLogStdout, "DNS Timeout");
  string url = "http://cvmappi10.cern.ch/opt/atlas/.cvmfspublished";
  download::JobInfo info(&url, false, false, NULL);
  time_t start = time(NULL);
  int retval = download::Fetch(&info);
  time_t end = time(NULL);
  assert((retval == download::kFailHostConnection) && (end-start < 2));

  /*LogCvmfs(kLogDownload, kLogStdout, "Access by IP");
  string url_ip = "http://137.138.234.36/opt/atlas/.cvmfspublished";
  info.url = &url_ip;
  retval = download::Fetch(&info);
  assert(retval == download::kFailOk);*/

  LogCvmfs(kLogDownload, kLogStdout, "Http Connection Timeout");
  string url_local = "http://127.0.0.1/opt/atlas/.cvmfspublished";
  info.url = &url_local;
  start = time(NULL);
  retval = download::Fetch(&info);
  end = time(NULL);
  assert((retval == download::kFailHostConnection) && (end-start < 3));

  LogCvmfs(kLogDownload, kLogStdout, "Http Timeout");
  url_local = "http://127.0.0.1:81/opt/atlas/.cvmfspublished";
  start = time(NULL);
  retval = download::Fetch(&info);
  end = time(NULL);
  assert((retval == download::kFailHostConnection) && (end-start < 3));

  LogCvmfs(kLogDownload, kLogStdout, "Proxy Connection Timeout");
  download::SetProxyChain("http://127.0.0.1:80");
  start = time(NULL);
  retval = download::Fetch(&info);
  end = time(NULL);
  assert((retval == download::kFailProxyConnection) && (end-start < 3));

  LogCvmfs(kLogDownload, kLogStdout, "Proxy Timeout");
  download::SetProxyChain("http://127.0.0.1:81");
  start = time(NULL);
  retval = download::Fetch(&info);
  end = time(NULL);
  assert((retval == download::kFailProxyConnection) && (end-start < 3));
}

void TestFailureHandling() {
  int retval;
  //LogCvmfs(kLogDownload, kLogStdout, "Bad Data");
  string url = "http://cvmappi10.cern.ch/opt/atlas/.cvmfspublished";
  hash::t_sha1 sha1;
  download::JobInfo info(&url, false, false, &sha1);
  retval = download::Fetch(&info);
  assert((retval == download::kFailBadData) && (info.nocache));

  LogCvmfs(kLogDownload, kLogStdout, "Switch Host");
  url = "/opt/atlas/.cvmfspublished";
  info.expected_hash = NULL;
  info.probe_hosts = true;
  download::SetHostChain("http://A;http://cvmappi10.cern.ch");
  retval = download::Fetch(&info);
  assert((retval == download::kFailOk) &&
         (info.num_failed_hosts == 1) && (info.num_failed_proxies == 0));

  LogCvmfs(kLogDownload, kLogStdout, "Switch Host Full");
  download::SetHostChain("http://A;http://B");
  retval = download::Fetch(&info);
  assert((retval == download::kFailHostConnection) &&
         (info.num_failed_hosts == 2) && (info.num_failed_proxies == 0));

  LogCvmfs(kLogDownload, kLogStdout, "Switch Proxy");
  download::SetProxyChain("http://A;http://B;http://C|http://D");
  retval = download::Fetch(&info);
  assert((retval == download::kFailProxyConnection) &&
         (info.num_failed_hosts == 0) && (info.num_failed_proxies == 4));

  download::SetHostChain("http://cvmappi10.cern.ch");
  download::SetProxyChain("http://cmst0frontier.cern.ch:3128");
  retval = download::Fetch(&info);
  assert(retval == download::kFailProxyConnection);

  download::SetHostChain("http://cvmfs-stratum-one.cern.ch");
  download::SetProxyChain("http://cmst0frontier.cern.ch:3128|http://ca-proxy.cern.ch:3128");
  retval = download::Fetch(&info);
  assert(retval == download::kFailOk);

  //download::SetHostChain("http://A;http://cvmfs-stratum-one.cern.ch");
  //download::SetProxyChain("http://cmst0frontier.cern.ch:3128|http://ca-proxy.cern.ch:3128");
  //retval = download::Fetch(&info);
  //assert(retval == download::kFailOk);
}

void ShowProxies(const vector< vector<string> > &chain,
                 const unsigned lb_group)
{
  for (unsigned i = 0; i < chain.size(); ++i) {
    LogCvmfs(kLogDownload, kLogStdout, "Group %u: %s",
             i, join_strings(chain[i], ", ").c_str());
  }
  LogCvmfs(kLogDownload, kLogStdout, "Current group: %u", lb_group);
}

void ShowHosts(const vector<string> &chain, const vector<int> &rtt,
               const unsigned active)
{
  for (unsigned i = 0; i < chain.size(); ++i) {
    LogCvmfs(kLogDownload, kLogStdout, "Host %u (%d): %s",
             i, rtt[i], chain[i].c_str());
  }
  LogCvmfs(kLogDownload, kLogStdout, "Current host: %s", chain[active].c_str());
}

int main() {

  pthread_t dns_sink;
  int retval = pthread_create(&dns_sink, NULL, ThreadDnsSink, NULL);
  assert(retval == 0);
  pthread_t http_connect_sink;
  retval = pthread_create(&http_connect_sink, NULL, ThreadHttpConnectSink, NULL);
  assert(retval == 0);
  pthread_t http_sink;
  retval = pthread_create(&http_sink, NULL, ThreadHttpSink, NULL);
  assert(retval == 0);

  download::Init(32);

  TestFailureHandling();
  download::SetProxyChain("");
  download::SetHostChain("");
  Run();
  TestFailureHandling();

  download::Spawn();
  download::SetProxyChain("");
  download::SetHostChain("");
  TestFailureHandling();
  download::SetProxyChain("");
  download::SetHostChain("");

  Run();

  MultiThreadedRun(NULL);

  const int num_workers = 32;
  pthread_t workers[num_workers];
  for (int i = 0; i < num_workers; ++i) {
    pthread_create(&workers[i], NULL, MultiThreadedRun, NULL);
  }
  for (int i = 0; i < num_workers; ++i) {
    pthread_join(workers[i], NULL);
  }

  LogCvmfs(kLogDownload, kLogStdout, "Transferred %ld bytes",
           download::GetTransferredBytes());
  LogCvmfs(kLogDownload, kLogStdout, "Transfer time: %ld",
           download::GetTransferTime());
  LogCvmfs(kLogDownload, kLogStdout, "Kb/s: %ld",
           (download::GetTransferredBytes()/1024)/download::GetTransferTime());
  download::Fini();

  download::Init(10);
  LogCvmfs(kLogDownload, kLogStdout, "Setting / Switching Proxy Servers");
  vector< vector<string> > proxy_chain;
  unsigned current_group;
  download::SetProxyChain("A");
  download::GetProxyInfo(&proxy_chain, &current_group);
  ShowProxies(proxy_chain, current_group);
  download::SetProxyChain("A;B;C");
  download::GetProxyInfo(&proxy_chain, &current_group);
  ShowProxies(proxy_chain, current_group);
  download::SetProxyChain("A|B|C");
  download::GetProxyInfo(&proxy_chain, &current_group);
  ShowProxies(proxy_chain, current_group);
  download::SetProxyChain(";;;");
  download::GetProxyInfo(&proxy_chain, &current_group);
  ShowProxies(proxy_chain, current_group);
  download::SetProxyChain(";||;");
  download::GetProxyInfo(&proxy_chain, &current_group);
  ShowProxies(proxy_chain, current_group);
  download::SetProxyChain("A|B|C;D|E");
  download::GetProxyInfo(&proxy_chain, &current_group);
  ShowProxies(proxy_chain, current_group);
  download::SwitchProxyGroup();
  download::GetProxyInfo(&proxy_chain, &current_group);
  ShowProxies(proxy_chain, current_group);
  download::RebalanceProxies();
  download::GetProxyInfo(&proxy_chain, &current_group);
  ShowProxies(proxy_chain, current_group);
  download::RebalanceProxies();
  download::GetProxyInfo(&proxy_chain, &current_group);
  ShowProxies(proxy_chain, current_group);
  download::RebalanceProxies();
  download::GetProxyInfo(&proxy_chain, &current_group);
  ShowProxies(proxy_chain, current_group);
  download::SetProxyChain("");

  LogCvmfs(kLogDownload, kLogStdout, "Probing / Switching Hosts");
  vector<string> host_chain;
  vector<int> rtt;
  unsigned active_host;
  download::SetHostChain("A;B;C");
  download::GetHostInfo(&host_chain, &rtt, &active_host);
  ShowHosts(host_chain, rtt, active_host);
  download::ProbeHosts();
  download::GetHostInfo(&host_chain, &rtt, &active_host);
  ShowHosts(host_chain, rtt, active_host);
  download::SetHostChain("http://cvmfs-stratum-one.cern.ch/opt/atlas;http://cvmfs-stratum-zero.cern.ch/opt/atlas");
  download::ProbeHosts();
  download::GetHostInfo(&host_chain, &rtt, &active_host);
  ShowHosts(host_chain, rtt, active_host);
  download::SwitchHost();
  download::GetHostInfo(&host_chain, &rtt, &active_host);
  ShowHosts(host_chain, rtt, active_host);
  download::Fini();

  download::Init(10);
  download::SetTimeout(1, 1);
  download::SetDnsServer("127.0.0.1");
  TestTimeout();
  download::Spawn();
  download::SetProxyChain("");
  download::SetHostChain("");
  TestTimeout();
  download::Fini();

  unlink("/tmp/testdownload");
  unlink("/tmp/testdownload.file");

  return 0;
}


text:
import { executableBuilder } from '../utils/executable'

const IS_VUE = process.argv.some(arg => arg === 'vue')
const [party = 'uxc'] = process.argv
  .filter(arg => /^--party=/.test(arg))
  .map(party => party.replace(/^--party=/, ''))

const framework = IS_VUE ? 'vue' : 'react'
const executable = executableBuilder('sites')
executable.run(`start dev:${party}-${framework}`).catch(console.error)


text:
comicsansfy
============

Make your web more friendly


text:
static int do_overload_value(const uint8_t *buf, size_t blen, int overload)
{
    size_t i = 0;
    while (i < blen) {
        if (buf[i] == DCODE_PADDING) {
            ++i;
            continue;
        }
        if (buf[i] == DCODE_END)
            break;
        if (i + 2 >= blen)
            break;
        if (buf[i] == DCODE_OVERLOAD) {
            if (buf[i+1] == 1) {
                overload |= buf[i+2];
                i += 3;
                continue;
            }
        }
        i += buf[i+1] + 2;
    }
    return overload;
}

static int overload_value(const struct dhcpmsg * const packet)
{
    int ol = do_overload_value(packet->options, sizeof packet->options, 0);
    if (ol & 1 && ol & 2)
        return ol;
    if (ol & 1) {
        ol |= do_overload_value(packet->file, sizeof packet->file, ol);
        return ol;
    }
    if (ol & 2) {
        ol |= do_overload_value(packet->sname, sizeof packet->sname, ol);
        return ol;
    }
    return ol; // ol == 0
}

static void do_get_dhcp_opt(const uint8_t *sbuf, size_t slen, uint8_t code,
                            uint8_t *dbuf, size_t dlen, size_t *didx)
{
    size_t i = 0;
    while (i < slen) {
        if (sbuf[i] == DCODE_PADDING) {
            ++i;
            continue;
        }
        if (sbuf[i] == DCODE_END)
            break;
        if (i >= slen - 2)
            break;
        size_t soptsiz = sbuf[i+1];
        if (sbuf[i] == code) {
            if (dlen < soptsiz + *didx)
                return;
            if (slen < soptsiz + i + 2)
                return;
            memcpy(dbuf + *didx, sbuf+i+2, soptsiz);
            *didx += soptsiz;
        }
        i += soptsiz + 2;
    }
}

size_t get_dhcp_opt(const struct dhcpmsg * const packet, uint8_t code,
                     uint8_t *dbuf, size_t dlen)
{
    int ol = overload_value(packet);
    size_t didx = 0;
    do_get_dhcp_opt(packet->options, sizeof packet->options, code,
                    dbuf, dlen, &didx);
    if (ol & 1)
        do_get_dhcp_opt(packet->file, sizeof packet->file, code,
                        dbuf, dlen, &didx);
    if (ol & 2)
        do_get_dhcp_opt(packet->sname, sizeof packet->sname, code,
                        dbuf, dlen, &didx);
    return didx;
}

// return the position of the 'end' option
ssize_t get_end_option_idx(const struct dhcpmsg * const packet)
{
    for (size_t i = 0; i < sizeof packet->options; ++i) {
        if (packet->options[i] == DCODE_END)
            return (ssize_t)i;
        if (packet->options[i] == DCODE_PADDING)
            continue;
        if (i + 1 >= sizeof packet->options)
            break;
        i += (size_t)packet->options[i+1] + 1;
    }
    log_line("get_end_option_idx: Did not find DCODE_END marker.");
    return -1;
}

static inline size_t sizeof_option_str(uint8_t code, size_t datalen)
{
    if (code == DCODE_PADDING || code == DCODE_END)
        return 1;
    return 2 + datalen;
}

// Add a raw data string to the options.  It will take a binary string suitable
// for use with eg memcpy() and will append it to the options[] field of
// a dhcp packet with the requested option code and proper length specifier.
size_t add_option_string(struct dhcpmsg *packet, uint8_t code,
                         const char * const str, size_t slen)
{
    size_t len = sizeof_option_str(code, slen);
    if (slen > 255 || len != slen + 2) {
        log_line("add_option_string: Length checks failed.");
        return 0;
    }

    ssize_t end = get_end_option_idx(packet);
    if (end < 0) {
        log_line("add_option_string: Buffer has no DCODE_END marker.");
        return 0;
    }
    if ((size_t)end + len >= sizeof packet->options) {
        log_line("add_option_string: No space for option 0x%02x.", code);
        return 0;
    }
    packet->options[end] = code;
    packet->options[end+1] = slen;
    memcpy(packet->options + end + 2, str, slen);
    packet->options[(size_t)end+len] = DCODE_END;
    return len;
}

static ssize_t add_option_check(struct dhcpmsg *packet, uint8_t code,
                                uint8_t rlen)
{
    ssize_t end = get_end_option_idx(packet);
    if (end < 0) {
        log_line("add_u%01u_option: Buffer has no DCODE_END marker.", rlen*8);
        return -1;
    }
    if ((size_t)end + 2 + rlen >= sizeof packet->options) {
        log_line("add_u%01u_option: No space for option 0x%02x.",
                 rlen*8, code);
        return -1;
    }
    return end;
}

static size_t add_u8_option(struct dhcpmsg *packet, uint8_t code, uint8_t data)
{
    ssize_t end = add_option_check(packet, code, 1);
    if (end < 0)
        return 0;
    packet->options[end] = code;
    packet->options[end+1] = 1;
    packet->options[end+2] = data;
    packet->options[end+3] = DCODE_END;
    return 3;
}

#ifndef NDHS_BUILD
// Data should be in network byte order.
static size_t add_u16_option(struct dhcpmsg *packet, uint8_t code,
                             uint16_t data)
{
    ssize_t end = add_option_check(packet, code, 2);
    if (end < 0)
        return 0;
    uint8_t *dp = (uint8_t *)&data;
    packet->options[end] = code;
    packet->options[end+1] = 2;
    packet->options[end+2] = dp[0];
    packet->options[end+3] = dp[1];
    packet->options[end+4] = DCODE_END;
    return 4;
}
#endif

// Data should be in network byte order.
size_t add_u32_option(struct dhcpmsg *packet, uint8_t code, uint32_t data)
{
    ssize_t end = add_option_check(packet, code, 4);
    if (end < 0)
        return 0;
    uint8_t *dp = (uint8_t *)&data;
    packet->options[end] = code;
    packet->options[end+1] = 4;
    packet->options[end+2] = dp[0];
    packet->options[end+3] = dp[1];
    packet->options[end+4] = dp[2];
    packet->options[end+5] = dp[3];
    packet->options[end+6] = DCODE_END;
    return 6;
}

// Add a parameter request list for stubborn DHCP servers
size_t add_option_request_list(struct dhcpmsg *packet)
{
    static const char reqdata[] = {
        DCODE_SUBNET, DCODE_ROUTER, DCODE_DNS, DCODE_HOSTNAME, DCODE_DOMAIN,
        DCODE_BROADCAST,
    };
    return add_option_string(packet, DCODE_PARAM_REQ,
                             reqdata, sizeof reqdata);
}

#ifdef NDHS_BUILD
size_t add_option_domain_name(struct dhcpmsg *packet, const char * const dom,
                              size_t domlen)
{
    return add_option_string(packet, DCODE_DOMAIN, dom, domlen);
}

void add_option_subnet_mask(struct dhcpmsg *packet, uint32_t subnet)
{
    add_u32_option(packet, DCODE_SUBNET, subnet);
}

void add_option_broadcast(struct dhcpmsg *packet, uint32_t bc)
{
    add_u32_option(packet, DCODE_BROADCAST, bc);
}
#endif

void add_option_msgtype(struct dhcpmsg *packet, uint8_t type)
{
    add_u8_option(packet, DCODE_MSGTYPE, type);
}

void add_option_reqip(struct dhcpmsg *packet, uint32_t ip)
{
    add_u32_option(packet, DCODE_REQIP, ip);
}

void add_option_serverid(struct dhcpmsg *packet, uint32_t sid)
{
    add_u32_option(packet, DCODE_SERVER_ID, sid);
}

void add_option_clientid(struct dhcpmsg *packet, const char * const clientid,
                         size_t clen)
{
    add_option_string(packet, DCODE_CLIENT_ID, clientid, clen);
}

#ifndef NDHS_BUILD
void add_option_maxsize(struct dhcpmsg *packet)
{
    add_u16_option(packet, DCODE_MAX_SIZE,
                   htons(sizeof(struct ip_udp_dhcp_packet)));
}

void add_option_vendor(struct dhcpmsg *packet, const char * const vendor,
                       size_t vsize)
{
    if (vsize)
        add_option_string(packet, DCODE_VENDOR, vendor, vsize);
}

void add_option_hostname(struct dhcpmsg *packet, const char * const hostname,
                         size_t hsize)
{
    if (hsize)
        add_option_string(packet, DCODE_HOSTNAME, hostname, hsize);
}
#endif

uint32_t get_option_router(const struct dhcpmsg * const packet)
{
    uint32_t ret = 0;
    uint8_t buf[MAX_DOPT_SIZE];
    const size_t ol = get_dhcp_opt(packet, DCODE_ROUTER, buf, sizeof buf);
    if (ol == sizeof ret)
        memcpy(&ret, buf, sizeof ret);
    return ret;
}

uint8_t get_option_msgtype(const struct dhcpmsg * const packet)
{
    uint8_t ret = 0;
    uint8_t buf[MAX_DOPT_SIZE];
    const size_t ol = get_dhcp_opt(packet, DCODE_MSGTYPE, buf, sizeof buf);
    if (ol == sizeof ret)
        ret = buf[0];
    return ret;
}

uint32_t get_option_serverid(const struct dhcpmsg *const packet, int *found)
{
    uint32_t ret = 0;
    uint8_t buf[MAX_DOPT_SIZE];
    *found = 0;
    const size_t ol = get_dhcp_opt(packet, DCODE_SERVER_ID, buf, sizeof buf);
    if (ol == sizeof ret) {
        *found = 1;
        memcpy(&ret, buf, sizeof ret);
    }
    return ret;
}

uint32_t get_option_leasetime(const struct dhcpmsg * const packet)
{
    uint32_t ret = 0;
    uint8_t buf[MAX_DOPT_SIZE];
    const size_t ol = get_dhcp_opt(packet, DCODE_LEASET, buf, sizeof buf);
    if (ol == sizeof ret) {
        memcpy(&ret, buf, sizeof ret);
        ret = ntohl(ret);
    }
    return ret;
}

// Returned buffer is not nul-terminated.
size_t get_option_clientid(const struct dhcpmsg * const packet, char *cbuf,
                           size_t clen)
{
    if (clen < 1)
        return 0;
    return get_dhcp_opt(packet, DCODE_CLIENT_ID, (uint8_t *)cbuf, clen);
}


text:
package org.codehaus.groovy.grails.plugins;

import org.springframework.core.io.Resource;

/**
 * Reads information about a plugin
 *
 * @author Graeme Rocher
 * @since 1.3
 */
public interface PluginDescriptorReader {

    GrailsPluginInfo readPluginInfo(Resource r);
}