text:
LOCALPATH='/home/dssg/dssg/Fraud-Corruption-Detection-Data-Science-Pipeline-DSSG2015'
DATA_STORAGE='/home/dssg/dssg/Fraud-Corruption-Detection-Data-Science-Pipeline-DSSG2015/pipeline_data'
CURRENCY_FILE_PPP='/home/dssg/dssg/Fraud-Corruption-Detection-Data-Science-Pipeline-DSSG2015/pipeline_data/ppp.csv'
CURRENCY_FILE_FCRF='/home/dssg/dssg/Fraud-Corruption-Detection-Data-Science-Pipeline-DSSG2015/pipeline_data/fcrf.csv'
PATH_TO_SUPPLIER_FEATURE_GEN=$LOCALPATH'/WorldBank2015/Code/data_pipeline_src/supplier_feature_gen.py'

DATE=`date +"%m%d%Y_%H%M"`
STDOUT_LOG='./log_files/pipeline_'$DATE'.log'
ERROR_LOG='./log_files/pipeline_error_'$DATE'.log'
echo $STDOUT_LOG
echo $ERROR_LOG

echo Starting DSSG2015 World Bank Complaint Ranking Pipeline

#Setting Python Path - specific to allow desktop icon to run
#create an environment setup file if necessary for setting your system PATH and PYTHONPATH variables
###comment out if not needed
export PATH="/home/dssg/anaconda/bin":$PATH
export PYTHONPATH="/home/dssg/anaconda":$PYTHONPATH
echo $PYTHONPATH

echo ============================================
echo Ranked files will be output to $DATA_STORAGE
echo ============================================

echo Starting DSSG2015 World Bank Complaint Ranking Pipeline

### Data Loading ###
## Contracts ##
#Download a new set of contracts from the World Bank Website
echo Downloading newest contracts data set from finances.worldbank.org.
echo ================================================================= | tee $STDOUT_LOG $ERROR_LOG >/dev/null
echo Downloading newest contracts data set from finances.worldbank.org. | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null
echo ================================================================= | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null
CONTRACTS_FILE=$DATA_STORAGE'/latest_contract_web_download.csv'
wget --output-document=$CONTRACTS_FILE https://finances.worldbank.org/api/views/kdui-wcs3/rows.csv?accessType=DOWNLOAD >> $STDOUT_LOG 2>> $ERROR_LOG

#Cleaning the contracts: formating dates, renaming columns, properly coding null values
echo Cleaning contracts data set
echo ================================================================= | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo Cleaning contracts data set | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo ================================================================= | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

CLEANED_CONTRACTS_FILE=$DATA_STORAGE'/latest_contract_web_download_cleaned.csv'
python -W ignore $LOCALPATH'/WorldBank2015/Code/data_pipeline_src/data_cleaning_script.py' -f $CONTRACTS_FILE -n '#' -r "Borrower Country,country,Total Contract Amount (USD),amount" -o $CLEANED_CONTRACTS_FILE >> $STDOUT_LOG 2>> $ERROR_LOG

#Entity Resolution Application
echo Resolving entities in contracts data set.

echo ================================================================= | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null
echo Resolving entities in contracts data set. | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo ================================================================= | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

CANONICAL_FILE=$DATA_STORAGE'/canonicalNamesV2.csv'
ENTITY_RESOLVED_CONTRACTS_FILE=$DATA_STORAGE'/latest_contract_web_download_cleaned_resolved.csv'
python -W ignore $LOCALPATH'/WorldBank2015/Code/data_pipeline_src/entity_resolution/entity_resolution.py' -c $CLEANED_CONTRACTS_FILE -e $CANONICAL_FILE -o $ENTITY_RESOLVED_CONTRACTS_FILE >> $STDOUT_LOG 2>> $ERROR_LOG

#Loading contract data into PostgreSQL database
echo Loading contracts data set into database.

echo ================================================================= | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null
echo Loading contracts data set into database. | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo ================================================================= | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

CONTRACTS_TABLE='latest_contract_web_download_cleaned_resolved'
echo drop table \"$CONTRACTS_TABLE\"';' > droptable.sql
psql world_bank -f droptable.sql >> $STDOUT_LOG  2>> $ERROR_LOG
csvsql -i postgresql $ENTITY_RESOLVED_CONTRACTS_FILE > createtable.sql
#';'>>createtable.sql
psql world_bank -f createtable.sql >> $STDOUT_LOG 2>> $ERROR_LOG
echo \\copy \"$CONTRACTS_TABLE\" FROM \'$ENTITY_RESOLVED_CONTRACTS_FILE\' CSV HEADER\; > copydata.sql
psql world_bank -f copydata.sql >> $STDOUT_LOG 2>> $ERROR_LOG

## Projects ##
#Getting project data from World Bank Website which will later be joined with the contracts data
echo Downloading newest projectts data set from finances.worldbank.org.
echo ================================================================  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo Downloading newest projects data set from finances.worldbank.org.  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo =================================================================  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

PROJECTS_FILE=$DATA_STORAGE'/project_data.csv'
wget http://search.worldbank.org/api/projects/all.csv -O $PROJECTS_FILE >> $STDOUT_LOG 2>> $ERROR_LOG

#Cleaning the project data
echo Cleaning projects data set.

echo =================================================================  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null
echo Cleaning projects data set   | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null
echo =================================================================  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

python -W ignore $LOCALPATH'/WorldBank2015/Code/data_pipeline_src/data_cleaning_generic.py' -f $PROJECTS_FILE -o $PROJECTS_FILE >> $STDOUT_LOG 2>> $ERROR_LOG
#Loading the project data to the PostgreSQL database
echo Loading projects data set into database

echo =================================================================  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo Loading projects data set  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo =================================================================  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

PROJECTS_TABLE='project_data'
echo drop table \"$PROJECTS_TABLE\"';' > droptable.sql
psql world_bank -f droptable.sql >> $STDOUT_LOG 2>> $ERROR_LOG
csvsql -i postgresql $PROJECTS_FILE > createtable.sql
psql world_bank -f createtable.sql >> $STDOUT_LOG 2>> $ERROR_LOG
echo \\copy \"$PROJECTS_TABLE\" FROM \'$PROJECTS_FILE\' CSV HEADER';' > copydata.sql
psql world_bank -f copydata.sql >> $STDOUT_LOG 2>> $ERROR_LOG

#Joining Project data and Contracts data

echo =================================================================  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo joining project and contract data  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo =================================================================  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

JOINED_TABLE='contracts_wprojects'
echo DROP TABLE $JOINED_TABLE';'>droptable.sql
psql world_bank -f droptable.sql >> $STDOUT_LOG 2>> $ERROR_LOG
echo "ALTER TABLE $CONTRACTS_TABLE DROP COLUMN _unnamed;">dropcolumn.sql
psql world_bank -f dropcolumn.sql >> $STDOUT_LOG 2>> $ERROR_LOG
echo "ALTER TABLE $PROJECTS_TABLE DROP COLUMN _unnamed;">dropcolumn.sql
psql world_bank -f dropcolumn.sql >> $STDOUT_LOG 2>> $ERROR_LOG
echo "AlTER TABLE $PROJECTS_TABLE DROP COLUMN project_name;">dropcolumn.sql
psql world_bank -f dropcolumn.sql >> $STDOUT_LOG 2>> $ERROR_LOG
echo "AlTER TABLE $PROJECTS_TABLE DROP COLUMN country;">dropcolumn.sql
psql world_bank -f dropcolumn.sql >> $STDOUT_LOG 2>> $ERROR_LOG
echo "CREATE TABLE $JOINED_TABLE AS SELECT * FROM $CONTRACTS_TABLE LEFT JOIN $PROJECTS_TABLE ON ($CONTRACTS_TABLE.project_id = $PROJECTS_TABLE.id);" > joinprojectdata.sql
psql world_bank -f joinprojectdata.sql>> $STDOUT_LOG 2>> $ERROR_LOG

## Feature Generation ##
#Generate contracts features
echo Generating data abstractions \(features\) for at the contracts level.
echo =================================================================  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo Generating contract features  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo =================================================================  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

FEATURE_GEN_1_FILE=$DATA_STORAGE'/latest_contract_web_download_cleaned_feature_gen1.csv'
python -W ignore $LOCALPATH'/WorldBank2015/Code/data_pipeline_src/contracts_feature_gen.py' -f $ENTITY_RESOLVED_CONTRACTS_FILE -p procurement_method -wf $FEATURE_GEN_1_FILE -ppp $CURRENCY_FILE_PPP -fcrf $CURRENCY_FILE_FCRF >> $STDOUT_LOG 2>> $ERROR_LOG

#Adding Labels Data Set
###Cleaning the investigation data
echo Merging contracts, projects and investigations data sets.
echo =================================================================  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo Merging contracts,projects and investigations data sets. | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo =================================================================  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

LABELS_FILE=$DATA_STORAGE'/investigations.csv'
echo Investigations file being used: $LABELS_FILE
echo Last Modification Date for Investigations File:
stat -c %y $LABELS_FILE

UTF8_LABELS_FILE=$DATA_STORAGE'/utf8_investigations.csv'
iconv -f utf-8 -t ascii -c $LABELS_FILE -o $UTF8_LABELS_FILE >> $STDOUT_LOG 2>> $ERROR_LOG
python -W ignore $LOCALPATH'/WorldBank2015/Code/data_pipeline_src/data_cleaning_generic.py' -f $UTF8_LABELS_FILE -o $UTF8_LABELS_FILE >> $STDOUT_LOG 2>> $ERROR_LOG

LABELED_CONTRACTS_FEATURE_GEN_1=$DATA_STORAGE'/labeled_contracts_cleaned_resolved_feature_gen_1.csv'
python -W ignore $LOCALPATH'/WorldBank2015/Code/data_pipeline_src/label.py' -c $FEATURE_GEN_1_FILE -i $UTF8_LABELS_FILE -wf $LABELED_CONTRACTS_FEATURE_GEN_1 >> $STDOUT_LOG 2>> $ERROR_LOG

#Generating supplier features for allegations
echo Generating supplier features for allegations data set.
echo =================================================================  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo generating supplier features for allegations | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo ================================================================= | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

TABLE_ID_FOR_STORING_ALLEGATION_FEATURES='alleg'
python -W ignore $LOCALPATH'/WorldBank2015/Code/data_pipeline_src/feature_loop.py' -cf $FEATURE_GEN_1_FILE -if $LABELED_CONTRACTS_FEATURE_GEN_1 -id $TABLE_ID_FOR_STORING_ALLEGATION_FEATURES -path $PATH_TO_SUPPLIER_FEATURE_GEN >> $STDOUT_LOG 2>> $ERROR_LOG

#Generating ranked list of complaints based on model.
echo Generating ranked list of allegations.
echo ================================================================= | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null
echo generating allegations ranked list | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null
echo ================================================================= | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null
TRAINING_TABLE_NAME='labeled_contracts_cleaned_resolved_feature_gen_1_alleg'
RANKED_LIST_OF_ALLEGATIONS_FILE_NAME=$DATA_STORAGE'/prioritzed_allegations_to_investigate.csv'
python -W ignore $LOCALPATH'/WorldBank2015/Code/modeling/predict.py' -tf $TRAINING_TABLE_NAME -fl $LOCALPATH'/WorldBank2015/Code/modeling/feature_sets_log.yaml' -train_id $TABLE_ID_FOR_STORING_ALLEGATION_FEATURES -wf $RANKED_LIST_OF_ALLEGATIONS_FILE_NAME>>$STDOUT_LOG 2>> $ERROR_LOG

#Creating supplier features for contracts set
echo Generating supplier features for contracts data set.
echo ================================================================= | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null
echo generating supplier features for contracts | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo ================================================================= | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

