text:
import React, {Component, PropTypes} from 'react';
import {View, Text, StyleSheet, ActionSheetIOS, TouchableHighlight} from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons';
import {Theme} from '../common/Themes';
import MediaUtility from '../../modules/MediaUtility';
import MessageService from '../../services/MessageService';

class MediaViewHeader extends Component{

    goBackToPrevPage(){
        this.props.router.pop();
    }

    handleGridDisplay(){
        this.props.router.toGalleryViewFromMediaViewer({threadId: this.props.threadId});
    }

    handleForward(){
        let activeMediaUrl = this.props.activeMediaUrl;
        if(activeMediaUrl){

        }
    }

    async handleShare(){
        let activeMediaUrl = this.props.activeMediaUrl;
        if(activeMediaUrl){
            let mediaUrl = activeMediaUrl.mediaUrl;
            if(mediaUrl && mediaUrl.startsWith("ph://")){
                let mediaUrlWithoutPrefix = MediaUtility.removePrefixFromLocalMediaIdentifier(mediaUrl);
                mediaUrl = await MediaUtility.getURLForMediaID(mediaUrlWithoutPrefix);
            }
            ActionSheetIOS.showShareActionSheetWithOptions({
                    url: mediaUrl,
                },
                (error) => console.log(error),
                (success, method) => {
                    var text;
                    if (success) {
                        text = `Shared via ${method}`;
                    } else {
                        text = 'You didn\'t share';
                    }
                    console.log(text);
                });
        }
    }

     handleDelete(){
        let activeMediaUrl = this.props.activeMediaUrl;
        if(activeMediaUrl){
            MessageService.deleteMessage(activeMediaUrl);
        }
    }

    render(){
        const { currentIndex, total } = this.props;

        return (
            <View style={[styles.paginationContainer]}>
                <View style={[styles.paginationBar]}>
                    <TouchableHighlight onPress={() => this.goBackToPrevPage()}>
                        <Text style={styles.closeText}>Close</Text>
                    </TouchableHighlight>
                    <Text style={styles.paginationText}>
                        <Text>
                            {currentIndex + 1}
                        </Text>
                        /{total}
                    </Text>
                    <TouchableHighlight onPress={() => this.handleGridDisplay()}>
                        <Icon name='md-apps'
                              style={styles.paginationIcon}/>
                    </TouchableHighlight>
                    <TouchableHighlight onPress={() => this.handleForward()}>
                        <Icon name='md-share-alt'
                              style={styles.paginationIcon}/>
                    </TouchableHighlight>
                    <TouchableHighlight onPress={() => this.handleShare()}>
                        <Icon name='md-share'
                              style={styles.paginationIcon}/>
                    </TouchableHighlight>
                    <TouchableHighlight onPress={() => this.handleDelete()}>
                        <Icon name='ios-trash'
                              style={styles.paginationIcon}/>
                    </TouchableHighlight>
                </View>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    paginationContainer: {
        position: 'absolute',
        bottom: 0,
        left: 0,
        right: 0,
        backgroundColor: 'black',
        height: 50,
        justifyContent: 'center',
    },
    paginationBar: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        margin: 16,
    },
    paginationText:{
        alignSelf: 'center',
        color: Theme.iconColor,
        fontSize: 16,
    },
    closeText:{
        alignSelf: 'center',
        color: Theme.iconColor,
        fontSize: 16,
        paddingTop: 6
    },
    paginationIcon:{
        padding: 3,
        fontSize : 22,
        color: Theme.iconColor
    }
});

MediaViewHeader.propTypes = {
    currentIndex: PropTypes.number.isRequired,
    threadId: PropTypes.number.isRequired,
    total: PropTypes.number.isRequired,
    activeMediaUrl: PropTypes.oneOfType([
        PropTypes.string,
        PropTypes.object,
    ]),
    router: PropTypes.object.isRequired
};

export default MediaViewHeader;


text:
namespace CloudFoundry.ViewModels
{
    public class AppConfigViewModel
    {
        public AppConfigurationOptions AppConfig { get; }
        public AppConfigViewModel(AppConfigurationOptions appConfig)
        {
            AppConfig = appConfig ?? new AppConfigurationOptions();
        }
    }
}

// Lab01 - Lab04 End

redpajama_set_name: RedPajamaGithub


text:
@implementation HXCell

+ (instancetype)loadFromNib:(UITableView *)table {
    NSString *name = NSStringFromClass(self);
    HXCell *cell = (HXCell *)[table dequeueReusableCellWithIdentifier:name];
    if (!cell) {
        cell = [[NSBundle mainBundle] loadNibNamed:name owner:nil options:nil].firstObject;
    }
    return cell;
}

@end


text:
package org.apache.flink.runtime.executiongraph;

import org.apache.flink.runtime.executiongraph.failover.flip1.ResultPartitionAvailabilityChecker;
import org.apache.flink.runtime.io.network.partition.PartitionTracker;
import org.apache.flink.runtime.io.network.partition.ResultPartitionID;
import org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID;

import java.util.function.Function;

import static org.apache.flink.util.Preconditions.checkNotNull;

/**
 * A {@link ResultPartitionAvailabilityChecker} which decides the intermediate result partition availability
 * based on whether the corresponding result partition in the execution graph is tracked.
 */
public class ExecutionGraphResultPartitionAvailabilityChecker implements ResultPartitionAvailabilityChecker {

	/** The function maps an IntermediateResultPartitionID to a ResultPartitionID. */
	private final Function<IntermediateResultPartitionID, ResultPartitionID> partitionIDMapper;

	/** The tracker that tracks all available result partitions. */
	private final PartitionTracker partitionTracker;

	ExecutionGraphResultPartitionAvailabilityChecker(
			final Function<IntermediateResultPartitionID, ResultPartitionID> partitionIDMapper,
			final PartitionTracker partitionTracker) {

		this.partitionIDMapper = checkNotNull(partitionIDMapper);
		this.partitionTracker = checkNotNull(partitionTracker);
	}

	@Override
	public boolean isAvailable(final IntermediateResultPartitionID resultPartitionID) {
		return partitionTracker.isPartitionTracked(partitionIDMapper.apply(resultPartitionID));
	}
}


text:
"""
@author: Chenglong Chen <c.chenglong@gmail.com>
@brief: process data
        - a bunck of processing
        - automated spelling correction
        - query expansion
        - extract product name for search_term and product_title

"""

import csv
import imp

import nltk
import regex
import numpy as np
import pandas as pd
import multiprocessing
from bs4 import BeautifulSoup
from collections import Counter

import config
from utils import ngram_utils, pkl_utils, logging_utils, time_utils
from spelling_checker import GoogleQuerySpellingChecker, AutoSpellingChecker

#--------------------------- Processor ---------------------------
## base class
## Most of the processings can be casted into the "pattern-replace" framework
class BaseReplacer:
    def __init__(self, pattern_replace_pair_list=[]):
        self.pattern_replace_pair_list = pattern_replace_pair_list
    def transform(self, text):
        for pattern, replace in self.pattern_replace_pair_list:
            try:
                text = regex.sub(pattern, replace, text)
            except:
                pass
        return regex.sub(r"\s+", " ", text).strip()

## deal with case
class LowerCaseConverter(BaseReplacer):
    """
    Traditional -> traditional
    """
    def transform(self, text):
        return text.lower()

class LowerUpperCaseSplitter(BaseReplacer):
    """
    homeBASICS Traditional Real Wood -> homeBASICS Traditional Real Wood

    hidden from viewDurable rich finishLimited lifetime warrantyEncapsulated panels ->
    hidden from view Durable rich finish limited lifetime warranty Encapsulated panels

    Dickies quality has been built into every product.Excellent visibilityDurable ->
    Dickies quality has been built into every product Excellent visibility Durable

    BAD CASE:
    shadeMature height: 36 in. - 48 in.Mature width
    minutesCovers up to 120 sq. ft.Cleans up
    PUT one UnitConverter before LowerUpperCaseSplitter

    Reference:
    https://www.kaggle.com/c/home-depot-product-search-relevance/forums/t/18472/typos-in-the-product-descriptions
    """
    def __init__(self):
        self.pattern_replace_pair_list = [
            (r"(\w)[\.?!]([A-Z])", r"\1 \2"),
            (r"(?<=( ))([a-z]+)([A-Z]+)", r"\2 \3"),
        ]

## deal with word replacement
# 1st solution in CrowdFlower
class WordReplacer(BaseReplacer):
    def __init__(self, replace_fname):
        self.replace_fname = replace_fname
        self.pattern_replace_pair_list = []
        for line in csv.reader(open(self.replace_fname)):
            if len(line) == 1 and line[0].startswith("#"):
                continue
            try:
                pattern = r"(?<=\W|^)%s(?=\W|$)"%line[0]
                replace = line[1]
                self.pattern_replace_pair_list.append( (pattern, replace) )
            except:
                print(line)
                pass

## deal with letters
class LetterLetterSplitter(BaseReplacer):
    """
    For letter and letter
    /:
    Cleaner/Conditioner -> Cleaner Conditioner

    -:
    Vinyl-Leather-Rubber -> Vinyl Leather Rubber

    For digit and digit, we keep it as we will generate some features via math operations,
    such as approximate height/width/area etc.
    /:
    3/4 -> 3/4

    -:
    1-1/4 -> 1-1/4
    """
    def __init__(self):
        self.pattern_replace_pair_list = [
            (r"([a-zA-Z]+)[/\-]([a-zA-Z]+)", r"\1 \2"),
        ]

## deal with digits and numbers
class DigitLetterSplitter(BaseReplacer):
    """
    x:
    1x1x1x1x1 -> 1 x 1 x 1 x 1 x 1
    19.875x31.5x1 -> 19.875 x 31.5 x 1

    -:
    1-Gang -> 1 Gang
    48-Light -> 48 Light

    .:
    includes a tile flange to further simplify installation.60 in. L x 36 in. W x 20 in. ->
    includes a tile flange to further simplify installation. 60 in. L x 36 in. W x 20 in.
    """
    def __init__(self):
        self.pattern_replace_pair_list = [
            (r"(\d+)[\.\-]*([a-zA-Z]+)", r"\1 \2"),
            (r"([a-zA-Z]+)[\.\-]*(\d+)", r"\1 \2"),
        ]

class DigitCommaDigitMerger(BaseReplacer):
    """
    1,000,000 -> 1000000
    """
    def __init__(self):
        self.pattern_replace_pair_list = [
            (r"(?<=\d+),(?=000)", r""),
        ]

class NumberDigitMapper(BaseReplacer):
    """
    one -> 1
    two -> 2
    """
    def __init__(self):
        numbers = [
            "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
            "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
            "nineteen", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"
        ]
        digits = [
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
            16, 17, 18, 19, 20, 30, 40, 50, 60, 70, 80, 90
        ]
        self.pattern_replace_pair_list = [
            (r"(?<=\W|^)%s(?=\W|$)"%n, str(d)) for n,d in zip(numbers, digits)
        ]

## deal with unit
class UnitConverter(BaseReplacer):
    """
    shadeMature height: 36 in. - 48 in.Mature width
    PUT one UnitConverter before LowerUpperCaseSplitter
    """
    def __init__(self):
        self.pattern_replace_pair_list = [
            (r"([0-9]+)( *)(inches|inch|in|in.|')\.?", r"\1 in. "),
            (r"([0-9]+)( *)(pounds|pound|lbs|lb|lb.)\.?", r"\1 lb. "),
            (r"([0-9]+)( *)(foot|feet|ft|ft.|'')\.?", r"\1 ft. "),
            (r"([0-9]+)( *)(square|sq|sq.) ?\.?(inches|inch|in|in.|')\.?", r"\1 sq.in. "),
            (r"([0-9]+)( *)(square|sq|sq.) ?\.?(feet|foot|ft|ft.|'')\.?", r"\1 sq.ft. "),
            (r"([0-9]+)( *)(cubic|cu|cu.) ?\.?(inches|inch|in|in.|')\.?", r"\1 cu.in. "),
            (r"([0-9]+)( *)(cubic|cu|cu.) ?\.?(feet|foot|ft|ft.|'')\.?", r"\1 cu.ft. "),
            (r"([0-9]+)( *)(gallons|gallon|gal)\.?", r"\1 gal. "),
            (r"([0-9]+)( *)(ounces|ounce|oz)\.?", r"\1 oz. "),
            (r"([0-9]+)( *)(centimeters|cm)\.?", r"\1 cm. "),
            (r"([0-9]+)( *)(milimeters|mm)\.?", r"\1 mm. "),
            (r"([0-9]+)( *)(minutes|minute)\.?", r"\1 min. "),
            (r"([0-9]+)( *)(°|degrees|degree)\.?", r"\1 deg. "),
            (r"([0-9]+)( *)(v|volts|volt)\.?", r"\1 volt. "),
            (r"([0-9]+)( *)(wattage|watts|watt)\.?", r"\1 watt. "),
            (r"([0-9]+)( *)(amperes|ampere|amps|amp)\.?", r"\1 amp. "),
            (r"([0-9]+)( *)(qquart|quart)\.?", r"\1 qt. "),
            (r"([0-9]+)( *)(hours|hour|hrs.)\.?", r"\1 hr "),
            (r"([0-9]+)( *)(gallons per minute|gallon per minute|gal per minute|gallons/min.|gallons/min)\.?", r"\1 gal. per min. "),
            (r"([0-9]+)( *)(gallons per hour|gallon per hour|gal per hour|gallons/hour|gallons/hr)\.?", r"\1 gal. per hr "),
        ]

## deal with html tags
class HtmlCleaner:
    def __init__(self, parser):
        self.parser = parser

    def transform(self, text):
        bs = BeautifulSoup(text, self.parser)
        text = bs.get_text(separator=" ")
        return text

## deal with some special characters
# 3rd solution in CrowdFlower (cleanData_02.R)
class QuartetCleaner(BaseReplacer):
    def __init__(self):
        self.pattern_replace_pair_list = [
            (r"<.+?>", r""),
            # html codes
            (r" ", r" "),
            (r"&", r"&"),
            (r"'", r"'"),
            (r"/>/Agt/>", r""),
            (r"</a<gt/", r""),
            (r"gt/>", r""),
            (r"/>", r""),
            (r"<br", r""),
            # do not remove [".", "/", "-", "%"] as they are useful in numbers, e.g., 1.97, 1-1/2, 10%, etc.
            (r"[ &<>)(_,;:!?\+^~@#\$]+", r" "),
            ("'s\\b", r""),
            (r"[']+", r""),
            (r"[\"]+", r""),
        ]

## lemmatizing for using pretrained word2vec model
# 2nd solution in CrowdFlower
class Lemmatizer:
    def __init__(self):
        self.Tokenizer = nltk.tokenize.TreebankWordTokenizer()
        self.Lemmatizer = nltk.stem.wordnet.WordNetLemmatizer()

    def transform(self, text):
        tokens = [self.Lemmatizer.lemmatize(token) for token in self.Tokenizer.tokenize(text)]
        return " ".join(tokens)

## stemming
class Stemmer:
    def __init__(self, stemmer_type="snowball"):
        self.stemmer_type = stemmer_type
        if self.stemmer_type == "porter":
            self.stemmer = nltk.stem.PorterStemmer()
        elif self.stemmer_type == "snowball":
            self.stemmer = nltk.stem.SnowballStemmer("english")

    def transform(self, text):
        tokens = [self.stemmer.stem(token) for token in text.split(" ")]
        return " ".join(tokens)

#----------------------- Processor Wrapper -----------------------
class ProcessorWrapper:
    def __init__(self, processor):
        self.processor = processor

    def transform(self, input):
        if isinstance(input, str):
            out = self.processor.transform(input)
        elif isinstance(input, float) or isinstance(input, int):
            out = self.processor.transform(str(input))
        elif isinstance(input, list):
            # take care when the input is a list
            # currently for a list of attributes
            out = [0]*len(input)
            for i in range(len(input)):
                out[i] = ProcessorWrapper(self.processor).transform(input[i])
        else:
            raise(ValueError("Currently not support type: %s"%type(input).__name__))
        return out

#------------------- List/DataFrame Processor Wrapper -------------------
class ListProcessor:
    """
    WARNING: This class will operate on the original input list itself
    """
    def __init__(self, processors):
        self.processors = processors

    def process(self, lst):
        for i in range(len(lst)):
            for processor in self.processors:
                lst[i] = ProcessorWrapper(processor).transform(lst[i])
        return lst

class DataFrameProcessor:
    """
    WARNING: This class will operate on the original input dataframe itself
    """
    def __init__(self, processors):
        self.processors = processors

    def process(self, df):
        for processor in self.processors:
            df = df.apply(ProcessorWrapper(processor).transform)
        return df

class DataFrameParallelProcessor:
    """
    WARNING: This class will operate on the original input dataframe itself

    https://stackoverflow.com/questions/26520781/multiprocessing-pool-whats-the-difference-between-map-async-and-imap
    """
    def __init__(self, processors, n_jobs=4):
        self.processors = processors
        self.n_jobs = n_jobs

    def process(self, dfAll, columns):
        df_processor = DataFrameProcessor(self.processors)
        p = multiprocessing.Pool(self.n_jobs)
        dfs = p.imap(df_processor.process, [dfAll[col] for col in columns])
        for col,df in zip(columns, dfs):
            dfAll[col] = df
        return dfAll

#------------------- Query Expansion -------------------
# 3rd solution in CrowdFlower
class QueryExpansion:
    def __init__(self, df, ngram=3, stopwords_threshold=0.9, base_stopwords=set()):
        self.df = df[["search_term", "product_title"]].copy()
        self.ngram = ngram
        self.stopwords_threshold = stopwords_threshold
        self.stopwords = set(base_stopwords).union(self._get_customized_stopwords())

    def _get_customized_stopwords(self):
        words = " ".join(list(self.df["product_title"].values)).split(" ")
        counter = Counter(words)
        num_uniq = len(list(counter.keys()))
        num_stop = int((1.-self.stopwords_threshold)*num_uniq)
        stopwords = set()
        for e,(w,c) in enumerate(sorted(counter.items(), key=lambda x: x[1])):
            if e == num_stop:
                break
            stopwords.add(w)
        return stopwords

    def _ngram(self, text):
        tokens = text.split(" ")
        tokens = [token for token in tokens if token not in self.stopwords]
        return ngram_utils._ngrams(tokens, self.ngram, " ")

    def _get_alternative_query(self, df):
        res = []
        for v in df:
            res += v
        c = Counter(res)
        value, count = c.most_common()[0]
        return value

    def build(self):
        self.df["title_ngram"] = self.df["product_title"].apply(self._ngram)
        corpus = self.df.groupby("search_term").apply(lambda df: self._get_alternative_query(df["title_ngram"]))
        corpus = corpus.reset_index()
        corpus.columns = ["search_term", "search_term_alt"]
        self.df = pd.merge(self.df, corpus, on="search_term", how="left")
        return self.df["search_term_alt"].values

#------------------- Extract Product Name -------------------
# 3rd solution in CrowdFlower
color_data = imp.load_source("", config.COLOR_DATA)
COLORS_PATTERN = r"(?<=\W|^)%s(?=\W|$)"%("|".join(color_data.COLOR_LIST))
UNITS = [" ".join(r.strip().split(" ")[1:]) for p,r in UnitConverter().pattern_replace_pair_list]
UNITS_PATTERN = r"(?:\d+[?:.,]?\d*)(?: %s\.*)?"%("|".join(UNITS))
DIM_PATTERN_NxNxN = r"%s ?x %s ?x %s"%(UNITS_PATTERN, UNITS_PATTERN, UNITS_PATTERN)
DIM_PATTERN_NxN = r"%s ?x %s"%(UNITS_PATTERN, UNITS_PATTERN)

class ProductNameExtractor(BaseReplacer):
    def __init__(self):
        self.pattern_replace_pair_list = [
            # Remove descriptions (text between paranthesis/brackets)
            ("[ ]?[[(].+?[])]", r""),
            # Remove "made in..."
            ("made in [a-z]+\\b", r""),
            # Remove descriptions (hyphen or comma followed by space then at most 2 words, repeated)
            ("([,-]( ([a-zA-Z0-9]+\\b)){1,2}[ ]?){1,}$", r""),
            # Remove descriptions (prepositions staring with: with, for, by, in )
            ("\\b(with|for|by|in|w/) .+$", r""),
            # colors & sizes
            ("size: .+$", r""),
            ("size [0-9]+[.]?[0-9]+\\b", r""),
            (COLORS_PATTERN, r""),
            # dimensions
            (DIM_PATTERN_NxNxN, r""),
            (DIM_PATTERN_NxN, r""),
            # measurement units
            (UNITS_PATTERN, r""),
            # others
            ("(value bundle|warranty|brand new|excellent condition|one size|new in box|authentic|as is)", r""),
            # stop words
            ("\\b(in)\\b", r""),
            # hyphenated words
            ("([a-zA-Z])-([a-zA-Z])", r"\1\2"),
            # special characters
            ("[ &<>)(_,.;:!?/+#*-]+", r" "),
            # numbers that are not part of a word
            ("\\b[0-9]+\\b", r""),
        ]

    def preprocess(self, text):
        pattern_replace_pair_list = [
            # Remove single & double apostrophes
            ("[\"]+", r""),
            # Remove product codes (long words (>5 characters) that are all caps, numbers or mix pf both)
            # don't use raw string format
            ("[ ]?\\b[0-9A-Z-]{5,}\\b", ""),
        ]
        text = BaseReplacer(pattern_replace_pair_list).transform(text)
        text = LowerCaseConverter().transform(text)
        text = DigitLetterSplitter().transform(text)
        text = UnitConverter().transform(text)
        text = DigitCommaDigitMerger().transform(text)
        text = NumberDigitMapper().transform(text)
        text = UnitConverter().transform(text)
        return text

    def transform(self, text):
        text = super().transform(self.preprocess(text))
        text = Lemmatizer().transform(text)
        text = Stemmer(stemmer_type="snowball").transform(text)
        # last two words in product
        text = " ".join(text.split(" ")[-2:])
        return text

#------------------- Process Attributes -------------------
def _split_attr_to_text(text):
    attrs = text.split(config.ATTR_SEPARATOR)
    return " ".join(attrs)

def _split_attr_to_list(text):
    attrs = text.split(config.ATTR_SEPARATOR)
    if len(attrs) == 1:
        # missing
        return [[attrs[0], attrs[0]]]
    else:
        return [[n,v] for n,v in zip(attrs[::2], attrs[1::2])]

#-------------------------- Main --------------------------
now = time_utils._timestamp()