TABLE_ID_FOR_STORING_CONTRACTS_FEATURES='cntrcts'
python -W ignore $LOCALPATH'/WorldBank2015/Code/data_pipeline_src/feature_loop.py' -cf $FEATURE_GEN_1_FILE -if $FEATURE_GEN_1_FILE -id $TABLE_ID_FOR_STORING_CONTRACTS_FEATURES -path $PATH_TO_SUPPLIER_FEATURE_GEN >> $STDOUT_LOG 2>> $ERROR_LOG

#Generating ranked list of contracts in the last N years based on model.
echo Generating ranked list of contracts.
echo ================================================================= | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null
echo generating contracts ranked lists  | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null

echo ================================================================= | tee -a $STDOUT_LOG $ERROR_LOG > /dev/null
TRAINING_TABLE_NAME='labeled_contracts_cleaned_resolved_feature_gen_1_alleg'
PREDICTING_TABLE_NAME='latest_contract_web_download_cleaned_feature_gen1_cntrcts'
OUTPUT_FILE_NAME=$DATA_STORAGE'/ranked_contracts_to_investigate_for_'
python -W ignore $LOCALPATH'/WorldBank2015/Code/modeling/prediction_loop.py' -tf $TRAINING_TABLE_NAME -pf $PREDICTING_TABLE_NAME -fl $LOCALPATH'/WorldBank2015/Code/modeling/feature_sets_log.yaml' -train_id $TABLE_ID_FOR_STORING_ALLEGATION_FEATURES -pred_id $TABLE_ID_FOR_STORING_CONTRACTS_FEATURES -path $LOCALPATH'/WorldBank2015/Code/modeling/predict.py' -fp $OUTPUT_FILE_NAME >>$STDOUT_LOG 2>> $ERROR_LOG


text:
#pragma once

#include <Tensile/MasterSolutionLibrary.hpp>

#include <boost/program_options.hpp>

#include <functional>
#include <vector>

#include "RunListener.hpp"

namespace Tensile
{
    namespace Client
    {
        namespace po = boost::program_options;

        /**
 * Not an iterator by the traditional definition but I can't think of a better
 * name
 */
        class SolutionIterator : public RunListener
        {
        public:
            static std::shared_ptr<SolutionIterator>
                Default(std::shared_ptr<MasterSolutionLibrary<ContractionProblem>> library,
                        std::shared_ptr<Hardware>                                  hardware,
                        po::variables_map const&                                   args);

            virtual bool needMoreBenchmarkRuns() const override
            {
                return false;
            }
            virtual void preBenchmarkRun() override {}
            virtual void postBenchmarkRun() override {}

            virtual bool needMoreRunsInSolution() const override
            {
                return false;
            }

            virtual size_t numWarmupRuns() override
            {
                return 0;
            }
            virtual void setNumWarmupRuns(size_t count) override {}
            virtual void preWarmup() override {}
            virtual void postWarmup() override {}
            virtual void validateWarmups(std::shared_ptr<ContractionInputs> inputs,
                                         TimingEvents const&                startEvents,
                                         TimingEvents const&                stopEvents) override
            {
            }

            virtual size_t numSyncs() override
            {
                return 0;
            }
            virtual void setNumSyncs(size_t count) override {}
            virtual void preSyncs() override {}
            virtual void postSyncs() override {}

            virtual size_t numEnqueuesPerSync() override
            {
                return 0;
            }
            virtual void setNumEnqueuesPerSync(size_t count) override {}
            virtual void preEnqueues() override {}
            virtual void postEnqueues(TimingEvents const& startEvents,
                                      TimingEvents const& stopEvents) override
            {
            }
            virtual void validateEnqueues(std::shared_ptr<ContractionInputs> inputs,
                                          TimingEvents const&                startEvents,
                                          TimingEvents const&                stopEvents) override
            {
            }

            virtual void finalizeReport() override {}

            virtual int error() const override
            {
                return 0;
            }

            virtual bool                                 moreSolutionsInProblem() const = 0;
            virtual std::shared_ptr<ContractionSolution> getSolution()                  = 0;
            virtual bool                                 runCurrentSolution();

            virtual void preProblem(ContractionProblem const& problem) override;

        protected:
            SolutionIterator(std::shared_ptr<MasterSolutionLibrary<ContractionProblem>> library,
                             std::shared_ptr<Hardware>                                  hardware);

            virtual bool checkSolution(ContractionSolution const& solution);

            std::shared_ptr<MasterSolutionLibrary<ContractionProblem>> m_library;
            std::shared_ptr<Hardware>                                  m_hardware;
            ContractionProblem                                         m_problem;
        };

        class AllSolutionsIterator : public SolutionIterator
        {
        public:
            using RunCriteria = std::vector<std::function<bool(
                ContractionProblem const&, Hardware const&, ContractionSolution const&)>>;

            static RunCriteria
                CreateCriteria(std::shared_ptr<MasterSolutionLibrary<ContractionProblem>> library,
                               std::shared_ptr<Hardware>                                  hardware,
                               po::variables_map const&                                   args);

            AllSolutionsIterator(std::shared_ptr<MasterSolutionLibrary<ContractionProblem>> library,
                                 std::shared_ptr<Hardware> hardware,
                                 int                       firstSolutionIdx,
                                 int                       numSolutions,
                                 RunCriteria               runCriteria = RunCriteria());

            virtual void preProblem(ContractionProblem const& problem) override;
            virtual void postProblem() override;

            virtual void preSolution(ContractionSolution const& solution) override;
            virtual void postSolution() override;

            virtual bool                                 moreSolutionsInProblem() const override;
            virtual std::shared_ptr<ContractionSolution> getSolution() override;
            virtual bool                                 runCurrentSolution() override;

        private:
            int m_firstSolutionIdx;
            int m_lastSolutionIdx;

            int m_currentSolutionIdx;

            RunCriteria m_runCriteria;
        };

        class BestSolutionIterator : public SolutionIterator
        {
        public:
            BestSolutionIterator(std::shared_ptr<MasterSolutionLibrary<ContractionProblem>> library,
                                 std::shared_ptr<Hardware> hardware);

            virtual void preProblem(ContractionProblem const& problem) override;
            virtual void postProblem() override;

            virtual void preSolution(ContractionSolution const& solution) override;
            virtual void postSolution() override;

            virtual bool                                 moreSolutionsInProblem() const override;
            virtual std::shared_ptr<ContractionSolution> getSolution() override;

        private:
            std::shared_ptr<ContractionSolution> m_currentSolution;
            bool                                 m_usedCurrentSolution = false;
        };
    } // namespace Client
} // namespace Tensile

redpajama_set_name: RedPajamaGithub


text:
import React, { Component } from 'react';
import { orderBy } from 'lodash';

import { checkAuth, load, updateCell } from '../helpers/spreadsheet';
import { hash } from '../helpers/utils';
import * as ls from '../helpers/localStorage';

import Filters from './Filters';
import Quote from './Quote';
import Alert from './Alert';

class App extends Component {

  constructor(props) {
    super(props);

    this.state = {
      quotes: [],
      random: {},
      authors: [],
      author: '',
      order: 'date'
    }
  }

  componentDidMount() {
    window.gapi.load('client', () => {
      checkAuth(true, this.handleAuth.bind(this));
    });
  }

  /**
   * Check user authenification status and set app state accordingly
   */
  handleAuth(authResult) {
    if (authResult && !authResult.error) {
      this.setState({
        authenticated: true
      });
      load(this.onLoad.bind(this))
    } else {
      this.setState({
        authenticated: false
      })
    }
  }

  /**
   * Once quotes have been loaded from the spreadsheet
   */
  onLoad(data, error) {
    if (data) {
      const random = data.quotes[Math.floor(Math.random() * data.quotes.length)];

      this.setState({
        ...data,
        random
      });
    }
    else {
      this.setState({
        error: error
      })
    }
  }

  render() {
    return (

"Quotes"

        { this.renderContent() }

    );
  }

  renderContent() {
    const quotes = this.state.quotes;

    if (this.state.authenticated === false) {
      return (
        <button onClick={ this.authenticate.bind(this) } className="btn">Connect with Google</button>
      );
    }
    else if (quotes.length) {
      return (

Randomly picked

          <Quote
            quote={ this.state.random }
            toggleLike={ this.toggleLike.bind(this) } />

{ this.state.quotes.length} quotes

          <Filters
            authors={ this.state.authors }
            author={ this.state.author }
            setAuthor={ this.setAuthor.bind(this) }
            order={ this.state.order }
            setOrder={ this.setOrder.bind(this) } />

            { quotes.map((quote, i) => {
              if (this.state.author && quote.author !== this.state.author) {
                return false;
              }

              return (
                <Quote
                  key={ i }
                  quote={ quote }
                  toggleLike={ this.toggleLike.bind(this) } />
              );
            }) }

      );
    }
    else if (this.state.error) {
      return (
        <Alert error={ this.state.error } />
      );
    }
    else {
      return (

      );
    }
  }

  /**
   * Request Google authentification
   */
  authenticate(e) {
    e.preventDefault();
    checkAuth(false, this.handleAuth.bind(this));
  }

  /**
   * Filter by author
   */
  setAuthor(author) {
    this.setState({
      author
    });
  }

  /**
   * Change the order of the quotes
   */
  setOrder(order) {
    const quotes = orderBy(this.state.quotes, [order], ['desc']);

    this.setState({
      quotes,
      order
    });
  }

  /**
   * Add or remove like on the quote
   * The value is incremented/decremented into the spreadsheet
   * User owns likes are saved to its browser LocalStorage
   */
  toggleLike(q, save = true) {
    const quotes = [...this.state.quotes],
          index = quotes.indexOf(q),
          quote = quotes[index],
          userLikes = ls.get('likes') || [];

    if (quote) {
      const id = hash(quote.text);

      if (quote.liked) {
        quote.likes--;
        quote.liked = false;

        const index = userLikes.indexOf(id);

        if (index > -1) {
          userLikes.splice(index, 1);
        }
      }
      else {
        quote.likes++;
        quote.liked = true;

        if (id) {
          userLikes.push(id);
        }
      }

      ls.set('likes', userLikes);

      // Update state immediately for instant visual feedback
      this.setState({
        quotes
      }, () => {
        if (save) {
          // Now save the data to the spreadsheet
          updateCell('E', quote.row, quote.likes, null, (error) => {
            // In case an error occured while saving, toggle the state back
            this.toggleLike(quote, false);
          });
        }
      });
    }
  }

}

export default App;


text:
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <asm/io.h>
#include <asm/arch/hardware.h> /* for CLPS7111_VIRT_BASE */
#include <asm/sizes.h>
#include <asm/arch/h1900-gpio.h>
#include <asm/arch/ipaq.h>

/*
 * MTD structure for EDB7312 board
 */
static struct mtd_info *h1910_nand_mtd = NULL;

/*
 * Module stuff
 */

#ifdef CONFIG_MTD_PARTITIONS
/*
 * Define static partitions for flash device
 */
static struct mtd_partition partition_info[] = {
	{ name: "h1910 NAND Flash",
		  offset: 0,
		  size: 16*1024*1024 }
};
#define NUM_PARTITIONS 1

#endif

/*
 *	hardware specific access to control-lines
 */
static void h1910_hwcontrol(struct mtd_info *mtd, int cmd)
{
	struct nand_chip* this = (struct nand_chip *) (mtd->priv);

	switch(cmd) {

	case NAND_CTL_SETCLE:
		this->IO_ADDR_R |= (1 << 2);
		this->IO_ADDR_W |= (1 << 2);
		break;
	case NAND_CTL_CLRCLE:
		this->IO_ADDR_R &= ~(1 << 2);
		this->IO_ADDR_W &= ~(1 << 2);
		break;

	case NAND_CTL_SETALE:
		this->IO_ADDR_R |= (1 << 3);
		this->IO_ADDR_W |= (1 << 3);
		break;
	case NAND_CTL_CLRALE:
		this->IO_ADDR_R &= ~(1 << 3);
		this->IO_ADDR_W &= ~(1 << 3);
		break;

	case NAND_CTL_SETNCE:
		break;
	case NAND_CTL_CLRNCE:
		break;
	}
}