def main():

    ###########
    ## Setup ##
    ###########
    logname = "data_processor_%s.log"%now
    logger = logging_utils._get_logger(config.LOG_DIR, logname)

    # put product_attribute_list, product_attribute and product_description first as they are
    # quite time consuming to process
    columns_to_proc = [
        # # product_attribute_list is very time consuming to process
        # # so we just process product_attribute which is of the form
        # # attr_name1 | attr_value1 | attr_name2 | attr_value2 | ...
        # # and split it into a list afterwards
        # "product_attribute_list",
        "product_attribute_concat",
        "product_description",
        "product_brand",
        "product_color",
        "product_title",
        "search_term",
    ]
    if config.PLATFORM == "Linux":
        config.DATA_PROCESSOR_N_JOBS = len(columns_to_proc)

    # clean using a list of processors
    processors = [
        LowerCaseConverter(),
        # See LowerUpperCaseSplitter and UnitConverter for why we put UnitConverter here
        UnitConverter(),
        LowerUpperCaseSplitter(),
        WordReplacer(replace_fname=config.WORD_REPLACER_DATA),
        LetterLetterSplitter(),
        DigitLetterSplitter(),
        DigitCommaDigitMerger(),
        NumberDigitMapper(),
        UnitConverter(),
        QuartetCleaner(),
        HtmlCleaner(parser="html.parser"),
        Lemmatizer(),
    ]
    stemmers = [
        Stemmer(stemmer_type="snowball"),
        Stemmer(stemmer_type="porter")
    ][0:1]

    ## simple test
    text = "1/2 inch rubber lep tips Bullet07"
    print("Original:")
    print(text)
    list_processor = ListProcessor(processors)
    print("After:")
    print(list_processor.process([text]))

    #############
    ## Process ##
    #############
    ## load raw data
    dfAll = pkl_utils._load(config.ALL_DATA_RAW)
    columns_to_proc = [col for col in columns_to_proc if col in dfAll.columns]

    ## extract product name from search_term and product_title
    ext = ProductNameExtractor()
    dfAll["search_term_product_name"] = dfAll["search_term"].apply(ext.transform)
    dfAll["product_title_product_name"] = dfAll["product_title"].apply(ext.transform)
    if config.TASK == "sample":
        print(dfAll[["search_term", "search_term_product_name", "product_title_product_name"]])

    ## clean using GoogleQuerySpellingChecker
    # MUST BE IN FRONT OF ALL THE PROCESSING
    if config.GOOGLE_CORRECTING_QUERY:
        logger.info("Run GoogleQuerySpellingChecker at search_term")
        checker = GoogleQuerySpellingChecker()
        dfAll["search_term"] = dfAll["search_term"].apply(checker.correct)

    ## clean uisng a list of processors
    df_processor = DataFrameParallelProcessor(processors, config.DATA_PROCESSOR_N_JOBS)
    df_processor.process(dfAll, columns_to_proc)
    # split product_attribute_concat into product_attribute and product_attribute_list
    dfAll["product_attribute"] = dfAll["product_attribute_concat"].apply(_split_attr_to_text)
    dfAll["product_attribute_list"] = dfAll["product_attribute_concat"].apply(_split_attr_to_list)
    if config.TASK == "sample":
        print(dfAll[["product_attribute", "product_attribute_list"]])
    # query expansion
    if config.QUERY_EXPANSION:
        list_processor = ListProcessor(processors)
        base_stopwords = set(list_processor.process(list(config.STOP_WORDS)))
        qe = QueryExpansion(dfAll, ngram=3, stopwords_threshold=0.9, base_stopwords=base_stopwords)
        dfAll["search_term_alt"] = qe.build()
        if config.TASK == "sample":
            print(dfAll[["search_term", "search_term_alt"]])
    # save data
    logger.info("Save to %s"%config.ALL_DATA_LEMMATIZED)
    columns_to_save = [col for col in dfAll.columns if col != "product_attribute_concat"]
    pkl_utils._save(config.ALL_DATA_LEMMATIZED, dfAll[columns_to_save])

    ## auto correcting query
    if config.AUTO_CORRECTING_QUERY:
        logger.info("Run AutoSpellingChecker at search_term")
        checker = AutoSpellingChecker(dfAll, exclude_stopwords=False, min_len=4)
        dfAll["search_term_auto_corrected"] = list(dfAll["search_term"].apply(checker.correct))
        columns_to_proc += ["search_term_auto_corrected"]
        if config.TASK == "sample":
            print(dfAll[["search_term", "search_term_auto_corrected"]])
        # save query_correction_map and spelling checker
        fname = "%s/auto_spelling_checker_query_correction_map_%s.log"%(config.LOG_DIR, now)
        checker.save_query_correction_map(fname)
        # save data
        logger.info("Save to %s"%config.ALL_DATA_LEMMATIZED)
        columns_to_save = [col for col in dfAll.columns if col != "product_attribute_concat"]
        pkl_utils._save(config.ALL_DATA_LEMMATIZED, dfAll[columns_to_save])

    ## clean using stemmers
    df_processor = DataFrameParallelProcessor(stemmers, config.DATA_PROCESSOR_N_JOBS)
    df_processor.process(dfAll, columns_to_proc)
    # split product_attribute_concat into product_attribute and product_attribute_list
    dfAll["product_attribute"] = dfAll["product_attribute_concat"].apply(_split_attr_to_text)
    dfAll["product_attribute_list"] = dfAll["product_attribute_concat"].apply(_split_attr_to_list)
    # query expansion
    if config.QUERY_EXPANSION:
        list_processor = ListProcessor(stemmers)
        base_stopwords = set(list_processor.process(list(config.STOP_WORDS)))
        qe = QueryExpansion(dfAll, ngram=3, stopwords_threshold=0.9, base_stopwords=base_stopwords)
        dfAll["search_term_alt"] = qe.build()
        if config.TASK == "sample":
            print(dfAll[["search_term", "search_term_alt"]])
    # save data
    logger.info("Save to %s"%config.ALL_DATA_LEMMATIZED_STEMMED)
    columns_to_save = [col for col in dfAll.columns if col != "product_attribute_concat"]
    pkl_utils._save(config.ALL_DATA_LEMMATIZED_STEMMED, dfAll[columns_to_save])

if __name__ == "__main__":
    main()


text:
<?php
  session_start();
	include("utils/func.php");
	include("utils/user.php");
	$f = new Func();
	$u = new User($f);

  if($f->doRedirect($_SESSION)) {
	header("Location: ".$f->getLoginUrl());
    die();
  }

  $success = TRUE;
  try {
	  $user = $u->getUserPermissions($_SESSION['user_id']);
	  $isSiteAdmin = $user['is_site_admin'] ? TRUE : FALSE;
	  if($isSiteAdmin == FALSE) {
		  header("Location: attendance.php");
		  die();
	  }
      $query = "SELECT
                  starting_point_emails,
                  campuses,
                  service_labels,
                  default_campus,
                  default_first_service_label,
                  default_second_service_label
                FROM
                  Settings";
      $results = $f->fetchAndExecute($query);
    } catch (Exception $e) {
	  $success = FALSE;
      $f->logMessage($e->getMessage());
    }
?>
<!DOCTYPE html>

	<?php include("head.php"); ?>
	<link rel="stylesheet" href="styles/main.min.css">

    <?php include("navbar.php"); ?>

Settings

        Email(s) to send Starting Point notifications (comma-separated)

<textarea type="text" id="starting-point-emails" ><?php echo $results[0]['starting_point_emails'] ?></textarea>

        Campuses (id|label format, comma-separated. Ex: 1|Main,2|South Hilliard)

<textarea type="text" id="campuses" ><?php echo $results[0]['campuses'] ?></textarea>

        Service Labels (id|label format, comma-separated. Ex: 1|9:00 AM,2|10:30 AM)

<textarea type="text" id="service-labels" ><?php echo $results[0]['service_labels'] ?></textarea>

        Default Campus (enter id of campus)

        <input type="number" class="setting" id="default-campus" min="1" value="<?php echo $results[0]['default_campus'] ?>" />

        Default First Service Label (enter id of service label)

        <input type="number" class="setting" id="default-service-label-first" min="1" value="<?php echo $results[0]['default_first_service_label'] ?>" />

        Default Second Service Label (enter id of service label)

        <input type="number" class="setting" id="default-service-label-second" min="1" value="<?php echo $results[0]['default_second_service_label'] ?>" />

            <button id="update" type="button" class="btn btn-primary">  Save
            </button>

      <button id="email-error" type="button" class="btn btn-primary"> Email Error</button>


text:
import i18next from 'i18next';
import LanguageDetector from 'i18next-electron-language-detector';
import Backend from 'i18next-fs-backend';
import * as path from 'path';
import defaultOptions from '@/config/i18next';
import { memoize } from '@/utils';

i18next.use(Backend).use(LanguageDetector);

/** @type {i18next.InitOptions} */
let options = {
  backend: {
    loadPath: path.join(__static, 'locales', '{{lng}}', '{{ns}}.json'),
  },
};
options = Object.assign(defaultOptions, options);

if (!i18next.isInitialized) {
  i18next.init(options);
}

export function getResources() {
  let namespaces;
  if (Array.isArray(options.ns)) {
    namespaces = options.ns;
  } else {
    namespaces = [options.ns];
  }
  const resources = {};
  for (const lng of i18next.languages) {
    resources[lng] = {};
    for (const namespace of namespaces) {
      const bundle = i18next.getResourceBundle(lng, namespace);
      resources[lng][namespace] = bundle;
    }
  }
  return resources;
}

export function getCurrentLanguageData() {
  return {
    lng: i18next.language,
    resources: getResources(),
  };
}

export function waitForTranslationsToLoad() {
  return new Promise((resolve) => {
    i18next.on('loaded', function loaded() {
      resolve();
      i18next.off('loaded', this);
    });
  });
}

export { i18next };

export default {
  getMessage: memoize((key, ...args) => i18next.t(key, ...args)),
};


text:
<?php
/**
 * Built-in client script packages.
 *
 * Please see {@link CClientScript::packages} for explanation of the structure
 * of the returned array.
 *
 * @author Ruslan Fadeev <fadeevr@gmail.com>
 */
return array(
	'bootstrap' => array(
		'baseUrl' => $this->enableCdn ? '//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/' : $this->getAssetsUrl(),
		'css' => array(YII_DEBUG ? 'css/bootstrap.css' : 'css/bootstrap.min.css'),
	),
	'bootstrap.js' => array(
		'baseUrl' => $this->enableCdn ? '//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/' : $this->getAssetsUrl(),
		'js' => array(YII_DEBUG ? 'js/bootstrap.js' : 'js/bootstrap.min.js'),
		'depends' => array('jquery'),
	),
	'responsive' => array(
		'baseUrl' => $this->enableCdn ? '//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/' : $this->getAssetsUrl(),
		'css' => array(YII_DEBUG ? 'css/bootstrap-responsive.css' : 'css/bootstrap-responsive.min.css'),
		'depends' => array('bootstrap')
	),
	'font-awesome' => array(
		'baseUrl' => $this->enableCdn ? '//netdna.bootstrapcdn.com/font-awesome/3.0.2/' : $this->getAssetsUrl(),
		'css' => array(YII_DEBUG ? 'css/font-awesome.css' : 'css/font-awesome.min.css'),
	),
	'font-awesome-ie7' => array(
		'baseUrl' => $this->enableCdn ? '//netdna.bootstrapcdn.com/font-awesome/3.0.2/' : $this->getAssetsUrl(),
		'css' => array('css/font-awesome-ie7.min.css'),
		// only minified version exists in our assets and CDN serves minified version anyway
	),
	'full.css' => array(
		'baseUrl' => $this->enableCdn ? '//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/' : $this->getAssetsUrl(),
		'css' => array('css/bootstrap-combined.no-icons.min.css'),
		// only minified version exists in our assets and CDN serves minified version anyway
	),
	'bootstrap-yii' => array(
		'baseUrl' => $this->getAssetsUrl(),
		'css' => array('css/bootstrap-yii.css'),
	),
	'jquery-css' => array(
		'baseUrl' => $this->getAssetsUrl(),
		'css' => array('css/jquery-ui-bootstrap.css'),
	),
	'bootbox' => array(
		'baseUrl' => $this->getAssetsUrl(),
		'js' => array('js/bootstrap.bootbox.min.js'),
	),
	'notify' => array(
		'baseUrl' => $this->getAssetsUrl(),
		'css' => array('css/bootstrap-notify.css'),
		'js' => array('js/bootstrap.notify.js')
	),
	//widgets start
	'datepicker' => array(
		'baseUrl' => $this->enableCdn ? '//cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.0.2/' : $this->getAssetsUrl(),
		'css' => array(YII_DEBUG ? 'css/bootstrap-datepicker.css' : 'css/bootstrap-datepicker.min.css'),
		'js' => array(YII_DEBUG ? 'js/bootstrap-datepicker.js' : 'js/bootstrap-datepicker.min.js')
	),
	'date' => array(
		'baseUrl' => $this->enableCdn ? '//cdnjs.cloudflare.com/ajax/libs/datejs/1.0/' : $this->getAssetsUrl(),
		'js' => array($this->enableCdn ? 'date.min.js' : 'js/date.min.js')
	)
);


text:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:layout_marginTop="5dip">
    <TextView
        android:id="@+id/labelled_spinner_label"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textStyle="bold"
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:gravity="top"
        android:paddingRight="5dip"
        android:minWidth="100dip"
        android:text="Housing type"
        />
    <uk.co.vurt.hakken.ui.widget.MultiSelectSpinner
        android:id="@+id/labelled_spinner_value"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#000"
        android:gravity="top"
        android:minWidth="250dip"
        android:minHeight="55dip"
    />
</LinearLayout>


text:
package jdbreport.model.io.xml.ooxml;

import java.awt.image.RenderedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import javax.imageio.ImageIO;

import jdbreport.model.ReportBook;
import jdbreport.model.io.ReportWriter;
import jdbreport.model.io.SaveReportException;
import jdbreport.util.Utils;

/**
 * @author Andrey Kholmanskih
 *
 * @version 3.0 12.12.2014
 */
public class DocxWriter implements ReportWriter {

	private Map<String, RenderedImage> images;
	private String countPage;
	private String countWords;
	private String countCharacters;
	private String countLines;
	private String countParagraphs;
	private String charWithSpaces;
	private ReportBook reportBook;

	public void save(OutputStream out, ReportBook reportBook)
			throws SaveReportException {
		this.reportBook = reportBook;
		ZipOutputStream zipStream;
		try {
			zipStream = new ZipOutputStream(out);
			try {
				ZipEntry entry = new ZipEntry("[Content_Types].xml");
				zipStream.putNextEntry(entry);
				writeContentTypes(zipStream);

				entry = new ZipEntry("content.xml");
				zipStream.putNextEntry(entry);
				getContentWriter().save(zipStream, reportBook);

				if (images != null)
					entry = new ZipEntry("word/media/");
					zipStream.putNextEntry(entry);
					for (String fileName : images.keySet()) {
						entry = new ZipEntry("word/media/" + fileName);
						zipStream.putNextEntry(entry);
						RenderedImage image = images.get(fileName);

						ImageIO.write(image, Utils
								.getFileExtension(fileName), zipStream);
					}

				entry = new ZipEntry("settings.xml");
				zipStream.putNextEntry(entry);
				getSettingsWriter().save(zipStream, reportBook);

				entry = new ZipEntry("meta.xml");
				zipStream.putNextEntry(entry);
				getMetaWriter().save(zipStream, reportBook);

				entry = new ZipEntry("docProps/app.xml");
				zipStream.putNextEntry(entry);
				writeDocPropApp(zipStream);

				entry = new ZipEntry("docProps/core.xml");
				zipStream.putNextEntry(entry);
				writeDocPropCore(zipStream);

				entry = new ZipEntry("_rels/rels");
				zipStream.putNextEntry(entry);
				writeRels(zipStream);

			} finally {
				zipStream.close();
			}
		} catch (IOException e) {
			throw new SaveReportException(e);
		}
	}

	protected ReportWriter getSettingsWriter() {
		return null;//TODO
	}

	protected ReportWriter getMetaWriter() {
		return null;//TODO
	}

	protected ReportWriter getContentWriter() {
		return null;//TODO
	}