/*
 *	read device ready pin
 */
#if 0
static int h1910_device_ready(struct mtd_info *mtd)
{
	return (GPLR(55) & GPIO_bit(55));
}
#endif

/*
 * Main initialization routine
 */
static int __init h1910_init (void)
{
	struct nand_chip *this;
	const char *part_type = 0;
	int mtd_parts_nb = 0;
	struct mtd_partition *mtd_parts = 0;
	void __iomem *nandaddr;

	if (!machine_is_h1900())
		return -ENODEV;

	nandaddr = ioremap(0x08000000, 0x1000);
	if (!nandaddr) {
		printk("Failed to ioremap nand flash.\n");
		return -ENOMEM;
	}

	/* Allocate memory for MTD device structure and private data */
	h1910_nand_mtd = kmalloc(sizeof(struct mtd_info) +
			     sizeof(struct nand_chip),
			     GFP_KERNEL);
	if (!h1910_nand_mtd) {
		printk("Unable to allocate h1910 NAND MTD device structure.\n");
		iounmap ((void *) nandaddr);
		return -ENOMEM;
	}

	/* Get pointer to private data */
	this = (struct nand_chip *) (&h1910_nand_mtd[1]);

	/* Initialize structures */
	memset((char *) h1910_nand_mtd, 0, sizeof(struct mtd_info));
	memset((char *) this, 0, sizeof(struct nand_chip));

	/* Link the private data with the MTD structure */
	h1910_nand_mtd->priv = this;

	/*
	 * Enable VPEN
	 */
	GPSR(37) = GPIO_bit(37);

	/* insert callbacks */
	this->IO_ADDR_R = nandaddr;
	this->IO_ADDR_W = nandaddr;
	this->hwcontrol = h1910_hwcontrol;
	this->dev_ready = NULL;	/* unknown whether that was correct or not so we will just do it like this */
	/* 15 us command delay time */
	this->chip_delay = 50;
	this->eccmode = NAND_ECC_SOFT;
	this->options = NAND_NO_AUTOINCR;

	/* Scan to find existence of the device */
	if (nand_scan (h1910_nand_mtd, 1)) {
		printk(KERN_NOTICE "No NAND device - returning -ENXIO\n");
		kfree (h1910_nand_mtd);
		iounmap ((void *) nandaddr);
		return -ENXIO;
	}

#ifdef CONFIG_MTD_CMDLINE_PARTS
	mtd_parts_nb = parse_cmdline_partitions(h1910_nand_mtd, &mtd_parts,
						"h1910-nand");
	if (mtd_parts_nb > 0)
	  part_type = "command line";
	else
	  mtd_parts_nb = 0;
#endif
	if (mtd_parts_nb == 0)
	{
		mtd_parts = partition_info;
		mtd_parts_nb = NUM_PARTITIONS;
		part_type = "static";
	}

	/* Register the partitions */
	printk(KERN_NOTICE "Using %s partition definition\n", part_type);
	add_mtd_partitions(h1910_nand_mtd, mtd_parts, mtd_parts_nb);

	/* Return happy */
	return 0;
}
module_init(h1910_init);

/*
 * Clean up routine
 */
static void __exit h1910_cleanup (void)
{
	struct nand_chip *this = (struct nand_chip *) &h1910_nand_mtd[1];

	/* Release resources, unregister device */
	nand_release (h1910_nand_mtd);

	/* Release io resource */
	iounmap ((void *) this->IO_ADDR_W);

	/* Free the MTD device structure */
	kfree (h1910_nand_mtd);
}
module_exit(h1910_cleanup);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Joshua Wise <joshua at joshuawise dot com>");
MODULE_DESCRIPTION("NAND flash driver for iPAQ h1910");


text:
array_search_keys
=================

Provides functionality for searching a list of keys in order and returning the first match

License
-------

BSD-3-Clause

Un-Documented
-------------

This library is currently un-documented, please read the tests as they're pretty clear.

Prior Art
---------

  * None that I'm aware of


text:
<!DOCTYPE html>

    <title>Zuheir Al Sagha</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="shortcut icon" href="img/zs.png">
    <link rel="icon" type="image/png" href="img/zs.png"/>

    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">

    <link rel="stylesheet" type="text/css" href="../css/nav.css">
    <link rel="stylesheet" type="text/css" href="../css/main.css">
    <link rel="stylesheet" type="text/css" href="../css/projects.css">
    <link rel="stylesheet" type="text/css" href="../css/pp.css">

    Home
    Skills
    Portfolio
    Experience
    Contact

Popcorn Priests

Consulting Project

Overview

Team

Me!

Time

2 Weeks

Role

Lead Designer

The Challenge

        Popcorn Priests provides their customers with a healthy alternative to
        snacking. Their main product consists of freshly popped popcorn
        coated in a gourmet whey protein chocolate syrup. This means you can
        indulge in a sweet snack while staying healthy.

        My goal was to design a company logo, business card and packaging.

Logo

          The logo is inspired by the raw ingredients in their flagship product,
          popcorn and chocolate.

          The crown is placed on the kernel as a fun twist that helps to further
          solidify the gourmet appearance of the product.

Business Card

          For the business card design I wanted to create a minimal card that
          clearly showed all necessary information with the brand name clearly
          labelled in multiple locations.

          The blue background offers a nice contrast to the brown chocolate
          coating on the kernal.

Packaging

WombDefender

Popcorn Priests

BoilerPlate.

Dribbble

MaxRep

Baton Rouge

© Zuheir Chikh Al Sagha 2019


text:
package org.apache.ignite.internal.processors.cache.distributed.dht.topology;

import java.util.concurrent.CountDownLatch;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.testframework.GridTestUtils;
import org.junit.Test;

/**
 *
 */
public class PartitionsEvictionTaskFailureHandlerTest extends PartitionsEvictManagerAbstractTest {
    /**
     *
     */
    @Test
    public void testEvictionTaskShouldCallFailureHandler() throws Exception {
        T2<IgniteEx, CountDownLatch> nodeAndEvictLatch = makeNodeWithEvictLatch(true);

        IgniteCache<Object, Object> cache = nodeAndEvictLatch.get1().createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME)
            .setGroupName("test-grp"));

        for (int i = 0; i < 100_000; i++)
            cache.put(i, i);

        doActionDuringEviction(nodeAndEvictLatch, () -> {});

        assertTrue(GridTestUtils.waitForCondition(() -> failure.get(), 10_000));
    }
}


text:
#pragma once
#include <aws/snow-device-management/SnowDeviceManagement_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/snow-device-management/model/ExecutionState.h>
#include <utility>

namespace Aws
{
namespace Utils
{
namespace Json
{
  class JsonValue;
  class JsonView;
} // namespace Json
} // namespace Utils
namespace SnowDeviceManagement
{
namespace Model
{

  /**
   *
The summary of a task execution on a specified device.

See
   * Also:
   AWS
   * API Reference

   */
  class AWS_SNOWDEVICEMANAGEMENT_API ExecutionSummary
  {
  public:
    ExecutionSummary();
    ExecutionSummary(Aws::Utils::Json::JsonView jsonValue);
    ExecutionSummary& operator=(Aws::Utils::Json::JsonView jsonValue);
    Aws::Utils::Json::JsonValue Jsonize() const;

    /**
     *
The ID of the execution.

     */
    inline const Aws::String& GetExecutionId() const{ return m_executionId; }

    /**
     *
The ID of the execution.

     */
    inline bool ExecutionIdHasBeenSet() const { return m_executionIdHasBeenSet; }

    /**
     *
The ID of the execution.

     */
    inline void SetExecutionId(const Aws::String& value) { m_executionIdHasBeenSet = true; m_executionId = value; }

    /**
     *
The ID of the execution.

     */
    inline void SetExecutionId(Aws::String&& value) { m_executionIdHasBeenSet = true; m_executionId = std::move(value); }

    /**
     *
The ID of the execution.

     */
    inline void SetExecutionId(const char* value) { m_executionIdHasBeenSet = true; m_executionId.assign(value); }

    /**
     *
The ID of the execution.

     */
    inline ExecutionSummary& WithExecutionId(const Aws::String& value) { SetExecutionId(value); return *this;}

    /**
     *
The ID of the execution.

     */
    inline ExecutionSummary& WithExecutionId(Aws::String&& value) { SetExecutionId(std::move(value)); return *this;}

    /**
     *
The ID of the execution.

     */
    inline ExecutionSummary& WithExecutionId(const char* value) { SetExecutionId(value); return *this;}

    /**
     *
The ID of the managed device that the task is being executed on.

     */
    inline const Aws::String& GetManagedDeviceId() const{ return m_managedDeviceId; }

    /**
     *
The ID of the managed device that the task is being executed on.

     */
    inline bool ManagedDeviceIdHasBeenSet() const { return m_managedDeviceIdHasBeenSet; }

    /**
     *
The ID of the managed device that the task is being executed on.

     */
    inline void SetManagedDeviceId(const Aws::String& value) { m_managedDeviceIdHasBeenSet = true; m_managedDeviceId = value; }

    /**
     *
The ID of the managed device that the task is being executed on.

     */
    inline void SetManagedDeviceId(Aws::String&& value) { m_managedDeviceIdHasBeenSet = true; m_managedDeviceId = std::move(value); }

    /**
     *
The ID of the managed device that the task is being executed on.

     */
    inline void SetManagedDeviceId(const char* value) { m_managedDeviceIdHasBeenSet = true; m_managedDeviceId.assign(value); }

    /**
     *
The ID of the managed device that the task is being executed on.

     */
    inline ExecutionSummary& WithManagedDeviceId(const Aws::String& value) { SetManagedDeviceId(value); return *this;}

    /**
     *
The ID of the managed device that the task is being executed on.

     */
    inline ExecutionSummary& WithManagedDeviceId(Aws::String&& value) { SetManagedDeviceId(std::move(value)); return *this;}

    /**
     *
The ID of the managed device that the task is being executed on.

     */
    inline ExecutionSummary& WithManagedDeviceId(const char* value) { SetManagedDeviceId(value); return *this;}

    /**
     *
The state of the execution.

     */
    inline const ExecutionState& GetState() const{ return m_state; }

    /**
     *
The state of the execution.

     */
    inline bool StateHasBeenSet() const { return m_stateHasBeenSet; }

    /**
     *
The state of the execution.

     */
    inline void SetState(const ExecutionState& value) { m_stateHasBeenSet = true; m_state = value; }

    /**
     *
The state of the execution.

     */
    inline void SetState(ExecutionState&& value) { m_stateHasBeenSet = true; m_state = std::move(value); }

    /**
     *
The state of the execution.

     */
    inline ExecutionSummary& WithState(const ExecutionState& value) { SetState(value); return *this;}

    /**
     *
The state of the execution.

     */
    inline ExecutionSummary& WithState(ExecutionState&& value) { SetState(std::move(value)); return *this;}

    /**
     *
The ID of the task.

     */
    inline const Aws::String& GetTaskId() const{ return m_taskId; }

    /**
     *
The ID of the task.

     */
    inline bool TaskIdHasBeenSet() const { return m_taskIdHasBeenSet; }

    /**
     *
The ID of the task.

     */
    inline void SetTaskId(const Aws::String& value) { m_taskIdHasBeenSet = true; m_taskId = value; }

    /**
     *
The ID of the task.

     */
    inline void SetTaskId(Aws::String&& value) { m_taskIdHasBeenSet = true; m_taskId = std::move(value); }

    /**
     *
The ID of the task.

     */
    inline void SetTaskId(const char* value) { m_taskIdHasBeenSet = true; m_taskId.assign(value); }

    /**
     *
The ID of the task.

     */
    inline ExecutionSummary& WithTaskId(const Aws::String& value) { SetTaskId(value); return *this;}

    /**
     *
The ID of the task.

     */
    inline ExecutionSummary& WithTaskId(Aws::String&& value) { SetTaskId(std::move(value)); return *this;}

    /**
     *
The ID of the task.

     */
    inline ExecutionSummary& WithTaskId(const char* value) { SetTaskId(value); return *this;}

  private:

    Aws::String m_executionId;
    bool m_executionIdHasBeenSet;

    Aws::String m_managedDeviceId;
    bool m_managedDeviceIdHasBeenSet;

    ExecutionState m_state;
    bool m_stateHasBeenSet;

    Aws::String m_taskId;
    bool m_taskIdHasBeenSet;
  };

} // namespace Model
} // namespace SnowDeviceManagement
} // namespace Aws


text:
> A field that features a select box filled with Symphony's pages

## Installation

1. Upload the `pagesfield` folder in this archive to your Symphony `/extensions` folder.

2. Enable it by selecting the "Field: Page Select Box", choose Enable from the with-selected menu, then click Apply.

3. You can now add the "Page Select Box" field to your sections.

For more information, see <http://getsymphony.com/learn/tasks/view/install-an-extension/>

## Sorting

The field sorts the pages according to the sortorder determined in 'Blueprints » Pages'. If the sorting isn't correct, it's probably because of the sortorder. To set the sortorder of your pages, edit your `config.php`, set `symphony/pages_table_nest_children` to `yes`, and sort the pages manually in your pages screen. When done, you can set `symphony/pages_table_nest_children` back to no (or keep it on yes, if that is your prefered way of working).


text:
package edu.berkeley.path.beats.util;

import java.math.BigDecimal;
import java.util.StringTokenizer;

import org.apache.log4j.Logger;

public class Data2D {
	private BigDecimal[][] data = null;

	private static Logger logger = Logger.getLogger(Data2D.class);

	/**
	 * @param str a serialized matrix
	 * @param delim delimiters
	 */
	public Data2D(String str, String[] delim) {
		if (null == delim) logger.error("no delimiters");
		else if (2 != delim.length) logger.error("delim.length != 2");
		else if (null == str) logger.error("str == null");
		else {
			str = str.replaceAll("\\s", "");
			StringTokenizer st1 = new StringTokenizer(str, delim[0]);
			data = new BigDecimal[st1.countTokens()][];
			for (int i = 0; st1.hasMoreTokens(); ++i) {
				StringTokenizer st2 = new StringTokenizer(st1.nextToken(), delim[1]);
				data[i] = new BigDecimal[st2.countTokens()];
				for (int j = 0; st2.hasMoreTokens(); ++j)
					data[i][j] = new BigDecimal(st2.nextToken());
			}
		}
	}

	public boolean isEmpty() {
		return null == data;
	}

	public BigDecimal[][] getData() {
		return data;
	}
}


text:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".MainActivity">
    <item
        android:id="@+id/action_date"
        android:title="@string/label_date"
        app:showAsAction="ifRoom" />

    <item
        android:id="@+id/action_list"
        android:title="@string/label_expenses_list"
        app:showAsAction="ifRoom" />
</menu>


text:
namespace app { namespace Uno { namespace Graphics { struct Texture2D; } } }

namespace app {
namespace Fuse {
namespace Entities {

struct DefaultMaterial;

struct DefaultMaterial__uType : ::app::Fuse::Entities::Material__uType
{
};

DefaultMaterial__uType* DefaultMaterial__typeof();

void DefaultMaterial___ObjInit_1(DefaultMaterial* __this);
::app::Uno::Float3 DefaultMaterial__get_DiffuseColor(DefaultMaterial* __this);
::app::Uno::Graphics::Texture2D* DefaultMaterial__get_DiffuseMap(DefaultMaterial* __this);
::app::Uno::Float3 DefaultMaterial__get_EmissiveColor(DefaultMaterial* __this);
::app::Uno::Graphics::Texture2D* DefaultMaterial__get_EmissiveMap(DefaultMaterial* __this);
bool DefaultMaterial__get_IsEmissive(DefaultMaterial* __this);
::app::Uno::Graphics::Texture2D* DefaultMaterial__get_NormalMap(DefaultMaterial* __this);
::app::Uno::Float2 DefaultMaterial__get_Offset(DefaultMaterial* __this);
float DefaultMaterial__get_Shininess(DefaultMaterial* __this);
::app::Uno::Float3 DefaultMaterial__get_SpecularColor(DefaultMaterial* __this);
::app::Uno::Graphics::Texture2D* DefaultMaterial__get_SpecularMap(DefaultMaterial* __this);
::app::Uno::Float2 DefaultMaterial__get_Tiling(DefaultMaterial* __this);
DefaultMaterial* DefaultMaterial__New_1(::uStatic* __this);
void DefaultMaterial__set_DiffuseColor(DefaultMaterial* __this, ::app::Uno::Float3 value);
void DefaultMaterial__set_DiffuseMap(DefaultMaterial* __this, ::app::Uno::Graphics::Texture2D* value);
void DefaultMaterial__set_EmissiveColor(DefaultMaterial* __this, ::app::Uno::Float3 value);
void DefaultMaterial__set_EmissiveMap(DefaultMaterial* __this, ::app::Uno::Graphics::Texture2D* value);
void DefaultMaterial__set_IsEmissive(DefaultMaterial* __this, bool value);
void DefaultMaterial__set_NormalMap(DefaultMaterial* __this, ::app::Uno::Graphics::Texture2D* value);
void DefaultMaterial__set_Offset(DefaultMaterial* __this, ::app::Uno::Float2 value);
void DefaultMaterial__set_Shininess(DefaultMaterial* __this, float value);
void DefaultMaterial__set_SpecularColor(DefaultMaterial* __this, ::app::Uno::Float3 value);
void DefaultMaterial__set_SpecularMap(DefaultMaterial* __this, ::app::Uno::Graphics::Texture2D* value);
void DefaultMaterial__set_Tiling(DefaultMaterial* __this, ::app::Uno::Float2 value);

struct DefaultMaterial : ::app::Fuse::Entities::Material
{
    ::app::Uno::Float3 _DiffuseColor;
    ::app::Uno::Float3 _SpecularColor;
    float _Shininess;
    ::app::Uno::Float2 _Tiling;
    ::app::Uno::Float2 _Offset;
    bool _IsEmissive;
    ::app::Uno::Float3 _EmissiveColor;
    ::uStrong< ::app::Uno::Graphics::Texture2D*> _DiffuseMap;
    ::uStrong< ::app::Uno::Graphics::Texture2D*> _NormalMap;
    ::uStrong< ::app::Uno::Graphics::Texture2D*> _SpecularMap;
    ::uStrong< ::app::Uno::Graphics::Texture2D*> _EmissiveMap;

    void _ObjInit_1() { DefaultMaterial___ObjInit_1(this); }
    ::app::Uno::Float3 DiffuseColor() { return DefaultMaterial__get_DiffuseColor(this); }
    ::app::Uno::Graphics::Texture2D* DiffuseMap() { return DefaultMaterial__get_DiffuseMap(this); }
    ::app::Uno::Float3 EmissiveColor() { return DefaultMaterial__get_EmissiveColor(this); }
    ::app::Uno::Graphics::Texture2D* EmissiveMap() { return DefaultMaterial__get_EmissiveMap(this); }
    bool IsEmissive() { return DefaultMaterial__get_IsEmissive(this); }
    ::app::Uno::Graphics::Texture2D* NormalMap() { return DefaultMaterial__get_NormalMap(this); }
    ::app::Uno::Float2 Offset() { return DefaultMaterial__get_Offset(this); }
    float Shininess() { return DefaultMaterial__get_Shininess(this); }
    ::app::Uno::Float3 SpecularColor() { return DefaultMaterial__get_SpecularColor(this); }
    ::app::Uno::Graphics::Texture2D* SpecularMap() { return DefaultMaterial__get_SpecularMap(this); }
    ::app::Uno::Float2 Tiling() { return DefaultMaterial__get_Tiling(this); }
    void DiffuseColor(::app::Uno::Float3 value) { DefaultMaterial__set_DiffuseColor(this, value); }
    void DiffuseMap(::app::Uno::Graphics::Texture2D* value) { DefaultMaterial__set_DiffuseMap(this, value); }
    void EmissiveColor(::app::Uno::Float3 value) { DefaultMaterial__set_EmissiveColor(this, value); }
    void EmissiveMap(::app::Uno::Graphics::Texture2D* value) { DefaultMaterial__set_EmissiveMap(this, value); }
    void IsEmissive(bool value) { DefaultMaterial__set_IsEmissive(this, value); }
    void NormalMap(::app::Uno::Graphics::Texture2D* value) { DefaultMaterial__set_NormalMap(this, value); }
    void Offset(::app::Uno::Float2 value) { DefaultMaterial__set_Offset(this, value); }
    void Shininess(float value) { DefaultMaterial__set_Shininess(this, value); }
    void SpecularColor(::app::Uno::Float3 value) { DefaultMaterial__set_SpecularColor(this, value); }
    void SpecularMap(::app::Uno::Graphics::Texture2D* value) { DefaultMaterial__set_SpecularMap(this, value); }
    void Tiling(::app::Uno::Float2 value) { DefaultMaterial__set_Tiling(this, value); }
};

}}}

#endif


text:
class ExtensionService;

#if defined(OS_CHROMEOS)
namespace chromeos {
class DeviceLocalAccountManagementPolicyProvider;
}
#endif  // defined(OS_CHROMEOS)

namespace content {
class BrowserContext;
}

namespace extensions {

class AppSorting;
class ContentVerifier;
class Extension;
class ExtensionSet;
class InfoMap;
class ManagementPolicy;
class OneShotEvent;
class QuotaService;
class RuntimeData;
class ServiceWorkerManager;
class SharedUserScriptMaster;
class StateStore;
class ValueStoreFactory;

// ExtensionSystem manages the lifetime of many of the services used by the
// extensions and apps system, and it handles startup and shutdown as needed.
// Eventually, we'd like to make more of these services into KeyedServices in
// their own right.
class ExtensionSystem : public KeyedService {
 public:
  ExtensionSystem();
  ~ExtensionSystem() override;

  // Returns the instance for the given browser context, or NULL if none.
  static ExtensionSystem* Get(content::BrowserContext* context);

  // Initializes extensions machinery.
  // Component extensions are always enabled, external and user extensions are
  // controlled by |extensions_enabled|.
  virtual void InitForRegularProfile(bool extensions_enabled) = 0;

  // The ExtensionService is created at startup.
  virtual ExtensionService* extension_service() = 0;

  // Per-extension data that can change during the life of the process but
  // does not persist across restarts. Lives on UI thread. Created at startup.
  virtual RuntimeData* runtime_data() = 0;

  // The class controlling whether users are permitted to perform certain
  // actions on extensions (install, uninstall, disable, etc.).
  // The ManagementPolicy is created at startup.
  virtual ManagementPolicy* management_policy() = 0;

  // The ServiceWorkerManager is created at startup.
  virtual ServiceWorkerManager* service_worker_manager() = 0;

  // The SharedUserScriptMaster is created at startup.
  virtual SharedUserScriptMaster* shared_user_script_master() = 0;

  // The StateStore is created at startup.
  virtual StateStore* state_store() = 0;

  // The rules store is created at startup.
  virtual StateStore* rules_store() = 0;

  // Returns the |ValueStore| factory created at startup.
  virtual scoped_refptr<ValueStoreFactory> store_factory() = 0;

  // Returns the IO-thread-accessible extension data.
  virtual InfoMap* info_map() = 0;

  // Returns the QuotaService that limits calls to certain extension functions.
  // Lives on the UI thread. Created at startup.
  virtual QuotaService* quota_service() = 0;