	private void writeXmlHead(PrintWriter fw) {
		fw
				.println("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
	}

	private void writeContentTypes(OutputStream stream) {
		PrintWriter fw = new PrintWriter(new OutputStreamWriter(stream,
				java.nio.charset.Charset.forName("UTF-8")));
		writeXmlHead(fw);
		fw
				.print("<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">");
		fw
				.print("<Override PartName=\"/word/footnotes.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml\"/>");
		fw.print("<Default Extension=\"png\" ContentType=\"image/png\"/>");
		fw
				.print("<Override PartName=\"/word/comments.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml\"/>");
		fw.print("<Default Extension=\"emf\" ContentType=\"image/x-emf\"/>");
		fw
				.print("<Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>");
		fw
				.print("<Default Extension=\"xml\" ContentType=\"application/xml\"/>");
		fw
				.print("<Override PartName=\"/word/document.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\"/>");
		fw
				.print("<Override PartName=\"/word/numbering.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml\"/>");
		fw
				.print("<Override PartName=\"/word/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\"/>");
		fw
				.print("<Override PartName=\"/word/endnotes.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml\"/>");
		fw
				.print("<Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\"/>");
		fw
				.print("<Override PartName=\"/word/settings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml\"/>");
		fw
				.print("<Override PartName=\"/word/footer2.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml\"/>");
		fw
				.print("<Override PartName=\"/word/footer1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml\"/>");
		fw
				.print("<Override PartName=\"/word/theme/theme1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.theme+xml\"/>");
		fw
				.print("<Override PartName=\"/word/header2.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml\"/>");
		fw
				.print("<Override PartName=\"/word/fontTable.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml\"/>");
		fw
				.print("<Override PartName=\"/word/webSettings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml\"/>");
		fw
				.print("<Override PartName=\"/word/header1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml\"/>");
		fw
				.print("<Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/>");
		fw.print("</Types>");
		fw.flush();
	}

	private void writeDocPropApp(OutputStream stream) {
		PrintWriter fw = new PrintWriter(new OutputStreamWriter(stream,
				java.nio.charset.Charset.forName("UTF-8"))); //$NON-NLS-1$
		writeXmlHead(fw);
		fw.print("<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\">");
		fw.print("<Template>Normal.dotm</Template>");
		fw.print("<TotalTime>5</TotalTime>");
		fw.print("<Pages>" + countPage + "</Pages>");
		fw.print("<Words>" + countWords + "</Words>");
		fw.print("<Characters>" + countCharacters + "</Characters>");
		fw.print("<Application>Microsoft Office Word</Application>");
		fw.print("<DocSecurity>0</DocSecurity>");
		fw.print("<Lines>" + countLines + "</Lines>");
		fw.print("<Paragraphs>" + countParagraphs + "</Paragraphs>");
		fw.print("<ScaleCrop>false</ScaleCrop>");
		fw.print("<Company></Company>");
		fw.print("<LinksUpToDate>false</LinksUpToDate>");
		fw.print("<CharactersWithSpaces>" + charWithSpaces + "</CharactersWithSpaces>");
		fw.print("<SharedDoc>false</SharedDoc>");
		fw.print("<HyperlinksChanged>false</HyperlinksChanged>");
		fw.print("<AppVersion>12.0000</AppVersion>");
		fw.print("</Properties>");
	}

	private void writeDocPropCore(OutputStream stream) {
		PrintWriter fw = new PrintWriter(new OutputStreamWriter(stream,
				java.nio.charset.Charset.forName("UTF-8")));
		writeXmlHead(fw);
		fw.print("<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:dcmitype=\"http://purl.org/dc/dcmitype/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">");
		fw.print("<dc:title></dc:title>");
		fw.print("<dc:subject></dc:subject>");
		fw.print("<dc:creator>" + reportBook.getCreator() + "</dc:creator>");
		fw.print("<cp:keywords></cp:keywords>");
		fw.print("<dc:description></dc:description>");
		fw.print("<cp:lastModifiedBy>" +reportBook.getCreator() + "</cp:lastModifiedBy>");
		fw.print("<cp:revision>1</cp:revision>");

		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ");
		if (reportBook.getCreationDate() == null) {
			reportBook.setCreationDate(Calendar.getInstance().getTime());
		}
		String date = format.format(reportBook.getCreationDate());
		fw.print("<dcterms:created xsi:type=\"dcterms:W3CDTF\">" + date + "</dcterms:created>");
		fw.print("<dcterms:modified xsi:type=\"dcterms:W3CDTF\">" + date + "</dcterms:modified>");
		fw.print("</cp:coreProperties>");
	}

	private void writeRels(OutputStream stream) {
		PrintWriter fw = new PrintWriter(new OutputStreamWriter(stream,
				java.nio.charset.Charset.forName("UTF-8")));
		writeXmlHead(fw);
		fw.print("<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");
		fw.print("<Relationship Id=\"rId3\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties\" Target=\"docProps/app.xml\"/>");
		fw.print("<Relationship Id=\"rId2\" Type=\"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\" Target=\"docProps/core.xml\"/>");
		fw.print("<Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\" Target=\"word/document.xml\"/>");
		fw.print("</Relationships>");
	}

	public void save(Writer writer, ReportBook reportBook)
			throws SaveReportException {
		throw new SaveReportException("Method not supported");
	}

	public void save(File file, ReportBook reportBook)
			throws SaveReportException {
		try {
			save(new FileOutputStream(file), reportBook);
		} catch (FileNotFoundException e) {
			throw new SaveReportException(e);
		}
	}

	public String write(String fileName, Object resource)
			throws SaveReportException {
		if (resource instanceof RenderedImage) {
			writeIcon(fileName, (RenderedImage) resource);
			return fileName;
		}
		return "";
	}

	public void writeIcon(String fileName, RenderedImage image) {
		if (images == null) {
			images = new HashMap<>();
		}
		images.put(fileName, image);
	}

}


text:
define([

  'App',
  'jquery',
  'backbone',
  'marionette',
  'underscore',
  'handlebars',

  'hbs!templates/dashboard'

  ], function(App, $, Backbone, Marionette, _, Handlebars, layoutTemplate) {

  'use strict';

  return Backbone.Marionette.LayoutView.extend({
    template : layoutTemplate,

    regions : {
      tabs : '#tabs',
      table : '#table'
    },

    menu_item : '.admin-dashboard',

    events : {
      'click .sidebar a' : 'showResources'
    },

    setActivePage : function(page) {
      $('.sidebar li').removeClass('active');
      $('.sidebar li a[data-resource=' + page + ']').parent().addClass('active');
    },

    showResources : function(e) {
      e.preventDefault();
      var resourceName = $(e.target).data('resource');
      App.vent.trigger('admin:' + resourceName + ':index');
    }

  });
});


text:
El objetivo principal del proyecto es el desarrollar un Sistema Web para la reserva de las habitaciones de un hotel, con el fin de que este cubra todo el proceso de reserva y lo presente a los usuarios.
Específicamente buscamos que el proceso sea transparente para el usuario y que este no represente ninguna complejidad para el mismo. Además, buscamos que para el lado del administrador este puede gestionar todo lo relacionado con las reservas de manera práctica y que este en su mayoría sea automatizado.
#### Visión del Proyecto.
Este sistema se desarrolla pensando en la necesidad que tiene un hotel de mediana calidad (2-3 estrellas) de gestionar las reservas de sus habitaciones de manera fácil y rápida, para poder brindar un servicio ágil y de calidad al cliente, logrando de esta manera aumentar su eficiencia.
El sistema se encargará de realizar todo el proceso de reservas del hotel, incluyendo su registro, modificación y cancelación por parte del cliente.
Este sistema deberá ser robusto y consistente, de manera que puede atender a las reservas durante las 24 horas del día manteniendo la veracidad de los registros.
Luego de que este proceso esté correctamente implementado, se podrían aumentar funcionalidades del sistema para cubrir el resto de procesos dentro del hotel.

#### Descripcion

Este sistema gestiona la reservacion de una habitacion de hotel

El hotel cuenta con 20 pisos, en cada piso existen habitaciones simples, dobles y triples. En este hotel no existe el piso 13. Las reservas podrán ser individuales o grupales, por lo que se requiere conocer la información de cada persona que ingresa al hotel. La reserva puede ser cancelada hasta dos días antes del check-in. Caso contrario se debe pagar un día de alojamiento. El pago se lo realizará con tarjeta de crédito.

#### Link del Proyecto (Deploy final)
https://proyecto-software2-hotel-gr3.herokuapp.com/

#### Herramientas

* [Heroku](https://www.heroku.com/)
* [PostgreSQL](http://www.postgresql.org.es/)
* [NodeJs](https://nodejs.org/es/)
* [Sails](http://sailsjs.com/)


text:
module Raven.REPL ( interp
                  , interpPlot
                  , initREPL
                  ) where

import Language.Haskell.Interpreter
import Data.List (intercalate)

import Data.ByteString.Char8 (ByteString)

-- |Interpret a string, return the result
interp :: Interpreter () -> String -> IO String
interp interpS value = runInterpreter (interpS >> eval value) >>=
  (\out -> case out of
      Left err -> return (errorString err)
      Right out' -> return out')

-- |Interpret an io, Right if it worked, Left contains errors
interpPlot :: Interpreter () -> String -> IO (Either String (Either String ByteString))
interpPlot interpS value = runInterpreter (interpS >> runPlot value) >>=
  (\out -> case out of
      Left err -> return $ Left $ errorString err
      Right fname -> return $ Right fname)

-- | prints errors
errorString :: InterpreterError -> String
errorString (WontCompile es) = intercalate "\n" (header : map unbox es)
  where
    header = "ERROR: Won't compile:"
    unbox (GhcError e) = e
errorString e = show e

-- |initializes the repl
initREPL :: Interpreter ()
initREPL = setImportsQ
  [ ("Prelude", Nothing)
  , ("Raven.Data.Stat", Nothing)
  , ("Raven.Data.Prob", Nothing)
  , ("Raven.Data.Prob.DistributionFuncs", Nothing)
  , ("Raven.Data.Entry", Nothing)
  , ("Raven.Data.BasicEntry", Nothing)
  , ("Raven.Data.BasicUnboundEntry", Nothing)
  , ("Raven.Data.Table", Nothing)
  , ("Raven.Plot", Nothing)
  , ("Graphics.Rendering.Chart.Easy", Nothing)
  , ("Data.ByteString.Char8", Just "Char8")
  ]

-- |io interpreter wrapper
runPlot :: (MonadInterpreter m) => String -> m (Either String ByteString)
runPlot code = interpret code (as :: IO (Either String ByteString)) >>= liftIO


text:
from animalia import mollusca_v1

async def sample_method_one_signature():
    # Create a client
    client = mollusca_v1.SnippetsAsyncClient()

    # Initialize request argument(s)
    my_message = mollusca_v1.MessageWithNesting()
    my_message.message.required_string = "required_string_value"
    my_message.my_int = 656

    request = mollusca_v1.SignatureRequest(
        my_string="my_string_value",
        my_int=656,
        my_bool=True,
        my_message=my_message,
        single_enum="DEFAULT",
    )

    # Make the request
    response = await client.method_one_signature(request=request)

    # Handle the response
    print(response)

# [END mollusca_v1_generated_Snippets_MethodOneSignature_async]


text:
<!DOCTYPE html>

	<meta charset="utf-8">
	<title>EaselJS: Simple Graphics</title>
	<link href="../_assets/css/shared.css" rel="stylesheet" type="text/css"/>
	<link href="../_assets/css/examples.css" rel="stylesheet" type="text/css"/>

Graphics API

This demo shows the usage of many of the Graphics APIs.

	<canvas id="testCanvas" width="960" height="400"></canvas>


text:
module Api
  module V1
    class BaseController < ActionController::Base
      include OpenApi::Controller

      COMMON_RESPONSE_STATUS = {
          successful: :boolean,
          status: :string,
          statusCode: :integer
      }.freeze

      COMMON_PAGINATION_STATUS = {
          count: :integer,
          page: :integer,
          pageCount: :integer,
          pageSize: :integer
      }

      # OpenAPI documentation metadata shared by all endpoints, including common query string
      #  parameters, HTTP headers, and HTTP response codes.
      open_api_controller(
          query_string: {
              access_token: {
                  type: :string,
                  description: 'OAuth 2 access token query parameter',
                  required: false
              }
          },
          headers: {
              'Authorization' => {
                  type: :string,
                  description: 'Authorization header (format: "Bearer <access token>")',
                  required: false
              }
          },
          responses: {
              200 => { description: 'Successful' },
              400 => { description: 'Not found' },
              401 => { description: 'Invalid request' },
              403 => { description: 'Not authorized (typically missing / invalid access token)' }
          }
      )

      # OpenAPI documentation for common API endpoint path parameters
      open_api_path_param :author_id, description: 'Author identifier'
      open_api_path_param :book_id, description: 'Book identifier'
      open_api_path_param :genre_id, description: 'Genre identifier'
      open_api_path_param :order_id, description: 'Order identifier'
      open_api_path_param :user_id, description: 'User identifier'

    end
  end
end


text:
   #include <cstdlib>
   #include <netdb.h>
#else
   #include <winsock2.h>
   #include <ws2tcpip.h>
#endif
#include <fstream>
#include <iostream>
#include <cstring>
#include <udt.h>
#include <errno.h>
#include <arpa/inet.h>
#include <sstream>

using namespace std;

#ifndef WIN32
void* sendfile(void*);
#else
DWORD WINAPI sendfile(LPVOID);
#endif

static int MAX_NUMBER_OF_CLIENTS = 5;
static int MAX_PARALLEL_FILES = 5;
static int BUFFER_SIZE = 1024;

static void *client_communicator(void *arg);
static void *file_uploader(void *arg);
int main_send(char* server_port);
void serve(int listenerPortNumber);
int main(int argc, char* argv[]);

struct client_communicator_parameter
{
	int clientListenerPortNum;
};

struct file_uploader_parameter
{
	int fileUploaderPortNum;
};

static void *client_communicator(void *arg)
{
	struct client_communicator_parameter *p = (struct client_communicator_parameter *) arg;
	int port = p->clientListenerPortNum;

	int list_sock;
	int conn_sock;
	struct sockaddr_in sa, ca;
	socklen_t ca_len;
	char ipaddrstr[64];
	int fileNumber = 1;
	int fileCounter = MAX_PARALLEL_FILES;

	int ids[MAX_PARALLEL_FILES];
	int i;
	for(i=0; i<MAX_PARALLEL_FILES; i++)
	{
		ids[i] = -1;
	}
	int cur_id = 0;

	list_sock = socket(AF_INET, SOCK_STREAM, 0);
	if(list_sock < 0)
	{
		printf ("Errno: %s & Error: could not open socket\n",strerror(errno));
		exit(4);
	}

	bzero (&sa, sizeof(sa));
	sa.sin_family = AF_INET;
	sa.sin_addr.s_addr = htonl(INADDR_ANY);
	sa.sin_port = htons(port);
	if(bind (list_sock, (struct sockaddr *) &sa, sizeof(sa)) < 0)
	{
		printf ("Errno: %s & Error: could not bind in mainFunction\n",strerror(errno));
		exit(5);
	}

	listen (list_sock, 1);
	bzero (&ca, sizeof(ca));
	ca_len = sizeof(ca);
	conn_sock = accept (list_sock, (struct sockaddr *) &ca, &ca_len);
	inet_ntop(AF_INET, &(ca.sin_addr), ipaddrstr, 64);
	ntohs(ca.sin_port);

	int nextPortNum;
	char receive_buf[BUFFER_SIZE];
	int size = read(conn_sock, receive_buf, BUFFER_SIZE);
	if(size == -1)
	{
		cout<<"Something is wrong with reading!"<<endl;
	}

	while(!(receive_buf[0]=='E' && receive_buf[1]=='X' && receive_buf[2]=='I' && receive_buf[3]=='T') && fileCounter > 0)
	{
		fileCounter--;
		nextPortNum = port + fileNumber;
		char portString[BUFFER_SIZE];
		sprintf(portString, "%d", nextPortNum);
		int test = write(conn_sock, portString, BUFFER_SIZE);
		if(test == -1)
		{
			cout<<"Something is wrong with writing!"<<endl;
		}

		pthread_t tid;
		struct file_uploader_parameter *par = (struct file_uploader_parameter*) malloc(sizeof(struct file_uploader_parameter));

		par->fileUploaderPortNum = nextPortNum;

		int ret = pthread_create(&(tid), NULL, &file_uploader, (void *) par);

		if (ret != 0)
		{
			printf("ERROR: thread create failed \n");
			exit(1);
		}

		ids[cur_id++] = tid;

		fileNumber++;
		int size = read(conn_sock, receive_buf, BUFFER_SIZE);
		if(size == -1)
		{
			cout<<"Something is wrong with reading!"<<endl;
		}
	}

	for(i=0; i<MAX_PARALLEL_FILES; i++)
	{
		if(ids[i] != -1)
		{
			pthread_join(ids[i], NULL);
		}
	}

	cout<<"Done serving to the current client!"<<endl;
	close(conn_sock);
	free(p);
}

static void *file_uploader(void *arg)
{
	struct file_uploader_parameter *p = (struct file_uploader_parameter *) arg;
	int port = p->fileUploaderPortNum;

	stringstream strs;
        strs << port;
  	string temp_str = strs.str();
  	char* portString = (char*) temp_str.c_str();
	main_send(portString);
	free(p);
}

int main_send(char* server_port)
{
   // use this function to initialize the UDT library
   UDT::startup();

   addrinfo hints;
   addrinfo* res;

   memset(&hints, 0, sizeof(struct addrinfo));
   hints.ai_flags = AI_PASSIVE;
   hints.ai_family = AF_INET;
   hints.ai_socktype = SOCK_STREAM;

   string service = server_port;

   if (0 != getaddrinfo(NULL, service.c_str(), &hints, &res))
   {
      cout << "illegal port number or port is busy.\n" << endl;
      return 0;
   }

   UDTSOCKET serv = UDT::socket(res->ai_family, res->ai_socktype, res->ai_protocol);

   // Windows UDP issue
   // For better performance, modify HKLM\System\CurrentControlSet\Services\Afd\Parameters\FastSendDatagramThreshold
#ifdef WIN32
   int mss = 1052;
   UDT::setsockopt(serv, 0, UDT_MSS, &mss, sizeof(int));
#endif

   if (UDT::ERROR == UDT::bind(serv, res->ai_addr, res->ai_addrlen))
   {
      cout << "bind: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }

   freeaddrinfo(res);

   cout << "server is ready at port: " << service << endl;

   UDT::listen(serv, 10);

   sockaddr_storage clientaddr;
   int addrlen = sizeof(clientaddr);

   UDTSOCKET fhandle;

   while (true)
   {
      if (UDT::INVALID_SOCK == (fhandle = UDT::accept(serv, (sockaddr*)&clientaddr, &addrlen)))
      {
         cout << "accept: " << UDT::getlasterror().getErrorMessage() << endl;
         return 0;
      }

      char clienthost[NI_MAXHOST];
      char clientservice[NI_MAXSERV];
      getnameinfo((sockaddr *)&clientaddr, addrlen, clienthost, sizeof(clienthost), clientservice, sizeof(clientservice), NI_NUMERICHOST|NI_NUMERICSERV);
      cout << "new connection: " << clienthost << ":" << clientservice << endl;

      #ifndef WIN32
         pthread_t filethread;
         pthread_create(&filethread, NULL, sendfile, new UDTSOCKET(fhandle));
         pthread_detach(filethread);
      #else
         CreateThread(NULL, 0, sendfile, new UDTSOCKET(fhandle), 0, NULL);
      #endif
   }

   UDT::close(serv);

   // use this function to release the UDT library
   UDT::cleanup();

   return 0;
}

void serve(int listenerPortNumber)
{
	int list_sock;
	int conn_sock;
	struct sockaddr_in sa, ca;
	socklen_t ca_len;
	char ipaddrstr[64];

	list_sock = socket(AF_INET, SOCK_STREAM, 0);
	if(list_sock < 0)
	{
		printf ("Errno: %s & Error: could not open socket\n",strerror(errno));
		exit(4);
	}

	bzero (&sa, sizeof(sa));
	sa.sin_family = AF_INET;
	sa.sin_addr.s_addr = htonl(INADDR_ANY);
	sa.sin_port = htons(listenerPortNumber);
	if(bind (list_sock, (struct sockaddr *) &sa, sizeof(sa)) < 0)
	{
		printf ("Errno: %s & Error: could not bind in mainFunction\n",strerror(errno));
		exit(5);
	}

	listen (list_sock, MAX_NUMBER_OF_CLIENTS);

	int curPortNum = listenerPortNumber + (MAX_PARALLEL_FILES + 1);
	while(1)
	{
		bzero (&ca, sizeof(ca));
		ca_len = sizeof(ca);
		conn_sock = accept (list_sock, (struct sockaddr *) &ca, &ca_len);
		inet_ntop(AF_INET, &(ca.sin_addr), ipaddrstr, 64);
		ntohs(ca.sin_port);

		char portString[BUFFER_SIZE];
		sprintf(portString, "%d", curPortNum);
		int test = write(conn_sock, portString, BUFFER_SIZE);
		if(test == -1)
		{
			cout<<"Something is wrong with writing!"<<endl;
		}

		pthread_t tid;
		struct client_communicator_parameter *par = (struct client_communicator_parameter*) malloc(sizeof(struct client_communicator_parameter));

		par->clientListenerPortNum = curPortNum;

		int ret = pthread_create(&(tid), NULL, &client_communicator, (void *) par);

		if (ret != 0)
		{
			printf("ERROR: thread create failed \n");
			exit(1);
		}

		curPortNum += (MAX_PARALLEL_FILES + 1);
	}
}

int main(int argc, char* argv[])
{
   //usage: sendfile [server_port]
   if ((2 < argc) || ((2 == argc) && (0 == atoi(argv[1]))))
   {
      cout << "usage: sendfile [server_port]" << endl;
      return 0;
   }
   char* server_port = argv[1];
   serve(atoi(server_port));
   return 0;
}

#ifndef WIN32
void* sendfile(void* usocket)
#else
DWORD WINAPI sendfile(LPVOID usocket)
#endif
{
   UDTSOCKET fhandle = *(UDTSOCKET*)usocket;
   delete (UDTSOCKET*)usocket;

   // aquiring file name information from client
   char file[1024];
   int len;

   if (UDT::ERROR == UDT::recv(fhandle, (char*)&len, sizeof(int), 0))
   {
      cout << "recv: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }

   if (UDT::ERROR == UDT::recv(fhandle, file, len, 0))
   {
      cout << "recv: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }
   file[len] = '\0';

   // open the file
   fstream ifs(file, ios::in | ios::binary);

   ifs.seekg(0, ios::end);
   int64_t size = ifs.tellg();
   ifs.seekg(0, ios::beg);

   // send file size information
   if (UDT::ERROR == UDT::send(fhandle, (char*)&size, sizeof(int64_t), 0))
   {
      cout << "send: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }

   UDT::TRACEINFO trace;
   UDT::perfmon(fhandle, &trace);

   // send the file
   int64_t offset = 0;
   if (UDT::ERROR == UDT::sendfile(fhandle, ifs, offset, size))
   {
      cout << "sendfile: " << UDT::getlasterror().getErrorMessage() << endl;
      return 0;
   }

   UDT::perfmon(fhandle, &trace);
   cout << "speed = " << trace.mbpsSendRate << "Mbits/sec" << endl;

   UDT::close(fhandle);

   ifs.close();

   #ifndef WIN32
      return NULL;
   #else
      return 0;
   #endif
}


text:
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/api/networking_private/networking_private_chromeos.h"

#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/extensions/api/networking_private/networking_private_api.h"
#include "chrome/common/extensions/api/networking_private.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_manager_client.h"
#include "chromeos/login/login_state.h"
#include "chromeos/network/managed_network_configuration_handler.h"
#include "chromeos/network/network_connection_handler.h"
#include "chromeos/network/network_device_handler.h"
#include "chromeos/network/network_event_log.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/network_util.h"
#include "chromeos/network/onc/onc_signature.h"
#include "chromeos/network/onc/onc_translator.h"
#include "chromeos/network/onc/onc_utils.h"
#include "chromeos/network/portal_detector/network_portal_detector.h"
#include "components/onc/onc_constants.h"
#include "content/public/browser/browser_context.h"

using chromeos::NetworkHandler;
using chromeos::NetworkTypePattern;
using chromeos::ShillManagerClient;
using extensions::NetworkingPrivateDelegate;

namespace {

chromeos::NetworkStateHandler* GetStateHandler() {
  return NetworkHandler::Get()->network_state_handler();
}

chromeos::ManagedNetworkConfigurationHandler* GetManagedConfigurationHandler() {
  return NetworkHandler::Get()->managed_network_configuration_handler();
}

bool GetServicePathFromGuid(const std::string& guid,
                            std::string* service_path,
                            std::string* error) {
  const chromeos::NetworkState* network =
      GetStateHandler()->GetNetworkStateFromGuid(guid);
  if (!network) {
    *error = extensions::networking_private::kErrorInvalidNetworkGuid;
    return false;
  }
  *service_path = network->path();
  return true;
}

bool GetUserIdHash(content::BrowserContext* browser_context,
                   std::string* user_hash,
                   std::string* error) {
  std::string profile_user_hash =
      chromeos::ProfileHelper::GetUserIdHashFromProfile(
          static_cast<Profile*>(browser_context));

  // Currently Chrome OS only configures networks for the primary user.
  // Configuration attempts from other browser contexts should fail.
  // TODO(stevenjb): use an ExtensionsBrowserClient method to access
  // ProfileHelper when moving this to src/extensions.
  if (profile_user_hash != chromeos::LoginState::Get()->primary_user_hash()) {
    // Disallow class requiring a user id hash from a non-primary user context
    // to avoid complexities with the policy code.
    LOG(ERROR) << "networkingPrivate API call from non primary user: "
               << profile_user_hash;
    *error = "Error.NonPrimaryUser";
    return false;
  }
  *user_hash = profile_user_hash;
  return true;
}

void NetworkHandlerDictionaryCallback(
    const NetworkingPrivateDelegate::DictionaryCallback& callback,
    const std::string& service_path,
    const base::DictionaryValue& dictionary) {
  scoped_ptr<base::DictionaryValue> dictionary_copy(dictionary.DeepCopy());
  callback.Run(dictionary_copy.Pass());
}

void NetworkHandlerFailureCallback(
    const NetworkingPrivateDelegate::FailureCallback& callback,
    const std::string& error_name,
    scoped_ptr<base::DictionaryValue> error_data) {
  callback.Run(error_name);
}

}  // namespace

////////////////////////////////////////////////////////////////////////////////

namespace extensions {

NetworkingPrivateChromeOS::NetworkingPrivateChromeOS(
    content::BrowserContext* browser_context,
    scoped_ptr<VerifyDelegate> verify_delegate)
    : NetworkingPrivateDelegate(verify_delegate.Pass()),
      browser_context_(browser_context) {
}

NetworkingPrivateChromeOS::~NetworkingPrivateChromeOS() {}

void NetworkingPrivateChromeOS::GetProperties(
    const std::string& guid,
    const DictionaryCallback& success_callback,
    const FailureCallback& failure_callback) {
  std::string service_path, error;
  if (!GetServicePathFromGuid(guid, &service_path, &error)) {
    failure_callback.Run(error);
    return;
  }

  GetManagedConfigurationHandler()->GetProperties(
      service_path,
      base::Bind(&NetworkHandlerDictionaryCallback, success_callback),
      base::Bind(&NetworkHandlerFailureCallback, failure_callback));
}

void NetworkingPrivateChromeOS::GetManagedProperties(
    const std::string& guid,
    const DictionaryCallback& success_callback,
    const FailureCallback& failure_callback) {
  std::string service_path, error;
  if (!GetServicePathFromGuid(guid, &service_path, &error)) {
    failure_callback.Run(error);
    return;
  }

  std::string user_id_hash;
  if (!GetUserIdHash(browser_context_, &user_id_hash, &error)) {
    failure_callback.Run(error);
    return;
  }

  GetManagedConfigurationHandler()->GetManagedProperties(
      user_id_hash,
      service_path,
      base::Bind(&NetworkHandlerDictionaryCallback, success_callback),
      base::Bind(&NetworkHandlerFailureCallback, failure_callback));
}

void NetworkingPrivateChromeOS::GetState(
    const std::string& guid,
    const DictionaryCallback& success_callback,
    const FailureCallback& failure_callback) {
  std::string service_path, error;
  if (!GetServicePathFromGuid(guid, &service_path, &error)) {
    failure_callback.Run(error);
    return;
  }

  const chromeos::NetworkState* network_state =
      GetStateHandler()->GetNetworkStateFromServicePath(
          service_path, false /* configured_only */);
  if (!network_state) {
    failure_callback.Run(networking_private::kErrorNetworkUnavailable);
    return;
  }

  scoped_ptr<base::DictionaryValue> network_properties =
      chromeos::network_util::TranslateNetworkStateToONC(network_state);

  success_callback.Run(network_properties.Pass());
}

void NetworkingPrivateChromeOS::SetProperties(
    const std::string& guid,
    scoped_ptr<base::DictionaryValue> properties,
    const VoidCallback& success_callback,
    const FailureCallback& failure_callback) {
  std::string service_path, error;
  if (!GetServicePathFromGuid(guid, &service_path, &error)) {
    failure_callback.Run(error);
    return;
  }

  GetManagedConfigurationHandler()->SetProperties(
      service_path,
      *properties,
      success_callback,
      base::Bind(&NetworkHandlerFailureCallback, failure_callback));
}

void NetworkingPrivateChromeOS::CreateNetwork(
    bool shared,
    scoped_ptr<base::DictionaryValue> properties,
    const StringCallback& success_callback,
    const FailureCallback& failure_callback) {
  std::string user_id_hash, error;
  // Do not allow configuring a non-shared network from a non-primary user.
  if (!shared && !GetUserIdHash(browser_context_, &user_id_hash, &error)) {
    failure_callback.Run(error);
    return;
  }

  GetManagedConfigurationHandler()->CreateConfiguration(
      user_id_hash,
      *properties,
      success_callback,
      base::Bind(&NetworkHandlerFailureCallback, failure_callback));
}

void NetworkingPrivateChromeOS::GetNetworks(
    const std::string& network_type,
    bool configured_only,
    bool visible_only,
    int limit,
    const NetworkListCallback& success_callback,
    const FailureCallback& failure_callback) {
  NetworkTypePattern pattern =
      chromeos::onc::NetworkTypePatternFromOncType(network_type);
  scoped_ptr<base::ListValue> network_properties_list =
      chromeos::network_util::TranslateNetworkListToONC(
          pattern, configured_only, visible_only, limit, false /* debugging */);
  success_callback.Run(network_properties_list.Pass());
}

void NetworkingPrivateChromeOS::StartConnect(
    const std::string& guid,
    const VoidCallback& success_callback,
    const FailureCallback& failure_callback) {
  std::string service_path, error;
  if (!GetServicePathFromGuid(guid, &service_path, &error)) {
    failure_callback.Run(error);
    return;
  }

  const bool check_error_state = false;
  NetworkHandler::Get()->network_connection_handler()->ConnectToNetwork(
      service_path,
      success_callback,
      base::Bind(&NetworkHandlerFailureCallback, failure_callback),
      check_error_state);
}

void NetworkingPrivateChromeOS::StartDisconnect(
    const std::string& guid,
    const VoidCallback& success_callback,
    const FailureCallback& failure_callback) {
  std::string service_path, error;
  if (!GetServicePathFromGuid(guid, &service_path, &error)) {
    failure_callback.Run(error);
    return;
  }

  NetworkHandler::Get()->network_connection_handler()->DisconnectNetwork(
      service_path,
      success_callback,
      base::Bind(&NetworkHandlerFailureCallback, failure_callback));
}

void NetworkingPrivateChromeOS::SetWifiTDLSEnabledState(
    const std::string& ip_or_mac_address,
    bool enabled,
    const StringCallback& success_callback,
    const FailureCallback& failure_callback) {
  NetworkHandler::Get()->network_device_handler()->SetWifiTDLSEnabled(
      ip_or_mac_address,
      enabled,
      success_callback,
      base::Bind(&NetworkHandlerFailureCallback, failure_callback));
}

void NetworkingPrivateChromeOS::GetWifiTDLSStatus(
    const std::string& ip_or_mac_address,
    const StringCallback& success_callback,
    const FailureCallback& failure_callback) {
  NetworkHandler::Get()->network_device_handler()->GetWifiTDLSStatus(
      ip_or_mac_address,
      success_callback,
      base::Bind(&NetworkHandlerFailureCallback, failure_callback));
}

void NetworkingPrivateChromeOS::GetCaptivePortalStatus(
    const std::string& guid,
    const StringCallback& success_callback,
    const FailureCallback& failure_callback) {
  chromeos::NetworkPortalDetector* detector =
      chromeos::NetworkPortalDetector::Get();
  if (!detector) {
    failure_callback.Run(networking_private::kErrorNotReady);
    return;
  }

  chromeos::NetworkPortalDetector::CaptivePortalState state =
      detector->GetCaptivePortalState(guid);
  success_callback.Run(
      chromeos::NetworkPortalDetector::CaptivePortalStatusString(state.status));
}

scoped_ptr<base::ListValue>
NetworkingPrivateChromeOS::GetEnabledNetworkTypes() {
  chromeos::NetworkStateHandler* state_handler = GetStateHandler();

  scoped_ptr<base::ListValue> network_list(new base::ListValue);

  if (state_handler->IsTechnologyEnabled(NetworkTypePattern::Ethernet()))
    network_list->AppendString(::onc::network_type::kEthernet);
  if (state_handler->IsTechnologyEnabled(NetworkTypePattern::WiFi()))
    network_list->AppendString(::onc::network_type::kWiFi);
  if (state_handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()))
    network_list->AppendString(::onc::network_type::kWimax);
  if (state_handler->IsTechnologyEnabled(NetworkTypePattern::Cellular()))
    network_list->AppendString(::onc::network_type::kCellular);

  return network_list.Pass();
}

bool NetworkingPrivateChromeOS::EnableNetworkType(const std::string& type) {
  NetworkTypePattern pattern =
      chromeos::onc::NetworkTypePatternFromOncType(type);

  GetStateHandler()->SetTechnologyEnabled(
      pattern, true, chromeos::network_handler::ErrorCallback());

  return true;
}

bool NetworkingPrivateChromeOS::DisableNetworkType(const std::string& type) {
  NetworkTypePattern pattern =
      chromeos::onc::NetworkTypePatternFromOncType(type);

  GetStateHandler()->SetTechnologyEnabled(
      pattern, false, chromeos::network_handler::ErrorCallback());

  return true;
}

bool NetworkingPrivateChromeOS::RequestScan() {
  GetStateHandler()->RequestScan();
  return true;
}

}  // namespace extensions


text:
extern "Java"
{
  namespace java
  {
    namespace beans
    {
      namespace beancontext
      {
          class BeanContextServicesSupport;
          class BeanContextServicesSupport$BCSSChild;
      }
    }
  }
}

class java::beans::beancontext::BeanContextServicesSupport$BCSSChild : public ::java::beans::beancontext::BeanContextSupport$BCSChild
{

public: // actually package-private
  BeanContextServicesSupport$BCSSChild(::java::beans::beancontext::BeanContextServicesSupport *, ::java::lang::Object *, ::java::lang::Object *);
private:
  static const jlong serialVersionUID = -3263851306889194873LL;
public: // actually package-private
  ::java::beans::beancontext::BeanContextServicesSupport * __attribute__((aligned(__alignof__( ::java::beans::beancontext::BeanContextSupport$BCSChild)))) this$0;
public:
  static ::java::lang::Class class$;
};

#endif // __java_beans_beancontext_BeanContextServicesSupport$BCSSChild__


text:
#ifndef _PUD_POSAVG_H_
#define _PUD_POSAVG_H_

/* Plugin includes */

/* OLSR includes */

/* System includes */
#include <nmea/info.h>
#include <stdbool.h>

/** Stores angle components */
typedef struct _AngleComponents {
		double x; /**< cos of the angle (in radians) */
		double y; /**< sin of the angle (in radians) */
} AngleComponents;

/** Stores an nmeaINFO entry, used in the averaging */
typedef struct _PositionUpdateEntry {
		nmeaINFO nmeaInfo; /**< the position information */

		/* used for averaging of angles */
		AngleComponents track; /**< the track angle components */
		AngleComponents mtrack; /**< the mtrack angle components */
		AngleComponents magvar; /**< the magvar angle components */
} PositionUpdateEntry;

/**
 Counts the number of GPxxx based entries. Some parameters in nmeaINFO are
 dependent on different GPxxx NMEA sentences. These counters are used to
 determine which information would be valid for the average position.
 Also counts the fix values.
 */
typedef struct _PositionUpdateCounters {
		/* present */
		unsigned long long smask; /**< the number of entries with SMASK present */
		unsigned long long utcdate; /**< the number of entries with UTCDATE present */
		unsigned long long utctime; /**< the number of entries with UTCTIME present */
		unsigned long long sig; /**< the number of entries with SIG present */
		unsigned long long fix; /**< the number of entries with FIX present */
		unsigned long long pdop; /**< the number of entries with PDOP present */
		unsigned long long hdop; /**< the number of entries with HDOP present */
		unsigned long long vdop; /**< the number of entries with VDOP present */
		unsigned long long lat; /**< the number of entries with LAT present */
		unsigned long long lon; /**< the number of entries with LON present */
		unsigned long long elv; /**< the number of entries with ELV present */
		unsigned long long speed; /**< the number of entries with SPEED present */
		unsigned long long track; /**< the number of entries with TRACK present */
		unsigned long long mtrack; /**< the number of entries with MTRACK present */
		unsigned long long magvar; /**< the number of entries with MAGVAR present */
		unsigned long long satinusecount; /**< the number of entries with SATINUSECOUNT present */
		unsigned long long satinuse; /**< the number of entries with SATINUSE present */
		unsigned long long satinview; /**< the number of entries with SATINVIEW present */

		/* smask */
		unsigned long long gpgga; /**< the number of GPGGA based entries */
		unsigned long long gpgsa; /**< the number of GPGSA based entries */
		unsigned long long gpgsv; /**< the number of GPGSV based entries */
		unsigned long long gprmc; /**< the number of GPRMC based entries */
		unsigned long long gpvtg; /**< the number of GPVTG based entries */

		/* sig */
		unsigned long long sigBad; /**< the number of entries with a bad sig */
		unsigned long long sigLow; /**< the number of entries with a low sig */
		unsigned long long sigMid; /**< the number of entries with a mid sig */
		unsigned long long sigHigh; /**< the number of entries with a high sig */

		/* fix */
		unsigned long long fixBad; /**< the number of entries with a bad fix */
		unsigned long long fix2d; /**< the number of entries with a 2D fix */
		unsigned long long fix3d; /**< the number of entries with a 3D fix */
} PositionUpdateCounters;

/**
 A list of position updates that are used to determine the average position.

 The list uses 1 extra entry: when 5 entries have to be averaged then the list
 will have 6 entries. The 6th entry is used for the incoming entry, so that
 it is already in the list (together with the old entry that will be removed
 from the average) and does not need to be copied into the list. This is for
 better performance.

 The list is a circular list.
 This means that there is a gap/unused entry in the list between the
 newest entry and the oldest entry, which is the 'incoming entry'.

 Note that 'positionAverageCumulative' stores cumulative values for parameters
 for which an average is calculated. The reason is to minimise the number of
 calculations to be performed.
 */
typedef struct _PositionAverageList {
		unsigned long long entriesMaxCount; /**< the maximum number of entries in the list */
		PositionUpdateEntry * entries; /**< the list entries */

		unsigned long long entriesCount; /**< the number of entries in the list */
		unsigned long long newestEntryIndex; /**< index of the newest entry in the list (zero-based) */
		PositionUpdateCounters counters; /**< the counters */

		PositionUpdateEntry positionAverageCumulative; /**< the average position with cumulative values */
		PositionUpdateEntry positionAverage; /**< the average position */
} PositionAverageList;

/**
 Enumeration describing the type of an entry position in the average list
 */
typedef enum _AverageEntryPositionType {
	OLDEST, NEWEST, INCOMING, AVERAGECUMULATIVE, AVERAGE
} AverageEntryPositionType;

bool initPositionAverageList(PositionAverageList * positionAverageList,
		unsigned long long maxEntries);
void flushPositionAverageList(PositionAverageList * positionAverageList);
void destroyPositionAverageList(PositionAverageList * positionAverageList);

PositionUpdateEntry * getPositionAverageEntry(
		PositionAverageList * positionAverageList,
		AverageEntryPositionType positionType);

void addNewPositionToAverage(PositionAverageList * positionAverageList,
		PositionUpdateEntry * newEntry);

#endif /* _PUD_POSAVG_H_ */


text:
<?php
//
// Copyright (c) 2008-2016 Decibel Technology Limited.
//
namespace app\decibel\test;

use app\decibel\stream\DHttpStream;
use app\decibel\stream\DStream;
use app\decibel\stream\DStreamWriteException;

/**
 * Provides a mock stream for testing HTTP output.
 *
 * @author        Timothy de Paris
 */
class DTestOutputStream extends DStream
    implements DHttpStream
{
    /**
     * The stream output
     *
     * @var        string
     */
    private $output = '';
    /**
     * The stream headers
     *
     * @var        array
     */
    private $headers = array();

    /**
     * Closes the stream.
     *
     * @return    void
     */
    public function close()
    {
        // PHP will close the output stream
        // on termination of the request.
    }

    /**
     * Erases any content existing within the stream.
     *
     * @return    void
     * @throws    DStreamWriteException    If the data could not be erased.
     */
    public function erase()
    {
        throw new DStreamWriteException($this, 'Unable to erase stream content.');
    }

    /**
     * Flushes the content of the stream to the client.
     *
     * @return    void
     */
    public function flush()
    {
        $this->output = '';
    }

    /**
     * Returns the headers sent to this stream.
     *
     * @return    array
     */
    public function getHeaders()
    {
        return $this->headers;
    }

    /**
     * Returns the output sent to this stream.
     *
     * @return    string
     */
    public function getOutput()
    {
        return $this->output;
    }

    /**
     * Sets the value of a header to be sent to the client.
     *
     * @param    string $header Name of the header.
     * @param    string $value  Header value.
     *
     * @return    void
     */
    public function setHeader($header, $value = null)
    {
        if ($value) {
            $this->headers[] = "{$header}: {$value}";
        } else {
            $this->headers[] = $header;
        }
    }

    /**
     * Writes data to the stream.
     *
     * @param    string $data Data to write to the stream.
     *
     * @return    void
     * @throws    DStreamWriteException    If the data could not be written.
     */
    public function write($data)
    {
        $this->output .= $data;
    }

    /**
     * Sets the value of a header to be sent to the client.
     *
     * @param array $headers array of $header => $value tuples
     *
     */
    public function setHeaders(array $headers)
    {
        // TODO: Implement setHeaders() method.
    }
}


text:
@implementation PINExampleView

- (void)setImageURL:(NSURL *)url
{
    _imageURL = url;

    [[PINCache sharedCache] objectForKey:[url absoluteString]
                                  block:^(PINCache *cache, NSString *key, id object) {
                                      if (object) {
                                          [self setImageOnMainThread:(UIImage *)object];
                                          return;
                                      }

                                      NSLog(@"cache miss, requesting %@", url);

                                      NSURLResponse *response = nil;
                                      NSURLRequest *request = [NSURLRequest requestWithURL:url];
                                      NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];

                                      UIImage *image = [[UIImage alloc] initWithData:data scale:[[UIScreen mainScreen] scale]];
                                      [self setImageOnMainThread:image];

                                      [[PINCache sharedCache] setObject:image forKey:[url absoluteString]];
    }];
}

- (void)setImageOnMainThread:(UIImage *)image
{
    if (!image)
        return;

    NSLog(@"setting view image %@", NSStringFromCGSize(image.size));

    dispatch_async(dispatch_get_main_queue(), ^{
        self.image = image;
    });
}

@end


text:
import React from 'react';
import PropTypes from 'prop-types';
import { Router } from 'react-router-dom';
import { Route } from 'react-router';
import { ConnectedRouter } from 'react-router-redux';
import { Page } from './../../Page';
import PageLoader from './../../PageLoader';

class Placeholder extends React.Component {
    render() {
        let router = <Route render={
            (route) => {
                const pageName = Page.history.now();

                if (!pageName) return null;
                let attrs = {
                    '[[name]]': pageName
                };

                return <PageLoader {...attrs} />;
            }
        } />;

        if (PageLoader.redux.reducers) {
            return (
                <ConnectedRouter history={this.props.history}>
                    {router}
                </ConnectedRouter>
            )
        } else {
            return (
                <Router history={this.props.history}>
                    {router}
                </Router>
            );
        }
    }
}

Placeholder.propTypes = {
    history: PropTypes.object
}

export default Placeholder;


text:
export const KEY_CODE_ENTER = 13;
export const KEY_CODE_ESC = 27;
export const KEY_CODE_SPACE = 32;
export const KEY_CODE_UP = 38;
export const KEY_CODE_DOWN = 40;
export const KEY_CODE_LEFT = 37;
export const KEY_CODE_RIGHT = 39;


text:
namespace orbit_linux_tracing {

void PerfEventQueue::PushEvent(PerfEvent&& event) {
  const PerfEventOrderedStream order = event.ordered_stream;
  if (order == PerfEventOrderedStream::kNone) {
    priority_queue_of_events_not_ordered_in_stream_.push(std::move(event));
  } else if (auto queue_it = queues_of_events_ordered_in_stream_.find(order);
             queue_it != queues_of_events_ordered_in_stream_.end()) {
    const std::unique_ptr<std::queue<PerfEvent>>& queue = queue_it->second;

    ORBIT_CHECK(!queue->empty());
    // Fundamental assumption: events from the same file descriptor come already in order.
    ORBIT_CHECK(event.timestamp >= queue->back().timestamp);
    queue->push(std::move(event));
  } else {
    queue_it = queues_of_events_ordered_in_stream_
                   .emplace(order, std::make_unique<std::queue<PerfEvent>>())
                   .first;
    const std::unique_ptr<std::queue<PerfEvent>>& queue = queue_it->second;

    queue->push(std::move(event));
    heap_of_queues_of_events_ordered_in_stream_.emplace_back(queue.get());
    MoveUpBackOfHeapOfQueues();
  }
}

bool PerfEventQueue::HasEvent() const {
  return !heap_of_queues_of_events_ordered_in_stream_.empty() ||
         !priority_queue_of_events_not_ordered_in_stream_.empty();
}

const PerfEvent& PerfEventQueue::TopEvent() {
  // As we effectively have two priority queues, get the older event between the two events at the
  // top of the two queues. In case those two events have the exact same timestamp, return the one
  // at the top of priority_queue_of_events_not_ordered_in_stream_ (and do the same in PopEvent).
  if (priority_queue_of_events_not_ordered_in_stream_.empty()) {
    ORBIT_CHECK(!heap_of_queues_of_events_ordered_in_stream_.empty());
    ORBIT_CHECK(!heap_of_queues_of_events_ordered_in_stream_.front()->empty());
    return heap_of_queues_of_events_ordered_in_stream_.front()->front();
  }
  if (heap_of_queues_of_events_ordered_in_stream_.empty()) {
    ORBIT_CHECK(!priority_queue_of_events_not_ordered_in_stream_.empty());
    return priority_queue_of_events_not_ordered_in_stream_.top();
  }
  return (heap_of_queues_of_events_ordered_in_stream_.front()->front().timestamp <
          priority_queue_of_events_not_ordered_in_stream_.top().timestamp)
             ? heap_of_queues_of_events_ordered_in_stream_.front()->front()
             : priority_queue_of_events_not_ordered_in_stream_.top();
}

void PerfEventQueue::PopEvent() {
  if (!priority_queue_of_events_not_ordered_in_stream_.empty() &&
      (heap_of_queues_of_events_ordered_in_stream_.empty() ||
       priority_queue_of_events_not_ordered_in_stream_.top().timestamp <=
           heap_of_queues_of_events_ordered_in_stream_.front()->front().timestamp)) {
    // The oldest event is at the top of the priority queue holding the events that cannot be
    // assumed sorted in any stream. Note in particular that we pop this event even if the event at
    // the top of heap_of_queues_of_events_ordered_in_stream_ has the exact same timestamp, as we
    // need to be consistent with TopEvent.
    priority_queue_of_events_not_ordered_in_stream_.pop();
    return;
  }

  std::queue<PerfEvent>* top_queue = heap_of_queues_of_events_ordered_in_stream_.front();
  const PerfEventOrderedStream top_order = top_queue->front().ordered_stream;
  top_queue->pop();

  if (top_queue->empty()) {
    queues_of_events_ordered_in_stream_.erase(top_order);
    std::swap(heap_of_queues_of_events_ordered_in_stream_.front(),
              heap_of_queues_of_events_ordered_in_stream_.back());
    heap_of_queues_of_events_ordered_in_stream_.pop_back();
  }

  MoveDownFrontOfHeapOfQueues();
}

void PerfEventQueue::MoveDownFrontOfHeapOfQueues() {
  if (heap_of_queues_of_events_ordered_in_stream_.empty()) {
    return;
  }

  size_t current_index = 0;
  size_t new_index;
  while (true) {
    new_index = current_index;
    size_t left_index = current_index * 2 + 1;
    size_t right_index = current_index * 2 + 2;
    if (left_index < heap_of_queues_of_events_ordered_in_stream_.size() &&
        heap_of_queues_of_events_ordered_in_stream_[left_index]->front().timestamp <
            heap_of_queues_of_events_ordered_in_stream_[new_index]->front().timestamp) {
      new_index = left_index;
    }
    if (right_index < heap_of_queues_of_events_ordered_in_stream_.size() &&
        heap_of_queues_of_events_ordered_in_stream_[right_index]->front().timestamp <
            heap_of_queues_of_events_ordered_in_stream_[new_index]->front().timestamp) {
      new_index = right_index;
    }
    if (new_index != current_index) {
      std::swap(heap_of_queues_of_events_ordered_in_stream_[new_index],
                heap_of_queues_of_events_ordered_in_stream_[current_index]);
      current_index = new_index;
    } else {
      break;
    }
  }
}

void PerfEventQueue::MoveUpBackOfHeapOfQueues() {
  if (heap_of_queues_of_events_ordered_in_stream_.empty()) {
    return;
  }

  size_t current_index = heap_of_queues_of_events_ordered_in_stream_.size() - 1;
  while (current_index > 0) {
    size_t parent_index = (current_index - 1) / 2;
    if (heap_of_queues_of_events_ordered_in_stream_[parent_index]->front().timestamp <=
        heap_of_queues_of_events_ordered_in_stream_[current_index]->front().timestamp) {
      break;
    }
    std::swap(heap_of_queues_of_events_ordered_in_stream_[parent_index],
              heap_of_queues_of_events_ordered_in_stream_[current_index]);
    current_index = parent_index;
  }
}

}  // namespace orbit_linux_tracing


text:
package gin.edit;

public class MoveStatement extends Edit {

    public int sourceStatement;
    public int destinationBlock;
    public int destinationChildInBlock;

    public MoveStatement(int sourceStatement, int destinationBlock, int destinationChildInBlock) {
        this.sourceStatement = sourceStatement;
        this.destinationBlock = destinationBlock;
        this.destinationChildInBlock = destinationChildInBlock;
    }

    @Override
    public String toString() {
        return "MOVE " + sourceStatement + " -> " + destinationBlock + ":" + destinationChildInBlock;
    }

}


text:
package org.deeplearning4j.nn.modelimport.keras.layers.convolutional;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import org.deeplearning4j.nn.conf.inputs.InputType;
import org.deeplearning4j.nn.conf.layers.convolutional.Cropping2D;
import org.deeplearning4j.nn.modelimport.keras.KerasLayer;
import org.deeplearning4j.nn.modelimport.keras.exceptions.InvalidKerasConfigurationException;
import org.deeplearning4j.nn.modelimport.keras.exceptions.UnsupportedKerasConfigurationException;

import java.util.Map;

import static org.deeplearning4j.nn.modelimport.keras.layers.convolutional.KerasConvolutionUtils.getPaddingFromConfig;

/**
 * Imports a Keras Cropping 2D layer.
 *
 * @author Max Pumperla
 */
@Slf4j
@Data
@EqualsAndHashCode(callSuper = false)
public class KerasCropping2D extends KerasLayer {

    /**
     * Constructor from parsed Keras layer configuration dictionary.
     *
     * @param layerConfig dictionary containing Keras layer configuration.
     * @throws InvalidKerasConfigurationException     Invalid Keras config
     * @throws UnsupportedKerasConfigurationException Unsupported Keras config
     */
    public KerasCropping2D(Map<String, Object> layerConfig)
            throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException {
        this(layerConfig, true);
    }

    /**
     * Constructor from parsed Keras layer configuration dictionary.
     *
     * @param layerConfig           dictionary containing Keras layer configuration
     * @param enforceTrainingConfig whether to enforce training-related configuration options
     * @throws InvalidKerasConfigurationException     Invalid Keras config
     * @throws UnsupportedKerasConfigurationException Unsupported Keras config
     */
    public KerasCropping2D(Map<String, Object> layerConfig, boolean enforceTrainingConfig)
            throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException {
        super(layerConfig, enforceTrainingConfig);
        String croppingField = conf.getLAYER_FIELD_CROPPING();
        int[] cropping = getPaddingFromConfig(layerConfig, conf, croppingField, 2);
        Cropping2D.Builder builder = new Cropping2D.Builder(cropping)
                .name(this.layerName).dropOut(this.dropout);
        this.layer = builder.build();
        this.vertex = null;
    }

    /**
     * Get DL4J Cropping2D layer.
     *
     * @return Cropping2D layer
     */
    public Cropping2D getCropping2DLayer() {
        return (Cropping2D) this.layer;
    }

    /**
     * Get layer output type.
     *
     * @param inputType Array of InputTypes
     * @return output type as InputType
     * @throws InvalidKerasConfigurationException Invalid Keras config
     */
    @Override
    public InputType getOutputType(InputType... inputType) throws InvalidKerasConfigurationException {
        if (inputType.length > 1)
            throw new InvalidKerasConfigurationException(
                    "Keras Cropping layer accepts only one input (received " + inputType.length + ")");
        return this.getCropping2DLayer().getOutputType(-1, inputType[0]);
    }
}