  // Returns the AppSorting which provides an ordering for all installed apps.
  virtual AppSorting* app_sorting() = 0;

  // Called by the ExtensionService that lives in this system. Gives the
  // info map a chance to react to the load event before the EXTENSION_LOADED
  // notification has fired. The purpose for handling this event first is to
  // avoid race conditions by making sure URLRequestContexts learn about new
  // extensions before anything else needs them to know. This operation happens
  // asynchronously. |callback| is run on the calling thread once completed.
  virtual void RegisterExtensionWithRequestContexts(
      const Extension* extension,
      const base::Closure& callback) {}

  // Called by the ExtensionService that lives in this system. Lets the
  // info map clean up its RequestContexts once all the listeners to the
  // EXTENSION_UNLOADED notification have finished running.
  virtual void UnregisterExtensionWithRequestContexts(
      const std::string& extension_id,
      const UnloadedExtensionInfo::Reason reason) {}

  // Signaled when the extension system has completed its startup tasks.
  virtual const OneShotEvent& ready() const = 0;

  // Returns the content verifier, if any.
  virtual ContentVerifier* content_verifier() = 0;

  // Get a set of extensions that depend on the given extension.
  // TODO(elijahtaylor): Move SharedModuleService out of chrome/browser
  // so it can be retrieved from ExtensionSystem directly.
  virtual scoped_ptr<ExtensionSet> GetDependentExtensions(
      const Extension* extension) = 0;

  // Install an updated version of |extension_id| with the version given in
  // temp_dir. Ownership of |temp_dir| in the filesystem is transferred and
  // implementors of this function are responsible for cleaning it up on
  // errors, etc.
  virtual void InstallUpdate(const std::string& extension_id,
                             const base::FilePath& temp_dir) = 0;
};

}  // namespace extensions

#endif  // EXTENSIONS_BROWSER_EXTENSION_SYSTEM_H_


text:
<BroadcastMonitor>
  <updated>2015-08-03T21:20:33</updated>
  <stationName>Radio 6</stationName>
  <Current>
    <startTime>2015-08-03T21:18:31</startTime>
    <itemId>1000080516:1242591</itemId>
    <titleId>216138795</titleId>
    <itemCode>10647</itemCode>
    <itemReference></itemReference>
    <titleName>Both Sides Now</titleName>
    <artistName>Cilla Black</artistName>
    <albumName></albumName>
    <CategoryCode>902</CategoryCode>
    <CategoryName>UITZENDING</CategoryName>
    <itemDuration>133</itemDuration>
    <MultiMedia1></MultiMedia1>
    <MultiMedia2></MultiMedia2>
    <MultiMedia3></MultiMedia3>
    <MultiMedia4></MultiMedia4>
  </Current>
  <Next>
    <startTime>2015-08-03T21:20:43</startTime>
    <itemId>1000080516:1242587</itemId>
    <titleId>216138788</titleId>
    <itemCode>10642</itemCode>
    <itemReference></itemReference>
    <titleName>You've Lost That Lovin' Feelin'</titleName>
    <artistName>Cilla Black</artistName>
    <albumName></albumName>
    <CategoryCode>902</CategoryCode>
    <CategoryName>UITZENDING</CategoryName>
    <itemDuration>186</itemDuration>
    <MultiMedia1></MultiMedia1>
    <MultiMedia2></MultiMedia2>
    <MultiMedia3></MultiMedia3>
    <MultiMedia4></MultiMedia4>
  </Next>
</BroadcastMonitor>


text:
package model

import (
	"encoding/json"
	"io/ioutil"
)

type DistributedConfig struct {
	AppName       string
	IsMaster      bool
	ThreadNum     int
	LockerTimeout int
	ZkTimeOut     int
	ZkHosts       []string
}

func GetDistributedConfigFromPath(path string) (*DistributedConfig, error) {
	var config DistributedConfig
	data, err := ioutil.ReadFile(path)
	if err != nil {
		return &config, err
	}
	err = json.Unmarshal(data, &config)
	return &config, err
}


text:
<!--title:Using Entity Framework Core with Jasper-->

The `Jasper.Persistence.EntityFrameworkCore` Nuget can be used with a Jasper application to add support for
using [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/) in the Jasper:

* `[Transactional]` middleware
* [Outbox](https://microservices.io/patterns/data/transactional-outbox.html) support
* <[linkto:documentation/execution/sagas;title=Saga persistence]>

Note that you will **also** need
to use one of the database backed message persistence mechanisms like <[linkto:documentation/durability/sqlserver;title=Jasper.Persistence.SqlServer]> or <[linkto:documentation/durability/postgresql;title=Jasper.Persistence.Postgresql]> in conjunction with the EF Core integration.

As an example of using the EF Core integration with Sql Server inside a Jasper application,
see the [the InMemoryMediator sample project](https://github.com/JasperFx/JasperSamples/tree/master/InMemoryMediator).

Assuming that `Jasper.Persistence.EntityFrameworkCore` is referenced by your application, here's a custom
[DbContext]() type from the [sample project](https://github.com/JasperFx/JasperSamples/tree/master/InMemoryMediator):

snippet: sample_ItemsDbContext

Most of this is just standard EF Core. The only Jasper specific thing is the call
to `modelBuilder.MapEnvelopeStorage()` in the `OnModelCreating()` method. This adds mappings
to Jasper's <[linkto:documentation/durability;title=message persistence]> and allowing
the `ItemsDbContext` objects to enroll in Jasper outbox transactions.

::: tip warning
You will have to explicitly opt into a specific database persistence for the messaging **and**
also explicitly add in the EF Core transactional support.
:::

Now, to wire up EF Core into our Jasper application and add Sql Server-backed message persistence, use
this <[linkto:documentation/bootstrapping;title=JasperOptions]> class:

snippet: sample_InMemoryMediator_JasperConfig

There's a couple things to note in the code above:

* The call to `Extensions.PersistMessagesWithSqlServer()` sets up the Sql Server backed message persistence
* The `AddDbContext<ItemsDbContext>()` call is just the normal EF Core set up, with one difference. **It's
  a possibly significant performance optimization to mark `optionsLifetime` as singleton scoped** because
  Jasper will be able to generate more efficient handler pipeline code for message handlers that use
  your EF Core `DbContext`.

## Transactional Support and Outbox Usage

First, let's look at using the EF Core-backed outbox usage in the following MVC controller method that:

1. Starts an outbox transaction with `ItemsDbContext` and `IMessageContext` (Jasper's main entrypoint for messaging)
1. Accepts a `CreateItemCommand` command input
1. Creates and saves a new `Item` entity with `ItemsDbContext`
1. Also creates and publishes a matching `ItemCreated` event for any interested subscribers
1. Commits the unit of work
1. Flushes out the newly persisted `ItemCreated` outgoing message to Jasper's sending agents

snippet: sample_InMemoryMediator_DoItAllMyselfItemController

Outside of a Jasper <[linkto:documentation/execution/handlers;title=message handler]>, you will have to explicitly
*enlist* a Jasper `IMessageContext` in a `DbContext` unit of work through the `EnlistInTransaction(DbContext)`
extension method. Secondly, after calling `DbContext.SaveChangesAsync()`, you'll need to manually call
`IMessageContext.SendAllQueuedOutgoingMessages()` to actually release the newly persisted `ItemCreated`
event message to be be sent. If your application somehow manages to crash between the successful call
to `SaveChangesAsync()` and the `ItemCreated` message actually being delivered by Jasper to wherever it
was supposed to go, not to worry. The outgoing message is persisted and will be sent either by restarting
the application or by failing over to another running node of your application.

Alright, that was some busy code, so let's see how this can be cleaner running inside a Jasper message
handler that takes advantage of the `[Transactional]` middleware:

snippet: sample_InMemoryMediator_Items

The code above effectively does the same thing as the `DoItAllMyselfItemController` shown earlier,
but Jasper is generating some middleware code around the `ItemHandler.Handle()` method to enlist
the scoped `IMessageContext` object into the scoped `ItemsDbContext` unit of work. That same middleware is
coming behind the call to `Item.Handler()` and both saving the changes in `ItemsDbContext` and pushing out
any newly persisted cascading messages.

## Saga Persistence

If the `Jasper.Persistence.EntityFrameworkCore` Nuget is referenced, your Jasper application can use custom `DbContext` types
as the <[linkto:documentation/execution/sagas;title=saga persistence mechanism]>. There's just a couple things to know:

1. The primary key / identity for the state document has to be either an `int`, `long`, `string`, or `System.Guid`
1. Jasper analyzes the dependency tree of your `StatefulSagaOf<TState>` handler class for a Lamar dependency that inherits
   from `DbContext`, and if it finds exactly 1 dependency, that is assumed to be used for persisting the state
1. All saga message handlers are automatically wrapped with the transactional middleware
1. You will have to have EF Core mapping for the .NET state type of your saga handler


text:
<!doctype html>

	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>RTTPingerOptions | mongodb</title>
	<meta name="description" content="Documentation for mongodb">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="../assets/css/main.css">

						Search
						<input id="tsd-search-field" type="text" />

Preparing search index...

The search index is not available

					mongodb

						Options

								All

Public

Public/Protected

All

							<input type="checkbox" id="tsd-filter-inherited" checked />
							Inherited
							<input type="checkbox" id="tsd-filter-externals" checked />
							Externals

					Menu

					mongodb

					RTTPingerOptions

Interface RTTPingerOptions

internal

Hierarchy

						ConnectionOptions

								RTTPingerOptions

Index

Properties

ALPNProtocols

auto<wbr>Encrypter

ca

cancellation<wbr>Token

cert

check<wbr>Server<wbr>Identity

ciphers

compressors

connect<wbr>TimeoutMS

connection<wbr>Type

credentials

crl

ecdh<wbr>Curve

family

generation

heartbeat<wbr>FrequencyMS

hints

host<wbr>Address

id

keep<wbr>Alive

keep<wbr>Alive<wbr>Initial<wbr>Delay

key

local<wbr>Address

local<wbr>Port

lookup

metadata

minDHSize

monitor<wbr>Commands

no<wbr>Delay

passphrase

pfx

reject<wbr>Unauthorized

secure<wbr>Context

secure<wbr>Protocol

server<wbr>Api

servername

session

socket<wbr>TimeoutMS

tls

Properties

Optional ALPNProtocols

ALPNProtocols: Uint8Array | string[] | Uint8Array[]

Inherited from ConnectionOptions.ALPNProtocols

Defined in node_modules/@types/node/tls.d.ts:376

An array of strings or a Buffer naming possible ALPN protocols.
							(Protocols should be ordered by their priority.)

Optional auto<wbr>Encrypter

auto<wbr>Encrypter: AutoEncrypter

Inherited from ConnectionOptions.autoEncrypter

Defined in src/cmap/connection.ts:124

Optional ca

ca: string | Buffer | (string | Buffer)[]

Inherited from ConnectionOptions.ca

Defined in node_modules/@types/node/tls.d.ts:583

Optionally override the trusted CA certificates. Default is to trust
								the well-known CAs curated by Mozilla. Mozilla's CAs are completely
							replaced when CAs are explicitly specified using this option.

Optional cancellation<wbr>Token

cancellation<wbr>Token: CancellationToken

Inherited from ConnectionOptions.cancellationToken

Defined in src/cmap/connection.ts:136

Optional cert

cert: string | Buffer | (string | Buffer)[]

Inherited from ConnectionOptions.cert

Defined in node_modules/@types/node/tls.d.ts:595

 Cert chains in PEM format. One cert chain should be provided per
								private key. Each cert chain should consist of the PEM formatted
								certificate for a provided private key, followed by the PEM
								formatted intermediate certificates (if any), in order, and not
								including the root CA (the root CA must be pre-known to the peer,
								see ca). When providing multiple cert chains, they do not have to
								be in the same order as their private keys in key. If the
								intermediate certificates are not provided, the peer will not be
							able to validate the certificate, and the handshake will fail.

Optional check<wbr>Server<wbr>Identity

check<wbr>Server<wbr>Identity: (host: string, cert: PeerCertificate) => Error | undefined

Inherited from ConnectionOptions.checkServerIdentity

Defined in node_modules/@types/node/tls.d.ts:455

Type declaration

(host: string, cert: PeerCertificate): Error | undefined

Parameters

host: string

cert: PeerCertificate

Returns Error | undefined

Optional ciphers

ciphers: string

Inherited from ConnectionOptions.ciphers

Defined in node_modules/@types/node/tls.d.ts:609

Cipher suite specification, replacing the default. For more
								information, see modifying the default cipher suite. Permitted
								ciphers can be obtained via tls.getCiphers(). Cipher names must be
							uppercased in order for OpenSSL to accept them.

Optional compressors

compressors: ("none" | "snappy" | "zlib")[]

Inherited from ConnectionOptions.compressors

Defined in src/cmap/stream_description.ts:17

Optional connect<wbr>TimeoutMS

connect<wbr>TimeoutMS: number

Inherited from ConnectionOptions.connectTimeoutMS

Defined in src/cmap/connection.ts:130

Optional connection<wbr>Type

connection<wbr>Type: typeof Connection

Inherited from ConnectionOptions.connectionType

Defined in src/cmap/connection.ts:128

internal

Optional credentials

credentials: MongoCredentials

Inherited from ConnectionOptions.credentials

Defined in src/cmap/connection.ts:129

Optional crl

crl: string | Buffer | (string | Buffer)[]

Inherited from ConnectionOptions.crl

Defined in node_modules/@types/node/tls.d.ts:617

PEM formatted CRLs (Certificate Revocation Lists).

Optional ecdh<wbr>Curve

ecdh<wbr>Curve: string

Inherited from ConnectionOptions.ecdhCurve

Defined in node_modules/@types/node/tls.d.ts:636

A string describing a named curve or a colon separated list of curve
								NIDs or names, for example P-521:P-384:P-256, to use for ECDH key
								agreement. Set to auto to select the curve automatically. Use
								crypto.getCurves() to obtain a list of available curve names. On
								recent releases, openssl ecparam -list_curves will also display the
								name and description of each available elliptic curve. Default:
							tls.DEFAULT_ECDH_CURVE.

Optional family

family: number

Inherited from ConnectionOptions.family

Defined in node_modules/@types/node/net.d.ts:50

generation

generation: number

Inherited from ConnectionOptions.generation

Defined in src/cmap/connection.ts:121

heartbeat<wbr>FrequencyMS

heartbeat<wbr>FrequencyMS: number

Defined in src/sdam/monitor.ts:377

Optional hints

hints: number

Inherited from ConnectionOptions.hints

Defined in node_modules/@types/node/net.d.ts:49

host<wbr>Address

host<wbr>Address: HostAddress

Inherited from ConnectionOptions.hostAddress

Defined in src/cmap/connection.ts:122

id

id: number | "<monitor>"

Inherited from ConnectionOptions.id

Defined in src/cmap/connection.ts:120

Optional keep<wbr>Alive

keep<wbr>Alive: boolean

Inherited from ConnectionOptions.keepAlive

Defined in src/cmap/connection.ts:132

Optional keep<wbr>Alive<wbr>Initial<wbr>Delay

keep<wbr>Alive<wbr>Initial<wbr>Delay: number

Inherited from ConnectionOptions.keepAliveInitialDelay

Defined in src/cmap/connection.ts:133

Optional key

key: string | Buffer | (Buffer | KeyObject)[]

Inherited from ConnectionOptions.key

Defined in node_modules/@types/node/tls.d.ts:653

Private keys in PEM format. PEM allows the option of private keys
								being encrypted. Encrypted keys will be decrypted with
								options.passphrase. Multiple keys using different algorithms can be
								provided either as an array of unencrypted key strings or buffers,
								or an array of objects in the form {pem: <string|buffer>[,
								passphrase: <string>]}. The object form can only occur in an array.
									object.passphrase is optional. Encrypted keys will be decrypted with
							object.passphrase if provided, or options.passphrase if it is not.

Optional local<wbr>Address

local<wbr>Address: string

Inherited from ConnectionOptions.localAddress

Defined in node_modules/@types/node/net.d.ts:47

Optional local<wbr>Port

local<wbr>Port: number

Inherited from ConnectionOptions.localPort

Defined in node_modules/@types/node/net.d.ts:48

Optional lookup

lookup: LookupFunction

Inherited from ConnectionOptions.lookup

Defined in node_modules/@types/node/net.d.ts:51

metadata

metadata: ClientMetadata

Inherited from ConnectionOptions.metadata

Defined in src/cmap/connection.ts:138

Optional minDHSize

minDHSize: number

Inherited from ConnectionOptions.minDHSize

Defined in node_modules/@types/node/tls.d.ts:458

monitor<wbr>Commands

monitor<wbr>Commands: boolean

Inherited from ConnectionOptions.monitorCommands

Defined in src/cmap/connection.ts:126

Optional no<wbr>Delay

no<wbr>Delay: boolean

Inherited from ConnectionOptions.noDelay

Defined in src/cmap/connection.ts:134

Optional passphrase

passphrase: string

Inherited from ConnectionOptions.passphrase

Defined in node_modules/@types/node/tls.d.ts:688

Shared passphrase used for a single private key and/or a PFX.

Optional pfx

pfx: string | Buffer | (string | Buffer | PxfObject)[]

Inherited from ConnectionOptions.pfx

Defined in node_modules/@types/node/tls.d.ts:699

PFX or PKCS12 encoded private key and certificate chain. pfx is an
								alternative to providing key and cert individually. PFX is usually
								encrypted, if it is, passphrase will be used to decrypt it. Multiple
								PFX can be provided either as an array of unencrypted PFX buffers,
								or an array of objects in the form {buf: <string|buffer>[,
								passphrase: <string>]}. The object form can only occur in an array.
									object.passphrase is optional. Encrypted PFX will be decrypted with
							object.passphrase if provided, or options.passphrase if it is not.

Optional reject<wbr>Unauthorized

reject<wbr>Unauthorized: boolean

Inherited from ConnectionOptions.rejectUnauthorized

Defined in node_modules/@types/node/tls.d.ts:393

If true the server will reject any connection which is not
								authorized with the list of supplied CAs. This option only has an
							effect if requestCert is true.

default

true

Optional secure<wbr>Context

secure<wbr>Context: SecureContext

Inherited from ConnectionOptions.secureContext

Defined in node_modules/@types/node/tls.d.ts:358

An optional TLS context object from tls.createSecureContext()

Optional secure<wbr>Protocol

secure<wbr>Protocol: string

Inherited from ConnectionOptions.secureProtocol

Defined in node_modules/@types/node/tls.d.ts:717

Legacy mechanism to select the TLS protocol version to use, it does
								not support independent control of the minimum and maximum version,
								and does not support limiting the protocol to TLSv1.3. Use
								minVersion and maxVersion instead. The possible values are listed as
								SSL_METHODS, use the function names as strings. For example, use
								'TLSv1_1_method' to force TLS version 1.1, or 'TLS_method' to allow
								any TLS protocol version up to TLSv1.3. It is not recommended to use
								TLS versions less than 1.2, but it may be required for
							interoperability. Default: none, see minVersion.

Optional server<wbr>Api

server<wbr>Api: ServerApi

Inherited from ConnectionOptions.serverApi

Defined in src/cmap/connection.ts:125

Optional servername

servername: string

Inherited from ConnectionOptions.servername

Defined in node_modules/@types/node/tls.d.ts:456

Optional session

session: Buffer

Inherited from ConnectionOptions.session

Defined in node_modules/@types/node/tls.d.ts:457

Optional socket<wbr>TimeoutMS

socket<wbr>TimeoutMS: number

Inherited from ConnectionOptions.socketTimeoutMS

Defined in src/cmap/connection.ts:135

tls

tls: boolean

Inherited from ConnectionOptions.tls

Defined in src/cmap/connection.ts:131

						Exports

						RTTPinger<wbr>Options

								ALPNProtocols

								auto<wbr>Encrypter

								ca

								cancellation<wbr>Token

								cert

								check<wbr>Server<wbr>Identity

								ciphers

								compressors

								connect<wbr>TimeoutMS

								connection<wbr>Type

								credentials

								crl

								ecdh<wbr>Curve

								family

								generation

								heartbeat<wbr>FrequencyMS

								hints

								host<wbr>Address

								id

								keep<wbr>Alive

								keep<wbr>Alive<wbr>Initial<wbr>Delay

								key

								local<wbr>Address

								local<wbr>Port

								lookup

								metadata

								minDHSize

								monitor<wbr>Commands

								no<wbr>Delay

								passphrase

								pfx

								reject<wbr>Unauthorized

								secure<wbr>Context

								secure<wbr>Protocol

								server<wbr>Api

								servername

								session

								socket<wbr>TimeoutMS

								tls

Legend

Constructor

Property

Method

Accessor

Inherited constructor

Inherited property

Inherited method

Inherited accessor

Constructor

Property

Method

Private property

Private method

Static property

Static method

Generated using TypeDoc


text:
. /home/dbadmin/.bashrc
PATH=/usr/local/bin:/opt/vertica/bin:${PATH}
autoscaleDir=/home/dbadmin/autoscale
. $autoscaleDir/autoscaling_vars.sh
time=$( date +"%Y-%m-%d %H:%M:%S")

# in non terminal mode, redirect stdout and stderr to logfile
if [ ! -t 0 ]; then exec >> $autoscaleDir/read_scaledown_queue.log 2>&1; fi
echo read_scaledown_queue.sh: [`date`]

# Get this node's IP
myIp=$(hostname -I | awk '{print $NF}')

# Get URL for ScaleDown SQS queue
scaleDown_url=$( aws --output=text sqs list-queues | grep "${autoscaling_group_name}_ScaleDown" | awk '{print $2}')

# Read and parse all pending messages, one at a time
i=0
while [ 1 ]; do
   # read queue
   # (a scaleDown may involve multiple instances / messages - we want to read them all)
   msg=$(aws --output=json sqs receive-message --wait-time-seconds 20 --queue-url $scaleDown_url)
   [ -z "$msg" ] && break  # no more messages waiting
   msgBody=$(echo "$msg" | python -c 'import sys, json; print json.load(sys.stdin)["Messages"][0]["Body"]')
   msgHandle=$(echo "$msg" | python -c 'import sys, json; print json.load(sys.stdin)["Messages"][0]["ReceiptHandle"]')
   echo $msgBody | grep "TEST_NOTIFICATION" > /dev/null
   if [ ! $? -eq 0 ]; then
      echo "ScaleDown SQS Message Received - $msgBody"
      lifecycleTransition=$(echo "$msgBody" | python -c 'import sys, json; print json.load(sys.stdin)["LifecycleTransition"]')
      lifecycleActionToken=$(echo "$msgBody" | python -c 'import sys, json; print json.load(sys.stdin)["LifecycleActionToken"]')
      eC2InstanceId=$(echo "$msgBody" | python -c 'import sys, json; print json.load(sys.stdin)["EC2InstanceId"]')
      privateIp=$(vsql -qAt -c "select distinct nvl(replace_node_address,node_address) from autoscale.launches where ec2_instanceid='$eC2InstanceId'")
      if [ ! -z "$privateIp" ]; then
         publicIp=$(vsql -qAt -c "select distinct node_public_address from autoscale.launches where ec2_instanceid='$eC2InstanceId'")
         # Add each terminating instance to the autoscale.terminations table
         echo "$myIp|$time|$eC2InstanceId|$privateIp|$publicIp|$lifecycleActionToken|COLLATING INSTANCES|1" | vsql -c "COPY autoscale.terminations (queued_by_node, start_time, ec2_instanceid, node_address, node_public_address, lifecycle_action_token, status, is_running) FROM STDIN"
         if [ $? -ne 0 ]; then
            echo Unable to add to autoscale.terminations - exiting without deleting message
            exit 1
         fi
         echo "Node [$privateIp] queued for termination"
         ((i=i+1))
      else
         echo "No Private IP found for [$eC2InstanceId] in autoscale.launches. Perhaps a rogue (old) message? Skipping"
      fi
   else
      echo "Skipping unimportant message: autoscaling:TEST_NOTIFICATION => $msgBody"
   fi
   aws sqs delete-message --queue-url $scaleDown_url --receipt-handle $msgHandle
   echo "Message deleted from SQS queue"
done
numMessages=$i
if [ $numMessages -eq 0 ]; then
   # echo "No pending ScaleDown messages - exiting"
   exit 0
else
   echo "ScaleDown: $numMessages nodes queued for termination"
fi

# make sure termination list has settled - ie that nodes aren't still being added
lastCount=0
thisCount=$(vsql -qAt -c "select count(*) from autoscale.terminations where is_running")
while [ $lastCount -ne $thisCount ]; do
   echo Ensure queued node count is stable - $thisCount nodes. Sleep 30s.
   lastCount=$thisCount
   sleep 30
   thisCount=$(vsql -qAt -c "select count(*) from autoscale.terminations where is_running")
done

# Remove nodes on an active DB node that is NOT currently queued for termination
connectTo=$(vsql -qAt -c "select node_address from nodes where node_state='UP' AND node_name NOT IN (select node_address from autoscale.terminations where is_running) ORDER BY node_name LIMIT 1")
if [ -z "$connectTo" ]; then
   echo "All nodes queued for deletion! Connect locally [$myIp]"
   connectTo=$myIp
fi
echo "connect to $connectTo and run remove_nodes()."
vsql -h $connectTo -c "select autoscale.remove_nodes()"

echo Done! [`date`]
exit 0


text:
"""Home of estimator related functions.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os
import re

from tensorflow.python.client import session
from tensorflow.python.estimator import estimator as estimator_lib
from tensorflow.python.estimator import export as export_lib
from tensorflow.python.estimator import model_fn as model_fn_lib
from tensorflow.python.framework import ops
from tensorflow.python.framework import random_seed
from tensorflow.python.framework import sparse_tensor as sparse_tensor_lib
from tensorflow.python.framework import tensor_util
from tensorflow.python.keras import backend as K
from tensorflow.python.keras import models
from tensorflow.python.keras import optimizers
from tensorflow.python.ops import check_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import metrics as metrics_module
from tensorflow.python.platform import gfile
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.saved_model import signature_constants
from tensorflow.python.training import checkpoint_management
from tensorflow.python.training import distribution_strategy_context
from tensorflow.python.training import optimizer as tf_optimizer_module
from tensorflow.python.training import saver as saver_lib
from tensorflow.python.training import training_util

_DEFAULT_SERVING_KEY = signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY

def _cast_tensor_to_floatx(x):
  """Cast tensor to keras's floatx dtype if it is not already the same dtype."""
  if x.dtype == K.floatx():
    return x
  else:
    return math_ops.cast(x, K.floatx())

def _convert_tensor(x):
  """Create or cast tensor if needed."""
  if not tensor_util.is_tensor(x):
    # x is a numpy array
    x = sparse_tensor_lib.convert_to_tensor_or_sparse_tensor(x)
  if check_ops.is_numeric_tensor(x):
    # is_numeric_tensor returns False if provided with a numpy array
    x = _cast_tensor_to_floatx(x)
  return x

def _any_weight_initialized(keras_model):
  """Check if any weights has been initialized in the Keras model.

  Args:
    keras_model: An instance of compiled keras model.

  Returns:
    boolean, True if at least one weight has been initialized, else False.
    Currently keras initialize all weights at get_session().
  """
  if keras_model is None:
    return False
  for layer in keras_model.layers:
    for weight in layer.weights:
      if hasattr(weight, '_keras_initialized'):
        return True
  return False

def _convert_estimator_io_to_keras(keras_model, features, labels):
  """Converts estimator features and labels to keras input and target tensors.

  Args:
    keras_model: a compiled `tf.keras.Model` instance, used to determine the
      order of the returned lists.
    features: Dict of tensors or `None`.
    labels: Dict of tensors, a single tensor, or `None`.

  Returns:
    Tuple of (
      list of input tensors or `None`,
      list of target tensors or `None`)
    The order of tensors is determined by the order set in the keras model.
  """

  def _to_ordered_tensor_list(obj, key_order, obj_name, order_name):
    """Convert obj to an ordered list of tensors.

    Args:
      obj: List, dict, or single tensor. May be `None`.
      key_order: List of strings with the order to return (used if obj is a
        dict).
      obj_name: String name of object (e.g. "features" or "labels")
      order_name: String name of the key order (e.g. "inputs" or "outputs")

    Returns:
      List of tensors, or `None`

    Raises:
      KeyError: If obj has invalid keys.
    """
    if obj is None:
      return None
    elif isinstance(obj, (list, tuple)):
      return [_convert_tensor(x) for x in obj]
    elif isinstance(obj, dict):
      # Ensure that the obj keys and keys in key_order are exactly the same.
      different_keys = set(obj.keys()) ^ set(key_order)

      if different_keys:
        raise KeyError(
            'The dictionary passed into {obj_name} does not have the expected '
            '{order_name} keys defined in the keras model.'
            '\n\tExpected keys: {order_keys}'
            '\n\t{obj_name} keys: {obj_keys}'
            '\n\tDifference: {different_keys}'.format(
                order_name=order_name, order_keys=set(key_order),
                obj_name=obj_name, obj_keys=set(obj.keys()),
                different_keys=different_keys))

      return [_convert_tensor(obj[key]) for key in key_order]
    else:  # Assume obj is a tensor.
      return [_convert_tensor(obj)]

  input_names = None
  output_names = None
  if isinstance(features, dict):
    input_names = (
        keras_model.input_names if keras_model._is_graph_network else
        ['input_%d' % i for i in range(1, len(features) + 1)])
  if isinstance(labels, dict):
    output_names = (
        keras_model.output_names if keras_model._is_graph_network else
        ['output_%d' % i for i in range(1, len(labels) + 1)])

  input_tensors = _to_ordered_tensor_list(
      features, input_names, 'features', 'inputs')
  target_tensors = _to_ordered_tensor_list(
      labels, output_names, 'labels', 'outputs')

  return input_tensors, target_tensors

def _clone_and_build_model(mode,
                           keras_model,
                           custom_objects,
                           features=None,
                           labels=None):
  """Clone and build the given keras_model.

  Args:
    mode: training mode.
    keras_model: an instance of compiled keras model.
    custom_objects: Dictionary for custom objects.
    features: Dict of tensors.
    labels: Dict of tensors, or single tensor instance.

  Returns:
    The newly built model.
  """
  # Set to True during training, False for inference or testing.
  K.set_learning_phase(mode == model_fn_lib.ModeKeys.TRAIN)
  input_tensors, target_tensors = _convert_estimator_io_to_keras(
      keras_model, features, labels)

  compile_clone = (mode != model_fn_lib.ModeKeys.PREDICT)

  global_step = None
  if compile_clone:
    # Set iterations to the global step created by tf.train.create_global_step()
    # which is automatically run in the estimator framework.
    global_step = training_util.get_or_create_global_step()
    K.track_variable(global_step)

  clone = models.clone_and_build_model(
      keras_model, input_tensors, target_tensors, custom_objects,
      compile_clone=compile_clone,
      in_place_reset=(not keras_model._is_graph_network),
      optimizer_iterations=global_step)

  return clone

def _convert_keras_metrics_to_estimator(model):
  """Convert metrics from a Keras model to ops used by the Estimator framework.

  Args:
    model: A `tf.keras.Model` object.

  Returns:
    Dictionary mapping metric names to tuples of (value, update) ops. May return
    `None` if the model does not contain any metrics.
  """
  if not getattr(model, 'metrics', None):
    return None

  # TODO(psv/fchollet): support stateful metrics
  eval_metric_ops = {}
  # When each metric maps to an output
  if isinstance(model.metrics, dict):
    for i, output_name in enumerate(model.metrics.keys()):
      metric_name = model.metrics[output_name]
      if callable(metric_name):
        metric_name = metric_name.__name__
      # When some outputs use the same metric
      if list(model.metrics.values()).count(metric_name) > 1:
        metric_name += '_' + output_name
      eval_metric_ops[metric_name] = metrics_module.mean(
          model.metrics_tensors[i - len(model.metrics)])
  else:
    for i, metric_name in enumerate(model.metrics):
      if callable(metric_name):
        metric_name = metric_name.__name__
      eval_metric_ops[metric_name] = metrics_module.mean(
          model.metrics_tensors[i])
  return eval_metric_ops

def _create_keras_model_fn(keras_model, custom_objects=None):
  """Creates model_fn for keras Estimator.

  Args:
    keras_model: an instance of compiled keras model.
    custom_objects: Dictionary for custom objects.

  Returns:
    The model_fn for a keras Estimator.
  """

  def model_fn(features, labels, mode):
    """model_fn for keras Estimator."""
    # Raise an error when users use DistributionStrategy with native Keras
    # optimizers. Currently we only support native TensorFlow optimizers.
    if distribution_strategy_context.has_distribution_strategy() and \
        not isinstance(keras_model.optimizer,
                       (tf_optimizer_module.Optimizer, optimizers.TFOptimizer)):
      raise ValueError('Only TensorFlow native optimizers are supported with '
                       'DistributionStrategy.')

    model = _clone_and_build_model(mode, keras_model, custom_objects, features,
                                   labels)
    model_output_names = []
    # We need to make sure that the output names of the last layer in the model
    # is the same for each of the cloned models. This is required for mirrored
    # strategy when we call regroup.
    if distribution_strategy_context.has_distribution_strategy():
      for name in model.output_names:
        name = re.compile(r'_\d$').sub('', name)
        model_output_names.append(name)
    else:
      model_output_names = model.output_names

    # Get inputs to EstimatorSpec
    predictions = dict(zip(model_output_names, model.outputs))

    loss = None
    train_op = None
    eval_metric_ops = None

    # Set loss and metric only during train and evaluate.
    if mode is not model_fn_lib.ModeKeys.PREDICT:
      if mode is model_fn_lib.ModeKeys.TRAIN:
        model._make_train_function()  # pylint: disable=protected-access
      else:
        model._make_test_function()  # pylint: disable=protected-access
      loss = model.total_loss

      eval_metric_ops = _convert_keras_metrics_to_estimator(model)

    # Set train_op only during train.
    if mode is model_fn_lib.ModeKeys.TRAIN:
      train_op = model.train_function.updates_op

    if not model._is_graph_network:
      # Reset model state to original state,
      # to avoid `model_fn` being destructive for the initial model argument.
      models.in_place_subclassed_model_state_restoration(keras_model)
    return model_fn_lib.EstimatorSpec(
        mode=mode,
        predictions=predictions,
        loss=loss,
        train_op=train_op,
        eval_metric_ops=eval_metric_ops,
        export_outputs={
            _DEFAULT_SERVING_KEY:
            export_lib.export_output.PredictOutput(predictions)
        })

  return model_fn

def _save_first_checkpoint(keras_model, custom_objects, config):
  """Save first checkpoint for the keras Estimator.

  Args:
    keras_model: an instance of compiled keras model.
    custom_objects: Dictionary for custom objects.
    config: Estimator config.

  Returns:
    The path where keras model checkpoint is saved.
  """
  # save checkpoint into subdirectory to allow warm start
  keras_model_dir = os.path.join(config.model_dir, 'keras')
  # Load weights and save to checkpoint if there is no checkpoint
  latest_path = checkpoint_management.latest_checkpoint(keras_model_dir)
  if not latest_path:
    keras_weights = None
    if _any_weight_initialized(keras_model):
      keras_weights = keras_model.get_weights()
    if not gfile.IsDirectory(keras_model_dir):
      gfile.MakeDirs(keras_model_dir)
    with ops.Graph().as_default():
      random_seed.set_random_seed(config.tf_random_seed)
      training_util.create_global_step()
      model = _clone_and_build_model(model_fn_lib.ModeKeys.TRAIN, keras_model,
                                     custom_objects)
      # save to checkpoint
      with session.Session(config=config.session_config) as sess:
        if keras_weights:
          model.set_weights(keras_weights)
        # Make update ops and initialize all variables.
        if not model.train_function:
          # pylint: disable=protected-access
          model._make_train_function()
          K._initialize_variables(sess)
          # pylint: enable=protected-access
        saver = saver_lib.Saver()
        latest_path = os.path.join(keras_model_dir, 'keras_model.ckpt')
        saver.save(sess, latest_path)
  return latest_path

def model_to_estimator(keras_model=None,
                       keras_model_path=None,
                       custom_objects=None,
                       model_dir=None,
                       config=None):
  """Constructs an `Estimator` instance from given keras model.

  For usage example, please see:
  [Creating estimators from Keras
  Models](https://tensorflow.org/guide/estimators#model_to_estimator).

  Args:
    keras_model: A compiled Keras model object. This argument is mutually
      exclusive with `keras_model_path`.
    keras_model_path: Path to a compiled Keras model saved on disk, in HDF5
      format, which can be generated with the `save()` method of a Keras model.
      This argument is mutually exclusive with `keras_model`.
    custom_objects: Dictionary for custom objects.
    model_dir: Directory to save `Estimator` model parameters, graph, summary
      files for TensorBoard, etc.
    config: `RunConfig` to config `Estimator`.

  Returns:
    An Estimator from given keras model.

  Raises:
    ValueError: if neither keras_model nor keras_model_path was given.
    ValueError: if both keras_model and keras_model_path was given.
    ValueError: if the keras_model_path is a GCS URI.
    ValueError: if keras_model has not been compiled.
  """
  if not (keras_model or keras_model_path):
    raise ValueError(
        'Either `keras_model` or `keras_model_path` needs to be provided.')
  if keras_model and keras_model_path:
    raise ValueError(
        'Please specity either `keras_model` or `keras_model_path`, '
        'but not both.')

  if not keras_model:
    if keras_model_path.startswith(
        'gs://') or 'storage.googleapis.com' in keras_model_path:
      raise ValueError(
          '%s is not a local path. Please copy the model locally first.' %
          keras_model_path)
    logging.info('Loading models from %s', keras_model_path)
    keras_model = models.load_model(keras_model_path)
  else:
    logging.info('Using the Keras model provided.')
    keras_model = keras_model

  if not hasattr(keras_model, 'optimizer') or not keras_model.optimizer:
    raise ValueError(
        'The given keras model has not been compiled yet. '
        'Please compile the model with `model.compile()` '
        'before calling `model_to_estimator()`.')

  config = estimator_lib.maybe_overwrite_model_dir_and_session_config(config,
                                                                      model_dir)

  keras_model_fn = _create_keras_model_fn(keras_model, custom_objects)
  if _any_weight_initialized(keras_model):
    # Warn if config passed to estimator tries to update GPUOptions. If a
    # session has already been created, the GPUOptions passed to the first
    # session sticks.
    if config.session_config.HasField('gpu_options'):
      logging.warning(
          'The Keras backend session has already been set. '
          'The _session_config passed to model_to_estimator will not be used.')
  else:
    # Pass the config into keras backend's default session.
    sess = session.Session(config=config.session_config)
    K.set_session(sess)

  warm_start_path = None
  if keras_model._is_graph_network:
    warm_start_path = _save_first_checkpoint(keras_model, custom_objects,
                                             config)
  elif keras_model.built:
    logging.warning('You are creating an Estimator from a Keras model manually '
                    'subclassed from `Model`, that was already called on some '
                    'inputs (and thus already had weights). We are currently '
                    'unable to preserve the model\'s state (its weights) as '
                    'part of the estimator in this case. Be warned that the '
                    'estimator has been created using a freshly initialized '
                    'version of your model.\n'
                    'Note that this doesn\'t affect the state of the model '
                    'instance you passed as `keras_model` argument.')

  estimator = estimator_lib.Estimator(keras_model_fn,
                                      config=config,
                                      warm_start_from=warm_start_path)

  return estimator


text:
InputWidget для текстовых полей на основе tinyMce
===================
Установка:
```bash
$ php composer.phar require developeruz/yii2-tinymce-widget "*"
```
###Простое использование###
```php
use developeruz\tinyMce\TinyMce;

    echo TinyMce::widget( [
            'name' => 'content',
            'options' => ['rows' => 6], // параметры передаваемые в Html::textarea
            'clientOptions' => [        // параметры передаваемые в tinymce.init()
                'language' => 'ru',
            ],
        ]);
    ?>
```

###Использование c ActiveForm###
```php
use developeruz\tinyMce\TinyMce;

    echo $form->field($model, 'content')->widget(TinyMce::className(), [
        'options' => ['rows' => 6], // параметры передаваемые в Html::textarea
        'clientOptions' => [        // параметры передаваемые в tinymce.init()
            'language' => 'ru',
        ],
    ]);
```


text:
goog.provide('shaka.offline.indexeddb.V5StorageCell');

goog.require('shaka.offline.indexeddb.BaseStorageCell');

/**
 * The V5StorageCell is for all stores that follow the shaka.externs V5 offline
 * types introduced in v3.0.
 *
 * @implements {shaka.extern.StorageCell}
 */
shaka.offline.indexeddb.V5StorageCell = class
  extends shaka.offline.indexeddb.BaseStorageCell {
  /** @override */
  hasFixedKeySpace() {
    // This makes the cell read-write.
    return false;
  }

  /** @override */
  addSegments(segments) {
    return this.add(this.segmentStore_, segments);
  }

  /** @override */
  addManifests(manifests) {
    return this.add(this.manifestStore_, manifests);
  }

  /** @override */
  updateManifest(key, manifest) {
    return this.updateManifestImplementation(key, manifest);
  }

  /** @override */
  convertManifest(old) {
    // JSON serialization turns Infinity into null, so turn it back now.
    if (old.expiration == null) {
      old.expiration = Infinity;
    }
    return Promise.resolve(/** @type {shaka.extern.ManifestDB} */(old));
  }
};


text:
using OfficeDevPnP.Core.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OfficeDevPnP.Core.Framework.Provisioning.Model
{
    /// <summary>
    /// Domain Object to define a tenant Site Design
    /// </summary>
    public partial class SiteDesign : BaseModel, IEquatable<SiteDesign>
    {
        #region Private Members

        private SiteDesignGrantCollection _grants;

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the Title for the SiteDesign
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// Gets or sets the Description flag for the SiteDesign
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets the IsDefault for the SiteDesign
        /// </summary>
        public bool IsDefault { get; set; }

        /// <summary>
        /// Gets or sets the WebTemplate flag for the SiteDesign
        /// </summary>
        public SiteDesignWebTemplate WebTemplate { get; set; }

        /// <summary>
        /// Gets or sets the PreviewImageUrl flag for the SiteDesign
        /// </summary>
        public string PreviewImageUrl { get; set; }

        /// <summary>
        /// Gets or sets the PreviewImageAltText flag for the SiteDesign
        /// </summary>
        public string PreviewImageAltText { get; set; }

        /// <summary>
        /// Gets or sets the list of SiteScripts for the SiteDesign
        /// </summary>
        public List<string> SiteScripts { get; set; } = new List<string>();

        /// <summary>
        /// Defines whether to overwrite the SiteDesign or not
        /// </summary>
        public Boolean Overwrite { get; set; }

        /// <summary>
        /// Gets or sets the list of Site Design Permission Right Grants
        /// </summary>
        public SiteDesignGrantCollection Grants
        {
            get
            {
                if (this._grants == null)
                {
                    this._grants = new SiteDesignGrantCollection(this.ParentTemplate);
                }
                return this._grants;
            }
            private set
            {
                if (this._grants != null)
                {
                    this._grants.ParentTemplate = null;
                }
                this._grants = value;
                if (this._grants != null)
                {
                    this._grants.ParentTemplate = this.ParentTemplate;
                }
            }
        }

        #endregion

        #region Constructors

        /// <summary>
        /// Default constructor
        /// </summary>
        public SiteDesign()
        {
            this.Grants = new SiteDesignGrantCollection(this.ParentTemplate);
        }

        #endregion

        #region Comparison code
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Returns HashCode</returns>
        public override int GetHashCode()
        {
            return (String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|",
                (this.Title != null ? this.Title.GetHashCode() : 0),
                (this.Description != null ? this.Description.GetHashCode() : 0),
                this.IsDefault.GetHashCode(),
                this.WebTemplate.GetHashCode(),
                (this.PreviewImageUrl != null ? this.PreviewImageUrl.GetHashCode() : 0),
                (this.PreviewImageAltText != null ? this.PreviewImageAltText.GetHashCode() : 0),
                this.SiteScripts.Aggregate(0, (acc, next) => acc += (next != null ? next.GetHashCode() : 0)),
                this.Overwrite.GetHashCode(),
                this.Grants.Aggregate(0, (acc, next) => acc += (next != null ? next.GetHashCode() : 0))
            ).GetHashCode());
        }

        /// <summary>
        /// Compares object with SiteDesign
        /// </summary>
        /// <param name="obj">Object</param>
        /// <returns>true if the current object is equal to the SiteDesign</returns>
        public override bool Equals(object obj)
        {
            if (!(obj is SiteDesign))
            {
                return (false);
            }
            return (Equals((SiteDesign)obj));
        }

        /// <summary>
        /// Compares SiteDesign object based on Title, Description, IsDefault, WebTemplate, PreviewImageUrl, PreviewImageAltText, Overwrite, and Grants properties.
        /// </summary>
        /// <param name="other">SiteDesign object</param>
        /// <returns>true if the SiteDesign object is equal to the current object; otherwise, false.</returns>
        public bool Equals(SiteDesign other)
        {
            if (other == null)
            {
                return (false);
            }

            return (this.Title == other.Title &&
                this.Description == other.Description &&
                this.IsDefault == other.IsDefault &&
                this.WebTemplate == other.WebTemplate &&
                this.PreviewImageUrl == other.PreviewImageUrl &&
                this.PreviewImageAltText == other.PreviewImageAltText &&
                this.SiteScripts.DeepEquals(other.SiteScripts) &&
                this.Overwrite == other.Overwrite &&
                this.Grants.DeepEquals(other.Grants)
                );
        }

        #endregion
    }

    /// <summary>
    /// WebTemplate IDs for Site Designs
    /// </summary>
    public enum SiteDesignWebTemplate
    {
        /// <summary>
        /// WebTemplate ID for a "modern" Team Site
        /// </summary>
        TeamSite = 64,
        /// <summary>
        /// WebTemplate ID for a "modern" Communication Site
        /// </summary>
        CommunicationSite = 68,
    }
}


text:
require "spec_helper.rb"

describe CompleteSet do
  it { is_expected.to belong_to :taxon }
  it { is_expected.to belong_to :user }
  it { is_expected.to belong_to :place }
  it { is_expected.to belong_to :source }
  it { is_expected.to have_many(:comments).dependent :destroy }

  it do
    is_expected.to validate_uniqueness_of(:taxon_id).scoped_to(:place_id)
                                                    .with_message "already has complete set for this place"
  end
  it { is_expected.to validate_presence_of :taxon }
  it { is_expected.to validate_presence_of :place }
end