text:
import arcpy, collections
from ConfigParser import ConfigParser

class Summary:

	def __init__(self):
		pass #placeholder

	def writeSummaryTxt(Summary,outDirTxt,outName,totError):
		try:
			#Write general error report to .txt
			Summary.errorSummaryFile = open(outDirTxt + "/" + outName + "_ValidationSummary.txt","w")
			("Creating Validation Summary here: " + outDirTxt + "/" + outName + "_ValidationSummary.txt")
			Summary.errorSummaryFile.write(outDirTxt + "\\" + outName + "_ValidationSummary.txt" + "\n")
			Summary.errorSummaryFile.write("Validation Summary Table: " + "\n")
			Summary.errorSummaryFile.write("This validation summary table contains an overview of any errors found by the Parcel Validation Tool. Please review the contents of this file and make changes to your parcel dataset as necessary." + "\n\n")
			Summary.errorSummaryFile.write("************************************************************************\n")
			Summary.errorSummaryFile.write("* In-line errors\n")
			Summary.errorSummaryFile.write("************************************************************************\n")
			Summary.errorSummaryFile.write("The following lines summarized the element-specific errors that were found while validating your parcel dataset.  The stats below are meant as a means of reviewing the output.  Please see the GeneralElementErrors, AddressElementErrors, TaxrollElementErrors, and GeometricElementErrors fields to address these errors individually.\n")
			Summary.errorSummaryFile.write("	General Errors: " + str(totError.generalErrorCount) + "\n")
			Summary.errorSummaryFile.write("	Geometric Errors: " + str(totError.geometricErrorCount) + "\n")
			Summary.errorSummaryFile.write("	Address Errors: " + str(totError.addressErrorCount) + "\n")
			Summary.errorSummaryFile.write("	Tax Errors: " + str(totError.taxErrorCount) + "\n")
			Summary.errorSummaryFile.write("\n\n")
			Summary.errorSummaryFile.write("************************************************************************\n")
			Summary.errorSummaryFile.write("* Broad-level errors:\n")
			Summary.errorSummaryFile.write("************************************************************************\n")
			Summary.errorSummaryFile.write("The following lines explain any broad geometric errors that were found while validating your parcel dataset."+ "\n")
			if len(totError.geometricPlacementErrors) != 0:
				for geometricErrorMessage in totError.geometricPlacementErrors:
					Summary.errorSummaryFile.write("	Geometric Misplacement Flag: " + str(geometricErrorMessage) + "\n")
			if len(totError.geometricFileErrors) != 0:
				for geometricErrorMessage in totError.geometricFileErrors:
					Summary.errorSummaryFile.write("	Geometric File Error: " + str(geometricErrorMessage) + "\n")
			if (len(totError.geometricFileErrors) == 0) and (len(totError.geometricPlacementErrors) == 0):
				Summary.errorSummaryFile.write("	*No broad-level geometric errors found!" + "\n")
			Summary.errorSummaryFile.write("\n\n")
			Summary.errorSummaryFile.write("Percentage of records with various Taxroll Years" + "\n")
			Summary.errorSummaryFile.write("	Previous Taxroll Year: " + str(round((float(totError.trYearPast / float((totError.recordTotalCount - totError.pinSkipCount)))*100),2)) + "%\n")
			Summary.errorSummaryFile.write("	Expected Taxroll Year: " + str(round((float(totError.trYearExpected / float((totError.recordTotalCount - totError.pinSkipCount)))*100),2)) + "%\n")
			Summary.errorSummaryFile.write("	Future Taxroll Years: " + str(round((float(totError.trYearFuture / float((totError.recordTotalCount - totError.pinSkipCount)))*100),2)) + "%\n")
			Summary.errorSummaryFile.write("	Other Taxroll Years: " + str(round((float(totError.trYearOther / float((totError.recordTotalCount - totError.pinSkipCount)))*100),2)) + "%\n")
			Summary.errorSummaryFile.write("\n\n")
			Summary.errorSummaryFile.write("Records missing CONAME, PARCELFIPS, or PARCELSOURCE" + "\n")
			Summary.errorSummaryFile.write("	Missing CONAME: " + str(totError.coNameMiss) + "\n")
			Summary.errorSummaryFile.write("	Missing PARCELFIPS: " + str(totError.fipsMiss) + "\n")
			Summary.errorSummaryFile.write("	Missing PARCELSRC: " + str(totError.srcMiss) + "\n\n")
			Summary.errorSummaryFile.write("If any of the above values are greater than 0, please add missing values.  These 3 fields should be populated for all records submitted.\n\n\n")
			Summary.errorSummaryFile.write("BELOW IS A COMPARISON OF COMPLETENESS VALUES FROM YOUR PREVIOUS PARCEL SUBMISSION AND THIS CURRENT SUBMISSION.\n")
			Summary.errorSummaryFile.write("-->If the value shown is a seemingly large negative number, please verify that all data was joined correctly and no data was lost during processing.\n")
			Summary.errorSummaryFile.write("-->Note: This does not necessarily mean your data is incorrect, we just want to highlight large discrepancies that could indicate missing or incorrect data.\n\n")
			Summary.errorSummaryFile.write("          FIELD     DIFFERENCE\n")
			Summary.errorSummaryFile.write("         ------     ----------\n")
			Summary.errorSummaryFile.write("       PARCELID:  " + str(totError.comparisonDict["PARCELID"]) + '\n')
			Summary.errorSummaryFile.write("    TAXPARCELID:  " + str(totError.comparisonDict["TAXPARCELID"]) + '\n')
			Summary.errorSummaryFile.write("     PARCELDATE:  " + str(totError.comparisonDict["PARCELDATE"]) + '\n')
			Summary.errorSummaryFile.write("    TAXROLLYEAR:  " + str(totError.comparisonDict["TAXROLLYEAR"]) + '\n')
			Summary.errorSummaryFile.write("      OWNERNME1:  " + str(totError.comparisonDict["OWNERNME1"]) + '\n')
			Summary.errorSummaryFile.write("      OWNERNME2:  " + str(totError.comparisonDict["OWNERNME2"]) + '\n')
			Summary.errorSummaryFile.write("     PSTLADRESS:  " + str(totError.comparisonDict["PSTLADRESS"]) + '\n')
			Summary.errorSummaryFile.write("     SITEADRESS:  " + str(totError.comparisonDict["SITEADRESS"]) + '\n')
			Summary.errorSummaryFile.write("   ADDNUMPREFIX:  " + str(totError.comparisonDict["ADDNUMPREFIX"]) + '\n')
			Summary.errorSummaryFile.write("         ADDNUM:  " + str(totError.comparisonDict["ADDNUM"]) + '\n')
			Summary.errorSummaryFile.write("   ADDNUMSUFFIX:  " + str(totError.comparisonDict["ADDNUMSUFFIX"]) + '\n')
			Summary.errorSummaryFile.write("         PREFIX:  " + str(totError.comparisonDict["PREFIX"]) + '\n')
			Summary.errorSummaryFile.write("     STREETNAME:  " + str(totError.comparisonDict["STREETNAME"]) + '\n')
			Summary.errorSummaryFile.write("     STREETTYPE:  " + str(totError.comparisonDict["STREETTYPE"]) + '\n')
			Summary.errorSummaryFile.write("         SUFFIX:  " + str(totError.comparisonDict["SUFFIX"]) + '\n')
			Summary.errorSummaryFile.write("   LANDMARKNAME:  " + str(totError.comparisonDict["LANDMARKNAME"]) + '\n')
			Summary.errorSummaryFile.write("       UNITTYPE:  " + str(totError.comparisonDict["UNITTYPE"]) + '\n')
			Summary.errorSummaryFile.write("         UNITID:  " + str(totError.comparisonDict["UNITID"]) + '\n')
			Summary.errorSummaryFile.write("      PLACENAME:  " + str(totError.comparisonDict["PLACENAME"]) + '\n')
			Summary.errorSummaryFile.write("        ZIPCODE:  " + str(totError.comparisonDict["ZIPCODE"]) + '\n')
			Summary.errorSummaryFile.write("           ZIP4:  " + str(totError.comparisonDict["ZIP4"]) + '\n')
			Summary.errorSummaryFile.write("     SCHOOLDIST:  " + str(totError.comparisonDict["SCHOOLDIST"]) + '\n')
			Summary.errorSummaryFile.write("   SCHOOLDISTNO:  " + str(totError.comparisonDict["SCHOOLDISTNO"]) + '\n')
			Summary.errorSummaryFile.write("       IMPROVED:  " + str(totError.comparisonDict["IMPROVED"]) + '\n')
			Summary.errorSummaryFile.write("   CNTASSDVALUE:  " + str(totError.comparisonDict["CNTASSDVALUE"]) + '\n')
			Summary.errorSummaryFile.write("       LNDVALUE:  " + str(totError.comparisonDict["LNDVALUE"]) + '\n')
			Summary.errorSummaryFile.write("       IMPVALUE:  " + str(totError.comparisonDict["IMPVALUE"]) + '\n')
			Summary.errorSummaryFile.write("    FORESTVALUE:  " + str(totError.comparisonDict["FORESTVALUE"]) + '\n')
			Summary.errorSummaryFile.write("    ESTFMKVALUE:  " + str(totError.comparisonDict["ESTFMKVALUE"]) + '\n')
			Summary.errorSummaryFile.write("       NETPRPTA:  " + str(totError.comparisonDict["NETPRPTA"]) + '\n')
			Summary.errorSummaryFile.write("       GRSPRPTA:  " + str(totError.comparisonDict["GRSPRPTA"]) + '\n')
			Summary.errorSummaryFile.write("      PROPCLASS:  " + str(totError.comparisonDict["PROPCLASS"]) + '\n')
			Summary.errorSummaryFile.write("       AUXCLASS:  " + str(totError.comparisonDict["AUXCLASS"]) + '\n')
			Summary.errorSummaryFile.write("      ASSDACRES:  " + str(totError.comparisonDict["ASSDACRES"]) + '\n')
			Summary.errorSummaryFile.write("      DEEDACRES:  " + str(totError.comparisonDict["DEEDACRES"]) + '\n')
			Summary.errorSummaryFile.write("       GISACRES:  " + str(totError.comparisonDict["GISACRES"]) + '\n')
			Summary.errorSummaryFile.write("         CONAME:  " + str(totError.comparisonDict["CONAME"]) + '\n')
			Summary.errorSummaryFile.write("     PARCELFIPS:  " + str(totError.comparisonDict["PARCELFIPS"]) + '\n')
			Summary.errorSummaryFile.write("      PARCELSRC:  " + str(totError.comparisonDict["PARCELSRC"]) + '\n')
			Summary.errorSummaryFile.write("\n\n\n* Within: " + outDirTxt + "\\" + outName  + "\n")
			Summary.errorSummaryFile.write("************************************************************************\n")
			Summary.errorSummaryFile.close()
		except Exception as e:
			arcpy.AddMessage("!!!!!!!!!!Error writing summary file!!!!!!!!!!")
			arcpy.AddMessage(str(e))

	def writeIniFile(self,inputDict,totError):
		arcpy.AddMessage("Creating .ini file")
		config = ConfigParser()
		config.add_section('PARAMETERS')
		for key in inputDict.keys():
			config.set('PARAMETERS',key,inputDict[key])

		if inputDict['isSearchable'] == 'true':
			config.add_section('ERROR COUNTS')
			config.set('ERROR COUNTS','General',totError.generalErrorCount)
			config.set('ERROR COUNTS','Geometric',totError.geometricErrorCount)
			config.set('ERROR COUNTS','Address',totError.addressErrorCount)
			config.set('ERROR COUNTS','Tax',totError.taxErrorCount)
			config.add_section('PERCENT TAXROLL YEAR')
			config.set('PERCENT TAXROLL YEAR','Previous',round((float(totError.trYearPast / float((totError.recordTotalCount - totError.pinSkipCount)))*100),2))
			config.set('PERCENT TAXROLL YEAR','Expected',round((float(totError.trYearExpected / float((totError.recordTotalCount - totError.pinSkipCount)))*100),2))
			config.set('PERCENT TAXROLL YEAR','Future',round((float(totError.trYearFuture / float((totError.recordTotalCount - totError.pinSkipCount)))*100),2))
			config.set('PERCENT TAXROLL YEAR','Other',round((float(totError.trYearOther / float((totError.recordTotalCount - totError.pinSkipCount)))*100),2))
			config.add_section('MISSING RECORDS')
			config.set('MISSING RECORDS','CONAME',totError.coNameMiss)
			config.set('MISSING RECORDS','PARCELFIPS',totError.fipsMiss)
			config.set('MISSING RECORDS','PARCELSOURCE',totError.srcMiss)

			config.add_section('COMPARISON COMPLETENESS')
			for field in totError.comparisonDict.keys():
				if field != 'state' or field != 'loaddate':
					config.set('COMPARISON COMPLETENESS',field,totError.comparisonDict[field])
		try:
			#Write out .ini file
			with open(inputDict['outINIDir']+'/'+inputDict['county']+'_'+inputDict['outName']+'.ini','w') as configFile:
				config.write(configFile)
				with open(inputDict['inCert'],'r') as certFile:
					for line in certFile:
						configFile.write(line)
			arcpy.AddMessage("Wrote .ini file to "+inputDict['outINIDir'])
			arcpy.AddMessage("SUBMISSIONS WITHOUT .ini WILL NOT BE ACCEPTED!")
		except Exception as e:
			arcpy.AddMessage("!!!!!!!!!!Error writing .ini file!!!!!!!!!!")
			arcpy.AddMessage(str(e))


text:
file-display .inline-tag img {
  max-width: 100%;
}

file-display pre,
file-display code {
  width: 100%;
  margin-top: -10px;
  margin-bottom: 0;
}

file-display code {
  white-space: pre-wrap;
}

redpajama_set_name: RedPajamaGithub


text:
export class Collection {
    changes: number[];
    comparator: null | string | ((param0: Model, param1?: Model) => number);
    customPagingOptions: ((response: object) => Collection.CustomPagingOptionsReturn | null) | null;
    customURL: ((param0: string, param1: Collection, param2: object) => string | object | null) | null;
    fetchSize: number;
    hasMore: boolean;
    lastFetchCount: number;
    lastFetchSize: number;
    length: number;
    model: object;
    modelLimit: number;
    models: Model[];
    offset: number;
    omitLanguageHeader: boolean;
    parse: ((param0: object) => object);
    sortDirection: number;
    totalResults: number;
    url: null | string | (() => string);
    constructor(models?: Model[], options?: object);
    static extend(properties?: {
        parse?: (data: any) => any;
        model?: Model;
        url?: string;
        initialize?: (models: Model[], options: object) => void;
        comparator?: null | string | ((model1: Model, model2?: Model) => number);
        fetchSize?: number;
        modelLimit?: number;
        [propName: string]: any;
    }, classProperties?: object): any;
    abort(): Promise<null>;
    add(m: Model | object | object[] | Model[], options?: {
        silent?: boolean;
        at?: number;
        merge?: boolean;
        sort?: boolean;
        force?: boolean;
        deferred?: boolean;
        [propName: string]: any;
    }): Promise<Model[]> | Model[];
    any(iterator: ((param0: object) => void), context?: object): boolean;
    at(index: number, options?: {
        fetchSize?: number;
        deferred?: boolean;
        [propName: string]: any;
    }): Model | Promise<Model> | null;
    clone(): Collection;
    contains(model: object, options?: object): boolean | Promise<boolean>;
    create(attributes?: object, options?: {
        silent?: boolean;
        at?: number;
        merge?: boolean;
        sort?: boolean;
        force?: boolean;
        deferred?: boolean;
        [propName: string]: any;
    }): Model | boolean | Promise<Model>;
    difference(...var_args: Model[][]): Model[];
    each(iterator: ((param0: Model) => void), context?: object): undefined;
    fetch(options?: {
        success?: (collection: Collection, response: any, options: object) => void;
        error?: (collection: Collection, xhr: any, options: object) => void;
        add?: boolean;
        set?: boolean;
        startIndex?: number;
        startID?: any;
        since?: any;
        until?: any;
        fetchSize?: number;
        [propName: string]: any;
    }): object;
    filter(iterator: ((param0: Model) => void), context?: object): Model[];
    findWhere(attrs: object | object[], options?: {
        deferred?: boolean;
        [propName: string]: any;
    }): Model | Promise<Model>;
    first(n?: number, options?: object): Model[] | null | Promise<any>;
    get(id: object | string, options?: object): Model | null | Promise<Model>;
    getByCid(clientId: string): Model | null;
    groupBy(iterator: string | ((param0: Model) => object), context?: object): object;
    include(model: object, options?: object): boolean | Promise<boolean>;
    indexBy(iterator: string | ((param0: Model) => void), context?: object): object;
    indexOf(model: object, options?: object): number | Promise<number>;
    initial(n?: number): Model[];
    isEmpty(): boolean;
    isRangeLocal(start: number, count: number): boolean;
    last(n?: number, options?: object): Promise<Model> | Model[] | null;
    lastIndexOf(model: Model, fromIndex?: number): number;
    listenTo(otherObj: object, eventType: string, callback: (eventType: string, data: object) => void): undefined;
    listenToOnce(otherObj: object, eventType: string, callback: (eventType: string, data: object) => void): undefined;
    map(iterator: ((param0: Model) => object), context?: object): object[];
    max(iterator: ((param0: Model) => object), context?: object): object;
    min(iterator: ((param0: object) => void), context?: object): object;
    modelId(attrs: object): null | string;
    next(n: number, options?: {
        success?: (collection: Collection, response: any, options: object) => void;
        error?: (collection: Collection, xhr: any, options: object) => void;
        [propName: string]: any;
    }): object | null;
    off(eventType?: string | object, callback?: (eventType: string, data: object) => void, context?: object): undefined;
    on(eventType: string | object, callback: (eventType: string, data: object) => void, context?: object): undefined;
    once(eventType: string, callback: (eventType: string, data: object) => void, context?: object): undefined;
    pluck(attr: string): object[];
    pop(options?: {
        silent?: boolean;
        deferred?: boolean;
        [propName: string]: any;
    }): Model | Promise<Model>;
    previous(n: number, options?: {
        success?: (collection: Collection, response: any, options: object) => void;
        error?: (collection: Collection, xhr: any, options: object) => void;
        [propName: string]: any;
    }): object;
    push(m: Model | object, options?: {
        silent?: boolean;
        at?: number;
        merge?: boolean;
        sort?: boolean;
        force?: boolean;
        deferred?: boolean;
        [propName: string]: any;
    }): Promise<Model[]> | undefined;
    refresh(options?: {
        silent?: boolean;
        startIndex?: number;
        [propName: string]: any;
    }): Promise<Collection.SetRangeLocalPromise | undefined>;
    remove(m: Model | Model[], options?: object): Model[] | object;
    reset(data?: object, options?: {
        silent?: boolean;
        [propName: string]: any;
    }): Model | Model[];
    rest(n?: number, options?: object): object[] | Promise<any>;
    set(models: object, options?: {
        add?: boolean;
        remove?: boolean;
        merge?: boolean;
        silent?: boolean;
        deferred?: boolean;
        [propName: string]: any;
    }): Promise<any> | null;
    setFetchSize(n: number): undefined;
    setModelLimit(n: number): undefined;
    setRangeLocal(start: number, count: number): Promise<Collection.SetRangeLocalPromise>;
    shift(options?: object): Model | Promise<Model> | null;
    size(): number;
    slice(start: number, end?: number, options?: object): Promise<Model[]> | Model[];
    sort(options?: {
        silent?: boolean;
        startIndex?: number;
        [propName: string]: any;
    }): Promise<Collection.SetRangeLocalPromise> | null;
    sortBy(iterator: string | ((param0: Model) => object), context?: object): Model[];
    sortedIndex(comparator: string | ((param0: Model, param1?: Model) => object)): number;
    stopListening(otherObj?: object, eventType?: string, callback?: (eventType: string, data: object) => void): undefined;
    sync(method: string, collection: Collection, options?: {
        success?: (json?: any[]) => void;
        error?: (xhr: any, status: any, error: any) => void;
        [propName: string]: any;
    }): object;
    toJSON(): object[];
    trigger(eventType: string): undefined;
    unshift(m: object, options?: {
        silent?: boolean;
        at?: number;
        merge?: boolean;
        sort?: boolean;
        force?: boolean;
        deferred?: boolean;
        [propName: string]: any;
    }): Promise<Model[]> | Model[];
    whenReady(): Promise<any>;
    where(attrs: object | object[], options?: object): Promise<Model[]> | Model[];
    whereToCollection(attrs: object | object[], options?: object): Collection | Promise<Collection>;
    without(...var_args: Model[]): Model[];
}
export namespace Collection {
    // tslint:disable-next-line interface-over-type-literal
    type CustomPagingOptionsReturn = {
        totalResults?: number;
        limit?: number;
        count?: number;
        offset?: number;
        hasMore?: boolean;
    };
    // tslint:disable-next-line interface-over-type-literal
    type SetRangeLocalPromise = {
        start: number;
        count: number;
        models: Model[];
    };
}
export class Model {
    attributes: object;
    customURL: ((param0: string, param1: Model, param2: object) => string | object | null) | null;
    defaults: object;
    id: string | null;
    idAttribute: string | null;
    omitLanguageHeader: boolean;
    parse: ((param0: object) => object);
    parseSave: ((param0: object) => object);
    urlRoot: string | null;
    validate: ((param0: object, param1: object) => string | object | null) | null;
    validationError: string | object | null;
    constructor(attributes?: object, options?: object);
    static extend(properties?: {
        parse?: (data: any) => any;
        parseSave?: (data: any) => any;
        urlRoot?: string;
        initialize?: (models: Model[], options: object) => void;
        validate?: null | object | string | ((attributes: object, options?: Model) => number);
        [propName: string]: any;
    }, classProperties?: object): any;
    changedAttributes(attributes?: object): object | boolean;
    clear(options?: object): Model | boolean;
    clone(): Model;
    destroy(options?: {
        success?: (model: Model, response: any, options: object) => void;
        error?: (model: Model, xhr: any, options: object) => void;
        wait?: boolean;
        [propName: string]: any;
    }): boolean;
    fetch(options?: {
        success?: (model: Model, response: any, options: object) => void;
        error?: (model: Model, xhr: any, options: object) => void;
        [propName: string]: any;
    }): object;
    get(property: string): object;
    has(property: string): boolean;
    hasChanged(attribute?: string): boolean;
    invert(): object;
    isNew(): boolean;
    isValid(): boolean;
    keys(): object[];
    listenTo(otherObj: object, eventType: string, callback: (eventType: string, data: object) => void): undefined;
    listenToOnce(otherObj: object, eventType: string, callback: (eventType: string, data: object) => void): undefined;
    matches(attrs: object): ((param0: Model) => boolean);
    off(eventType?: string | object, callback?: (eventType: string, data: object) => void, context?: object): undefined;
    omit(keys: object[] | object): object;
    on(eventType: string | object, callback: (eventType: string, data: object) => void, context?: object): undefined;
    once(eventType: string, callback: (eventType: string, data: object) => void, context?: object): undefined;
    pairs(): object;
    pick(keys: object[] | object): object;
    previous(attr: string): object;
    previousAttributes(): object;
    save(attributes?: object, options?: {
        success?: (model: Model, response: any, options: object) => void;
        error?: (model: Model, xhr: any, options: object) => void;
        contentType?: string;
        valdiate?: boolean;
        wait?: boolean;
        patch?: boolean;
        attrs?: object;
        [propName: string]: any;
    }): object | boolean;
    set(property: string | object, value?: object, options?: object): Model | boolean;
    stopListening(otherObj?: object, eventType?: string, callback?: (eventType: string, data: object) => void): undefined;
    sync(method: string, model: Model, options?: object): object;
    toJSON(): object;
    trigger(eventType: string): undefined;
    unset(property: string, options?: object): boolean;
    url(): string | null;
    values(): object[];
}
export class OAuth {
    constructor(attributes: object, header: string);
    cleanAccessTokenRequest(): undefined;
    cleanAccessTokenResponse(): undefined;
    clientCredentialGrant(): undefined;
    getAccessTokenRequest(): object;
    getAccessTokenResponse(): object;
    getHeader(): object;
    isInitialized(): boolean;
    setAccessTokenRequest(data: object): undefined;
    setAccessTokenResponse(data: object): undefined;
}
// tslint:disable-next-line no-unnecessary-class
export class URLError {
    constructor();
}


text:
author: robmyers
comments: true
date: 2007-05-12 06:04:18+00:00
layout: post
slug: joy-garnett
title: Joy Garnett
wordpress_id: 1291
categories:
- Aesthetics
- Free Culture
---

[iCommons » Blog Archive » Art Intercom: featuring painter, Joy Garnett](http://icommons.org/2007/05/11/art-intercom-featuring-painter-joy-garnett/#more-635)

_To me painting has always been a remix. It is a really old technology that excels at remixing. But the remixing has to do with the eye, the hand, the memory…_

Good interview with the excellent Joy Garnett at iCommons. Her current show, "Strange Weather" looks wonderful as well.


text:
/**
 * @file event.hpp
 * @author Albert Uchytil, Tomas Coufal
 * @brief Event class which specifies calendar actions
 */
#include "event.hpp"

Event::Event(double t, double d, Transition * trans, std::vector<Token *> * tok):
    time(t), duration(d), transition(trans), Tokens(tok) {
    //ctor
}

Event::~Event() {
    //dtor, destruct tokens vector
    delete Tokens;
    debug("event", "destroyed");
}

/**
 * Return pointer to transition (transition is private)
 *
 * @return tranistion poiter
 */
Transition * Event::GetTransitionPtr() {
    return this->transition;
}

/**
 * Add token to event's evidence
 *
 * Push token pointer to the events vector containig all tokens affected by the
 * transition.
 * @param token Token that should be added
 */
void Event::AddToken(Token * token) {
    debug("event", "adding token");
    this->Tokens->push_back(token);
}


text:
'use strict';

describe('Directive: map', function () {

  // load the directive's module
  beforeEach(module('handbook'));

  var scope;

  beforeEach(inject(function ($rootScope) {
    scope = $rootScope.$new();
  }));

});


text:
/**
 * Support and FAQ: visit Atmel Support
 */
#ifndef CONF_SPI_MASTER_H_INCLUDED
#define CONF_SPI_MASTER_H_INCLUDED

//! Default Config Spi Master Dummy Field
// #define CONFIG_SPI_MASTER_DUMMY                0xFF

#endif /* CONF_SPI_MASTER_H_INCLUDED */


text:
require 'helper'

describe Stackdriver::Client::Custom do

  before do
    Stackdriver.clear
  end

  it 'is testable'

end


text:
<?xml version="1.0" encoding="utf-8"?>

<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0">
  <DefaultLanguage xmlns="" code="en-US"/>
  <App xmlns="" ProductID="{12463e46-329f-43e6-a52a-1badbabf6ace}" Title="AnimationBehaviorDemo.WinPhone" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal"  Author="AnimationBehaviorDemo.WinPhone author" Description="Sample description" Publisher="AnimationBehaviorDemo.WinPhone" PublisherID="{c4b6789b-ed52-4896-b9af-5d5362150cc1}">
    <IconPath IsRelative="true" IsResource="false">Assets\ApplicationIcon.png</IconPath>
    <Capabilities>
      <Capability Name="ID_CAP_NETWORKING"/>
      <Capability Name="ID_CAP_MEDIALIB_AUDIO"/>
      <Capability Name="ID_CAP_MEDIALIB_PLAYBACK"/>
      <Capability Name="ID_CAP_SENSORS"/>
      <Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>
    </Capabilities>
    <Tasks>
      <DefaultTask  Name ="_default" NavigationPage="MainPage.xaml"/>
    </Tasks>
    <Tokens>
      <PrimaryToken TokenID="PhoneApp1Token" TaskName="_default">
        <TemplateFlip>
          <SmallImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileSmall.png</SmallImageURI>
          <Count>0</Count>
          <BackgroundImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileMedium.png</BackgroundImageURI>
          <Title>AnimationBehaviorDemo.WinPhone</Title>
          <BackContent></BackContent>
          <BackBackgroundImageURI></BackBackgroundImageURI>
          <BackTitle></BackTitle>
          <DeviceLockImageURI></DeviceLockImageURI>
          <HasLarge></HasLarge>
        </TemplateFlip>
      </PrimaryToken>
    </Tokens>
    <ScreenResolutions>
      <ScreenResolution Name="ID_RESOLUTION_WVGA"/>
      <ScreenResolution Name="ID_RESOLUTION_WXGA"/>
      <ScreenResolution Name="ID_RESOLUTION_HD720P"/>
    </ScreenResolutions>
  </App>
</Deployment>


text:
from django.urls import path
from django.utils.translation import pgettext_lazy

from .views import follow, embed_follow, confirm_follow, unfollow_by_link

urlpatterns = [
    path("<int:pk>/follow/", follow, name="foirequestfollower-follow"),
    path(
        "<int:pk>/follow/embed/", embed_follow, name="foirequestfollower-follow_embed"
    ),
    path(
        pgettext_lazy("url part", "confirm/<int:follow_id>/<str:check>/"),
        confirm_follow,
        name="foirequestfollower-confirm_follow",
    ),
    path(
        pgettext_lazy("url part", "unfollow/<int:follow_id>/<str:check>/"),
        unfollow_by_link,
        name="foirequestfollower-confirm_unfollow",
    ),
]


text:
In order to run vulnerability scanning, use `carash` console as explained below.

## Overview

Vulnerability scanning with use of `carash` take the following procedure.

1. [start `carash`](#boot-carash)
2. [`site new` to create a new site or `site select` to select the existing sites](#site-new)
3. [`target add` to add a target host](#target-add)
4. [`testcase run` to execute the single *TestCase*](#testcase-run)
5. [`attack` to automatically execute tree-shaped *TestSuite*](#attack)
6. [`report create` to create report after the completion of the test](#report-create)

The command `help` shows the list of available commands and their brief explanations.

Some commands have subcommands. Press `help` after a command(`site help` for instance), the list and the brief explanations of its subcommands are shown. Bear it in mind.

## boot carash

You may know, some tools for vulnerability scanning, not limited to Caras-Framework, need the root privilege. An [Installed](INSTALL.md) sample *TestSuite* has *TestCase*s that need the privilege as well.

```bash
$ sudo carash
```

When using docker-compose, you won't need `sudo`.

## site new

In `carash`, *site* is a group that consists of *target* IP addresses. Scan is executed for the *target*s under the management of *site*.

Below is an example to create *site* named "sample_site".

```
carash # site new sample_site
create a new site named sample_site
carash [sample_site] #
```

The prompt changes to `carash [sample_site]`, which suggests that "sample_site" is the *site* currently selected.

## target add

Add a target host to *site*.

```
carash [sample_site] # target add 127.0.0.1
Added ip address : 127.0.0.1
carash [sample_site] #
```

`127.0.0.1` is added as a *target* host to *site*. `target list` lists the hosts that the *site* contains. `target delete <number> | <IP address>` deletes the host specified by `<number>` or `<IP address>`. `<number>` may be confirmed by `target list` command.

```
carash [sample_site] # target list
 List of Host

 1  127.0.0.1

carash [sample_site] # target delete 1
Really want to delete target 127.0.0.1? [Y/n] > Y
Deleted target 127.0.0.1 successfully
carash [sample_site] #
```

Before proceeding, execute `target add 127.0.0.1` once again.

## testcase run

Although Caras-Framework is to execute multiple *TestCase*s consecutively, you might want to run a single *TestCase* manually. The sample *TestSuite* contains `ImportNmapResult` that is useful for that.

Skilled penetration testers wisely choose command options for port scanning, depending on network conditions, responses upon attacks, and so forth.

Before using `ImportNmapResult`, run `nmap` and save its result in the form of either xml or text under the directory `$(pwd)/nmap/`

Hit `testcase run` with no option shows the list of executable *TestCase*s.

```
carash [sample_site] # testcase run
Run test case individually.
Select test case number to run or "x" to exit
                  List of Test case

 1  TestSuites::Default::Icmp::Ping
 2  TestSuites::Default::Tcp::SslConnect
 3  TestSuites::Default::Tcp::Http::DetectHttpService
 4  TestSuites::Default::Tcp::Http::BannerGrabber
 5  TestSuites::Default::ImportNmapResult
 6  TestSuites::Default::Tcp::SynScan

Which do you want to run? [1 - 6]
```

A command with option like `testcase run TestSuites::Default::ImportNmapResult` immediately shows the next dialogue.

In the example above, select `5` to run `ImportNmapResult`.

Next is to select the *target* host.

```
Select target host to test or "x" to exit
   List of Host

 1  127.0.0.1

Which do you want to test? [1]
```

Provide a reply, `ImportNmapResult` will start.

```
Which do you want to test? [1] 1
TestSuites::Default::ImportNmapResult instantiated
TestSuites::Default::ImportNmapResult start
TestSuites::Default::ImportNmapResult on 127.0.0.1 start (waiting:0 running:1/30)
Ctrl+c to cancel.
Specify nmap result directory (/Users/gsx/nmap) >
```

Press Enter with no directory given, then the default path will be selected. Make sure that the nmap logs are stored in the displayed directory, and press Enter.

Then, the parsed nmap log will be displayed.

```
+------+-------+-------+-------------+------------------------------------------------------------------+
|                                               tcp ports                                               |
+------+-------+-------+-------------+------------------------------------------------------------------+
| No.  | proto | state | service     | version                                                          |
+------+-------+-------+-------------+------------------------------------------------------------------+
| 21   | tcp   | open  | ftp         | vsftpd 2.3.4                                                     |
| 22   | tcp   | open  | ssh         | OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)                     |
| 23   | tcp   | open  | telnet      | Linux telnetd                                                    |
| 25   | tcp   | open  | smtp        | Postfix smtpd                                                    |
*snip*
Import these result? [Y/n] >
```

If expected result is shown, press `Y` to exit.

```
Import these result? [Y/n] > Y
TestSuites::Default::ImportNmapResult end
carash [sample_site] #
```

`dump` command may be useful to know the status of the current host. With this command executed, the ports of the *target* host are listed.

```
carash [sample_site] # dump
ip : 127.0.0.1
+------+-------+-----+-------+---------+--------------+------------------------------------------------------------------+
|                                                       tcp ports                                                        |
+------+-------+-----+-------+---------+--------------+------------------------------------------------------------------+
| no   | state | ssl | plain | service | nmap_service | nmap_version                                                     |
+------+-------+-----+-------+---------+--------------+------------------------------------------------------------------+
| 21   | open  |     |       |         | ftp          | vsftpd 2.3.4                                                     |
| 22   | open  |     |       |         | ssh          | OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)                     |
| 23   | open  |     |       |         | telnet       | Linux telnetd                                                    |
| 25   | open  |     |       |         | smtp         | Postfix smtpd                                                    |
*snip*
carash [sample_site] #
```

## attack

If open ports are registered, then `attack` is prepared. Just perform `attack` command.

```
carash [sample_site] # attack
Start tester for 127.0.0.1
carash [sample_site] # Done tests for 127.0.0.1
Done all tests
```

Wait for a while, then `Done all tests` will appear as shown above. This concludes a test.

In case the execution takes a long time, `status` command may be used to know the progress status of the test.

```
carash [sample_site] # status
Tester:127.0.0.1@sample_site => running: [ 2 > 1 > 1 ]
 root
 |--fin TestSuites::Default::Icmp::Ping
 `--run TestSuites::Default::Tcp::SslConnect
    `--TestSuites::Default::Tcp::Http::DetectHttpService
       `--TestSuites::Default::Tcp::Http::BannerGrabber
Queued  testers : 6
Running testers : 6/30
Waiting testers : 0
All threads     : 19
carash [sample_site] #
```

To know the status more in detail, `toggle` command may be useful. Once this command is performed, all the log that *TestCase* generates will be displayed in the console in real time.

```
carash [sample_site] # toggle
Showing sub thread message : true
carash [sample_site] #
Tester:127.0.0.1@sample_site start running
TestSuites::Default::Icmp::Ping for 127.0.0.1 instantiated
TestSuites::Default::Icmp::Ping on 127.0.0.1 start (waiting:0 running:1/30)
TestSuites::Default::Tcp::SslConnect for 127.0.0.1 instantiated
TestSuites::Default::Tcp::SslConnect on 127.0.0.1:22/tcp start (waiting:0 running:18/30)
*snip*
```

To stop the log from being shown, execute `toggle` again.

To break off the test, use `stop` command. Once this command is executed, the test is terminated with no way to resume it.

## report create

When all the tests are completed, execute `report create` command to create a report.

```
carash [sample_site] # report create
Report is created in /User/gsx/result/sites/sample_site/report_20170801-010203.html
carash [sample_site] #
```

An html file will be generated in the displayed path. Check the file using the browser of your choice. If the framework runs on macOS, the browser will be automatically launched.

Notice that a directory named `$(pwd)/result` is created. This directory contains logfile and the outputs of *TestCase*.

# Conclusion

Hope you'll find this tutorial helpful. `carash` has many other commands. Get familiar with them by referring to help or trying them out. Only `attack` and `testcase run` require safety precautions.

This is the end of the tutorial. The next step is to [develop *TestSuite*s](DEVELOP_TEST_SUITES.md).


text:
package de.symeda.demo.java8.misc;

public class MathInvoker {

	public static int add(int x, int y) {
		return x + y;
	}

	public static int addExact(int x, int y) {

		return Math.addExact(x, y);
	}

}


text:
package org.apache.commons.math3.geometry.partitioning;

import org.apache.commons.math3.geometry.Point;
import org.apache.commons.math3.geometry.Space;

/** This interface represents an hyperplane of a space.

 *
The most prominent place where hyperplane appears in space
 * partitioning is as cutters. Each partitioning node in a {@link
 * BSPTree BSP tree} has a cut {@link SubHyperplane sub-hyperplane}
 * which is either an hyperplane or a part of an hyperplane. In an
 * n-dimensions euclidean space, an hyperplane is an (n-1)-dimensions
 * hyperplane (for example a traditional plane in the 3D euclidean
 * space). They can be more exotic objects in specific fields, for
 * example a circle on the surface of the unit sphere.

 *

 * Note that this interface is not intended to be implemented
 * by Apache Commons Math users, it is only intended to be implemented
 * within the library itself. New methods may be added even for minor
 * versions, which breaks compatibility for external implementations.
 *

 * @param <S> Type of the space.

 * @version $Id: Hyperplane.java 1566416 2014-02-09 20:56:55Z luc $
 * @since 3.0
 */
public interface Hyperplane<S extends Space> {

    /** Copy the instance.
     *
The instance created is completely independant of the original
     * one. A deep copy is used, none of the underlying objects are
     * shared (except for immutable objects).

     * @return a new hyperplane, copy of the instance
     */
    Hyperplane<S> copySelf();

    /** Get the offset (oriented distance) of a point.
     *
The offset is 0 if the point is on the underlying hyperplane,
     * it is positive if the point is on one particular side of the
     * hyperplane, and it is negative if the point is on the other side,
     * according to the hyperplane natural orientation.

     * @param point point to check
     * @return offset of the point
     */
    double getOffset(Point<S> point);

    /** Project a point to the hyperplane.
     * @param point point to project
     * @return projected point
     * @since 3.3
     */
    Point<S> project(Point<S> point);

    /** Get the tolerance below which points are considered to belong to the hyperplane.
     * @return tolerance below which points are considered to belong to the hyperplane
     * @since 3.3
     */
    double getTolerance();

    /** Check if the instance has the same orientation as another hyperplane.
     *
This method is expected to be called on parallel hyperplanes. The
     * method should not re-check for parallelism, only for
     * orientation, typically by testing something like the sign of the
     * dot-products of normals.

     * @param other other hyperplane to check against the instance
     * @return true if the instance and the other hyperplane have
     * the same orientation
     */
    boolean sameOrientationAs(Hyperplane<S> other);

    /** Build a sub-hyperplane covering the whole hyperplane.
     * @return a sub-hyperplane covering the whole hyperplane
     */
    SubHyperplane<S> wholeHyperplane();

    /** Build a region covering the whole space.
     * @return a region containing the instance
     */
    Region<S> wholeSpace();

}


text:
<!DOCTYPE html>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

  <meta name="description" content="Javadoc API documentation for Fresco." />

<link rel="shortcut icon" type="image/x-icon" href="../../../../../../favicon.ico" />
<title>

  ImagePerfState - Fresco API

| Fresco

</title>
<link href="../../../../../../../assets/doclava-developer-docs.css" rel="stylesheet" type="text/css" />
<link href="../../../../../../../assets/customizations.css" rel="stylesheet" type="text/css" />

      Fresco

          <form accept-charset="utf-8" class="gsc-search-box"
                onsubmit="return submit_search()">

                    <input id="search_autocomplete" class="gsc-input" type="text" size="33" autocomplete="off"
                      title="search developer docs" name="q"
                      value="search developer docs"
                      onFocus="search_focus_changed(this, true)"
                      onBlur="search_focus_changed(this, false)"
                      onkeydown="return search_changed(event, true, '../../../../../../')"
                      onkeyup="return search_changed(event, false, '../../../../../../')" />

          </form>

                Packages |
                Classes

  com.facebook.animated.gif

  com.facebook.animated.webp

  com.facebook.binaryresource

  com.facebook.cache.common

  com.facebook.cache.disk

  com.facebook.common.activitylistener

  com.facebook.common.disk

  com.facebook.common.executors

  com.facebook.common.file

  com.facebook.common.internal

  com.facebook.common.lifecycle

  com.facebook.common.logging

  com.facebook.common.media

  com.facebook.common.memory

  com.facebook.common.references

  com.facebook.common.statfs

  com.facebook.common.streams

  com.facebook.common.time

  com.facebook.common.util

  com.facebook.common.webp

  com.facebook.datasource

  com.facebook.drawable.base

  com.facebook.drawee.backends.pipeline

  com.facebook.drawee.backends.pipeline.info

  com.facebook.drawee.backends.pipeline.info.internal

  com.facebook.drawee.backends.volley

  com.facebook.drawee.components

  com.facebook.drawee.controller

  com.facebook.drawee.debug

  com.facebook.drawee.debug.listener

  com.facebook.drawee.drawable

  com.facebook.drawee.generic

  com.facebook.drawee.gestures

  com.facebook.drawee.interfaces

  com.facebook.drawee.span

  com.facebook.drawee.view

  com.facebook.fresco.animation.backend

  com.facebook.fresco.animation.bitmap

  com.facebook.fresco.animation.bitmap.cache

  com.facebook.fresco.animation.bitmap.preparation

  com.facebook.fresco.animation.bitmap.wrapper

  com.facebook.fresco.animation.drawable

  com.facebook.fresco.animation.drawable.animator

  com.facebook.fresco.animation.factory

  com.facebook.fresco.animation.frame

  com.facebook.imageformat

  com.facebook.imagepipeline.animated.base

  com.facebook.imagepipeline.animated.factory

  com.facebook.imagepipeline.animated.impl

  com.facebook.imagepipeline.animated.util

  com.facebook.imagepipeline.backends.okhttp3

  com.facebook.imagepipeline.backends.volley

  com.facebook.imagepipeline.bitmaps

  com.facebook.imagepipeline.cache

  com.facebook.imagepipeline.common

  com.facebook.imagepipeline.core

  com.facebook.imagepipeline.datasource

  com.facebook.imagepipeline.decoder

  com.facebook.imagepipeline.drawable

  com.facebook.imagepipeline.image

  com.facebook.imagepipeline.listener

  com.facebook.imagepipeline.memory

  com.facebook.imagepipeline.nativecode

  com.facebook.imagepipeline.platform

  com.facebook.imagepipeline.postprocessors

  com.facebook.imagepipeline.producers

  com.facebook.imagepipeline.request

  com.facebook.imagepipeline.systrace

  com.facebook.imageutils

  com.facebook.webpsupport

  com.facebook.widget.text.span

Interfaces

ImageOriginListener

ImagePerfDataListener

Classes

ForwardingImageOriginListener

ImageOriginRequestListener

ImageOriginUtils

ImagePerfData

ImagePerfMonitor

ImagePerfState

ImagePerfUtils

Annotations

ImageLoadStatus

ImageOrigin

            Packages |
            Classes

Summary:

  Ctors

  | Methods

  | Inherited Methods

| [Expand All]

    public

    class

ImagePerfState

    extends Object

        java.lang.Object

               ↳

        com.facebook.drawee.backends.pipeline.info.ImagePerfState

Summary

Public Constructors

        ImagePerfState()

Public Methods

            int

        getImageLoadStatus()

            void

        reset()

            void

        setCallerContext(Object callerContext)

            void

        setCanceled(boolean canceled)

            void

        setControllerCancelTimeMs(long controllerCancelTimeMs)

            void

        setControllerFailureTimeMs(long controllerFailureTimeMs)

            void

        setControllerFinalImageSetTimeMs(long controllerFinalImageSetTimeMs)

            void

        setControllerId(String controllerId)

            void

        setControllerIntermediateImageSetTimeMs(long controllerIntermediateImageSetTimeMs)

            void

        setControllerSubmitTimeMs(long controllerSubmitTimeMs)

            void

        setImageInfo(ImageInfo imageInfo)

            void

        setImageLoadStatus(int imageLoadStatus)

            void

        setImageOrigin(int imageOrigin)

            void

        setImageRequest(ImageRequest imageRequest)

            void

        setImageRequestEndTimeMs(long imageRequestEndTimeMs)

            void

        setImageRequestStartTimeMs(long imageRequestStartTimeMs)

            void

        setPrefetch(boolean prefetch)

            void

        setRequestId(String requestId)

            void

        setSuccessful(boolean successful)

            ImagePerfData

        snapshot()

  [Expand]

Inherited Methods

From class

  java.lang.Object

            Object

        clone()

            boolean

        equals(Object arg0)

            void

        finalize()

            final

            Class<?>

        getClass()

            int

        hashCode()

            final

            void

        notify()

            final

            void

        notifyAll()

            String

        toString()

            final

            void

        wait(long arg0, int arg1)

            final

            void

        wait(long arg0)

            final

            void

        wait()

Public Constructors

        public

      ImagePerfState
      ()

Public Methods

        public

        int

      getImageLoadStatus
      ()

        public

        void

      reset
      ()

        public

        void

      setCallerContext
      (Object callerContext)

        public

        void

      setCanceled
      (boolean canceled)

        public

        void

      setControllerCancelTimeMs
      (long controllerCancelTimeMs)

        public

        void

      setControllerFailureTimeMs
      (long controllerFailureTimeMs)

        public

        void

      setControllerFinalImageSetTimeMs
      (long controllerFinalImageSetTimeMs)

        public

        void

      setControllerId
      (String controllerId)

        public

        void

      setControllerIntermediateImageSetTimeMs
      (long controllerIntermediateImageSetTimeMs)

        public

        void

      setControllerSubmitTimeMs
      (long controllerSubmitTimeMs)

        public

        void

      setImageInfo
      (ImageInfo imageInfo)

        public

        void

      setImageLoadStatus
      (int imageLoadStatus)

        public

        void

      setImageOrigin
      (int imageOrigin)

        public

        void

      setImageRequest
      (ImageRequest imageRequest)

        public

        void

      setImageRequestEndTimeMs
      (long imageRequestEndTimeMs)

        public

        void

      setImageRequestStartTimeMs
      (long imageRequestStartTimeMs)

        public

        void

      setPrefetch
      (boolean prefetch)

        public

        void

      setRequestId
      (String requestId)

        public

        void

      setSuccessful
      (boolean successful)

        public

        ImagePerfData

      snapshot
      ()

 +Generated by Doclava.
 +


text:
def render_placeholder(environ, start_response):
    """Send the user a simple placeholder about missing SWAT."""
    status = '200 OK'
    response_headers = [('Content-type', 'text/html')]
    start_response(status, response_headers)

    yield "<!doctype html>\n"
    yield "\n"
    yield "  <title>The Samba web service</title>\n"
    yield "\n"

    yield "\n"
    yield "
Welcome to this Samba web server.
\n"
    yield "
This page is a simple placeholder. You probably want to install "
    yield "SWAT. More information can be found "
    yield "on the wiki.
"
    yield "
\n"
    yield "\n"
    yield "\n"

def __call__(environ, start_response):
    """Handle a HTTP request."""
    from wsgiref.util import application_uri, shift_path_info
    from urlparse import urljoin

    try:
        import swat
    except ImportError, e:
        print "NO SWAT: %r" % e
        have_swat = False
    else:
        have_swat = True

    orig_path = environ['PATH_INFO']
    name = shift_path_info(environ)

    if name == "":
        if have_swat:
            start_response('301 Redirect',
                [('Location', urljoin(application_uri(environ), 'swat')),])
            return []
        else:
            return render_placeholder(environ, start_response)
    elif have_swat and name == "swat":
        return swat.__call__(environ, start_response)
    else:
        status = '404 Not found'
        response_headers = [('Content-type', 'text/html')]
        start_response(status, response_headers)
        return ["The path %s (%s) was not found" % (orig_path, name)]

if __name__ == '__main__':
    from wsgiref import simple_server
    httpd = simple_server.make_server('localhost', 8090, __call__)
    print "Serving HTTP on port 8090..."
    httpd.serve_forever()


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ReplaceAttachments
{
    /// <summary>
    /// Interaction logic for AttachmentsDockpaneView.xaml
    /// </summary>
    public partial class AttachmentsDockpaneView : UserControl
    {
        public AttachmentsDockpaneView()
        {
            InitializeComponent();
        }

    }
}


text:
package getter

import (
	"context"
	"fmt"
	"io"
	"os"
)

// readerFunc is syntactic sugar for read interface.
type readerFunc func(p []byte) (n int, err error)

func (rf readerFunc) Read(p []byte) (n int, err error) { return rf(p) }

// Copy is a io.Copy cancellable by context
func Copy(ctx context.Context, dst io.Writer, src io.Reader) (int64, error) {
	// Copy will call the Reader and Writer interface multiple time, in order
	// to copy by chunk (avoiding loading the whole file in memory).
	return io.Copy(dst, readerFunc(func(p []byte) (int, error) {

		select {
		case <-ctx.Done():
			// context has been canceled
			// stop process and propagate "context canceled" error
			return 0, ctx.Err()
		default:
			// otherwise just run default io.Reader implementation
			return src.Read(p)
		}
	}))
}

// copyReader copies from an io.Reader into a file, using umask to create the dst file
func copyReader(dst string, src io.Reader, fmode, umask os.FileMode) error {
	dstF, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, fmode)
	if err != nil {
		return err
	}
	defer dstF.Close()

	_, err = io.Copy(dstF, src)
	if err != nil {
		return err
	}

	// Explicitly chmod; the process umask is unconditionally applied otherwise.
	// We'll mask the mode with our own umask, but that may be different than
	// the process umask
	return os.Chmod(dst, mode(fmode, umask))
}

// copyFile copies a file in chunks from src path to dst path, using umask to create the dst file
func copyFile(ctx context.Context, dst, src string, disableSymlinks bool, fmode, umask os.FileMode) (int64, error) {
	if disableSymlinks {
		fileInfo, err := os.Lstat(src)
		if err != nil {
			return 0, fmt.Errorf("failed to check copy file source for symlinks: %w", err)
		}
		if fileInfo.Mode()&os.ModeSymlink == os.ModeSymlink {
			return 0, ErrSymlinkCopy
		}
	}

	srcF, err := os.Open(src)
	if err != nil {
		return 0, err
	}
	defer srcF.Close()

	dstF, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, fmode)
	if err != nil {
		return 0, err
	}
	defer dstF.Close()

	count, err := Copy(ctx, dstF, srcF)
	if err != nil {
		return 0, err
	}

	// Explicitly chmod; the process umask is unconditionally applied otherwise.
	// We'll mask the mode with our own umask, but that may be different than
	// the process umask
	err = os.Chmod(dst, mode(fmode, umask))
	return count, err
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<TITLE>
org.apache.poi.extractor (POI API Documentation)
</TITLE>

<META NAME="date" CONTENT="2012-11-26">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">

org.apache.poi.extractor

Classes

CommandLineTextExtractor

ExtractorFactory


text:
from sklearn import datasets
from sklearn import __version__ as sklearn_version
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier, ExtraTreesClassifier, GradientBoostingClassifier
from sklearn.metrics import log_loss, accuracy_score, f1_score
import pandas as pd
import numpy as np
from linear_stacker import MultiLabelClassificationLinearPredictorStacker
try:
    from sklearn.model_selection import StratifiedKFold
except ImportError:
    from sklearn.cross_validation import StratifiedKFold

def get_folds(data, target):
    """returns correct folding generator for different versions of sklearn"""
    if sklearn_version.split('.')[1] == '18':
        # Module model_selection is in the distribution
        kf = StratifiedKFold(n_splits=5, shuffle=True, random_state=1)
        return kf.split(data, target)
    else:
        # Module model_selection is not in the distribution
        kf = StratifiedKFold(y=target, n_folds=5, shuffle=True, random_state=1)
        return kf

def main():
    pd.options.display.max_rows = 600

    # Load iris dataset
    dataset = datasets.load_iris()
    n_classes = len(np.unique(dataset.target))

    classifiers = [
        ('logit', LogisticRegression(C=0.1,
                                     random_state=1)),
        ('xtr', ExtraTreesClassifier(n_estimators=50,
                                     max_features=.4,
                                     max_depth=10,
                                     random_state=2,
                                     n_jobs=-1)),
        ('rfr', RandomForestClassifier(n_estimators=50,
                                       max_features=.2,
                                       max_depth=10,
                                       random_state=3,
                                       n_jobs=-1)),
        ('gbr', GradientBoostingClassifier(n_estimators=20,
                                           max_depth=3,
                                           subsample=.6,
                                           learning_rate=.01,
                                           random_state=4))
    ]

    # Go through classifiers
    oof_labels = np.zeros((len(dataset.data), len(classifiers)))
    oof_probas = np.zeros((len(dataset.data), len(classifiers) * n_classes))

    for reg_i, (name, reg) in enumerate(classifiers):
        # compute out of fold (OOF) predictions
        for trn_idx, val_idx in get_folds(dataset.data, dataset.target):
            # Split data in training and validation sets
            trn_X, trn_Y = dataset.data[trn_idx], dataset.target[trn_idx]
            val_X = dataset.data[val_idx]
            # Fit the classifier
            reg.fit(trn_X, trn_Y)
            # Predict OOF data
            oof_probas[val_idx, reg_i * n_classes: (reg_i + 1) * n_classes] = reg.predict_proba(val_X)
            oof_labels[val_idx, reg_i] = reg.predict(val_X)

        # Display OOF score
        print("Accuracy for classifier %6s : %.5f"
              % (name, accuracy_score(dataset.target, oof_labels[:, reg_i])))
        print("F1_score for classifier %6s : %.5f"
              % (name, f1_score(dataset.target, oof_labels[:, reg_i], average='micro')))
        print("Log_loss for classifier %6s : %.5f"
              % (name, log_loss(dataset.target, oof_probas[:, reg_i * n_classes: (reg_i + 1) * n_classes])))

    # Use stacker
    stacker = MultiLabelClassificationLinearPredictorStacker(metric=log_loss, verbose=0, max_iter=100)
    stacker.fit(predictors=oof_probas, target=dataset.target)
    print("Resulted log_loss : ", log_loss(dataset.target, stacker.predict_proba(oof_probas)))
    print("Resulted F1-score : ", f1_score(dataset.target, stacker.predict(oof_probas), average='macro'))
    print("Resulted accuracy : ", accuracy_score(dataset.target, stacker.predict(oof_probas)))

if __name__ == '__main__':
    main()


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using CheckMapp.ViewModels.PhotoViewModels;
using CheckMapp.Resources;
using CheckMapp.ViewModels;
using CheckMapp.Model.Tables;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Microsoft.Phone.Tasks;
using CheckMapp.Utils;
using GalaSoft.MvvmLight.Messaging;
using CheckMapp.ViewModels.POIViewModels;

namespace CheckMapp.Views.PhotoViews
{
    public partial class ListPhotoView : PhoneApplicationPage
    {
        public ListPhotoView()
        {
            InitializeComponent();
        }

        public ListPhotoViewModel ViewModel
        {
            get
            {
                return this.DataContext as ListPhotoViewModel;
            }
        }

        private void IconAdd_Click(object sender, EventArgs e)
        {
            ViewModel.EditPhotoCommand.Execute(new Tuple<int, Mode>(0, Mode.add));
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            var appbar = this.Resources["AppBarList"] as ApplicationBar;
            if (appbar.Buttons != null)
            {
                (appbar.Buttons[0] as ApplicationBarIconButton).Text = AppResources.Select;
                (appbar.Buttons[1] as ApplicationBarIconButton).Text = AppResources.AddPicture;
            }

            var appbarSelect = this.Resources["AppBarListSelect"] as ApplicationBar;
            if (appbarSelect.Buttons != null)
            {
                (appbarSelect.Buttons[0] as ApplicationBarIconButton).Text = AppResources.Delete;
            }
            ApplicationBar = this.Resources["AppBarList"] as ApplicationBar;
            (ApplicationBar.Buttons[0] as ApplicationBarIconButton).IsEnabled = (PhotoHubLLS.ItemsSource.Count > 0);

        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            PhotoHubLLS.ItemsSource = (this.DataContext as ListPhotoViewModel).GroupedPhotos;

            ViewModel.Loading = false;
        }

        protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
        {
            base.OnNavigatingFrom(e);
            if (e.NavigationMode == NavigationMode.Back && PhotoHubLLS.IsSelectionEnabled)
            {
                PhotoHubLLS.IsSelectionEnabled = false;
                e.Cancel = true;
            }
            if (e.Uri.OriginalString.Contains("ListPOI"))
            {
                Messenger.Default.Send<int, ListPOIViewModel>(ViewModel.Trip.Id);
            }
        }

        /// <summary>
        /// Click sur les options du menu contextuel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContextMenu_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = sender as MenuItem;
            if (menuItem != null && ((sender as MenuItem).DataContext is Picture))
            {
                Picture pictureSelected = (sender as MenuItem).DataContext as Picture;
                switch (menuItem.Name)
                {
                    case "EditPhoto":
                        ViewModel.EditPhotoCommand.Execute(new Tuple<int, Mode>(pictureSelected.Id, Mode.edit));
                        break;
                    case "DeletePhoto":
                        if (MessageBox.Show(AppResources.ConfirmationDeletePicture, "Confirmation", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                        {
                            ViewModel.DeletePictureCommand.Execute(pictureSelected);
                            PhotoHubLLS.ItemsSource = ViewModel.GroupedPhotos;

                            (ApplicationBar.Buttons[0] as ApplicationBarIconButton).IsEnabled = (PhotoHubLLS.ItemsSource.Count > 0);

                        }
                        break;
                }
            }
        }

        /// <summary>
        /// J'ai besoin de ça pour mettre à jour mon ContextMenu lorsque je reviens à un changement
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContextMenu_Opened(object sender, RoutedEventArgs e)
        {
            var menu = (ContextMenu)sender;
            var owner = (FrameworkElement)menu.Owner;
            if (owner.DataContext != menu.DataContext)
                menu.DataContext = owner.DataContext;
        }

        private void IconMultiSelect_Click(object sender, EventArgs e)
        {
            PhotoHubLLS.IsSelectionEnabled = !PhotoHubLLS.IsSelectionEnabled;
        }

        private void PhotoHubLLS_IsSelectionEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (PhotoHubLLS.IsSelectionEnabled)
                ApplicationBar = this.Resources["AppBarListSelect"] as ApplicationBar;
            else
                ApplicationBar = this.Resources["AppBarList"] as ApplicationBar;

            (ApplicationBar.Buttons[0] as ApplicationBarIconButton).IsEnabled = !PhotoHubLLS.IsSelectionEnabled;
        }

        private void IconDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(AppResources.ConfirmationDeletePictures, "Confirmation", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {

                ViewModel.DeletePicturesCommand.Execute(new List<object>(PhotoHubLLS.SelectedItems as IList<object>));
                PhotoHubLLS.ItemsSource = ViewModel.GroupedPhotos;
                (ApplicationBar.Buttons[0] as ApplicationBarIconButton).IsEnabled = (PhotoHubLLS.ItemsSource.Count > 0);
            }
        }

        private void StackPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            PhotoHubLLS.IsSelectionEnabled = false;

            if (!PhotoHubLLS.IsSelectionEnabled)
            {
                 Picture itemTapped = (sender as FrameworkElement).DataContext as Picture;
                ViewModel.PhotoCommand.Execute(itemTapped.Id);
            }
        }

        private void PhotoHubLLS_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (PhotoHubLLS.IsSelectionEnabled)
                (ApplicationBar.Buttons[0] as ApplicationBarIconButton).IsEnabled = (PhotoHubLLS.SelectedItems.Count > 0);
        }
    }
}


text:
/*
 * Hibernate Validator, declare and validate application constraints
 *
 * License: Apache License, Version 2.0
 * See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
 */
package org.hibernate.validator.ap.testmodel;

import java.util.Date;
import jakarta.validation.constraints.FutureOrPresent;
import jakarta.validation.constraints.Past;

public class ModelWithDateConstraints {

	/**
	 * Not allowed.
	 */
	@Past
	@FutureOrPresent
	public String string;

	@Past
	@FutureOrPresent
	public Date date;
}


text:
'''
Created by auto_sdk on 2014-12-17 17:22:51
'''
from top.api.base import RestApi
class RefundsApplyGetRequest(RestApi):
	def __init__(self,domain='gw.api.taobao.com',port=80):
		RestApi.__init__(self,domain, port)
		self.fields = None
		self.page_no = None
		self.page_size = None
		self.seller_nick = None
		self.status = None
		self.type = None

	def getapiname(self):
		return 'taobao.refunds.apply.get'


text:
#include "michael_alloc.h"

namespace memory {
    michael_heap s_MichaelHeap;
}


text:
#ifndef DYNAMICLIBRARY2_H
#define DYNAMICLIBRARY2_H

#ifdef D_PUBLIC_FORWARDING
/* note that the header from the dependency is purposefully in this module's public API */
#include "dynamiclibrary1.h"
#endif

/* specific platform settings */
#if defined(_WIN32)
#define DYNAMICLIBRARY2_EXPORT __declspec(dllexport)
#define DYNAMICLIBRARY2_IMPORT __declspec(dllimport)
#elif __GNUC__ >= 4
#define DYNAMICLIBRARY2_EXPORT __attribute__ ((visibility("default")))
#endif

/* defaults */
#ifndef DYNAMICLIBRARY2_EXPORT
#define DYNAMICLIBRARY2_EXPORT /* empty */
#endif
#ifndef DYNAMICLIBRARY2_IMPORT
#define DYNAMICLIBRARY2_IMPORT /* empty */
#endif

#if defined(D_BAM_DYNAMICLIBRARY_BUILD)
#define DYNAMICLIBRARY2_API DYNAMICLIBRARY2_EXPORT
#else
#define DYNAMICLIBRARY2_API DYNAMICLIBRARY2_IMPORT
#endif

extern DYNAMICLIBRARY2_API int DynamicLibrary2Function(char);

#endif /* STATICLIBRARY1_H */


text:
#ifndef dom_functypes_h_
#define dom_functypes_h_

#include <stddef.h>
#include <inttypes.h>

typedef unsigned int uint32_t;

/**
 * Severity levels for dom_msg function, based on syslog(3)
 */
enum {
	DOM_MSG_DEBUG,
	DOM_MSG_INFO,
	DOM_MSG_NOTICE,
	DOM_MSG_WARNING,
	DOM_MSG_ERROR,
	DOM_MSG_CRITICAL,
	DOM_MSG_ALERT,
	DOM_MSG_EMERGENCY
};

/**
 * Type of DOM message function
 */
typedef void (*dom_msg)(uint32_t severity, void *ctx, const char *msg, ...);

#endif


text:
enum { A, B, }; // CHECK: /warning: trailing comma in enum definition/

int a = { 1, }; // CHECK: /warning: trailing comma in initialiser/

main()
{
	return 0;
}


text:
<?php

namespace Billion\RestBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class BillionRestBundle extends Bundle
{
}


text: In progress document


text:
GoogleAlphabet

Google was founded by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University.

      Larry Page

      Sergey Brin


text:
@extends("admin.layout.base")

@section('content')

    <button type="button" class="close close-sm" data-dismiss="alert">

    </button>
     页面即将跳转~~

新增菜单

        <form class="form-horizontal adminex-form" action="/{{$admin_prefix}}/backmenu/insert" id="form" method="post">
            {{csrf_field()}}

                控制器中文名

                    <input type="text" placeholder="后台菜单" name="name" class="form-control">

                控制器名称

                    <input type="text" placeholder="Backmenu" name="controller_name" class="form-control">

                上级菜单

                    <select name="pid" class="form-control">
                        <option value="0">顶级菜单</option>
                        @foreach ($top_menus as $top_menu)
                        <option value="{{$top_menu->id}}">{{$top_menu->name}}</option>
                        @endforeach
                    </select>

                    提 交
                    返 回

        </form>

@endsection


text:
using System;
using System.Threading.Tasks;
using Orleans;
using Orleans.Runtime;

namespace Grains
{
    /// <summary>
    /// Demonstrates a grain that performs an internal operation based on a reminder.
    /// </summary>
    public class ReminderGrain : Grain, IReminderGrain, IRemindable
    {
        private int value;

        public override async Task OnActivateAsync()
        {
            await RegisterOrUpdateReminder(nameof(IncrementAsync), TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1));
            await base.OnActivateAsync();
        }

        public Task<int> GetValueAsync() => Task.FromResult(value);

        private Task IncrementAsync()
        {
            value += 1;
            return Task.CompletedTask;
        }

        /// <summary>
        /// Open up the reminder registration method for mocking.
        /// </summary>
        public virtual new Task<IGrainReminder> RegisterOrUpdateReminder(string reminderName, TimeSpan dueTime, TimeSpan period) =>
            base.RegisterOrUpdateReminder(reminderName, dueTime, period);

        public async Task ReceiveReminder(string reminderName, TickStatus status)
        {
            switch (reminderName)
            {
                case nameof(IncrementAsync):
                    await IncrementAsync();
                    break;

                default:
                    await UnregisterReminder(await GetReminder(reminderName));
                    break;
            }
        }
    }
}


text:
package org.apache.metron.writers.integration;

import com.google.common.collect.ImmutableList;
import org.adrianwalker.multilinestring.Multiline;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.metron.TestConstants;
import org.apache.metron.common.configuration.SensorParserConfig;
import org.apache.metron.common.utils.JSONUtils;
import org.apache.metron.enrichment.converter.EnrichmentConverter;
import org.apache.metron.enrichment.converter.EnrichmentKey;
import org.apache.metron.enrichment.converter.EnrichmentValue;
import org.apache.metron.enrichment.lookup.LookupKV;
import org.apache.metron.hbase.mock.MockHBaseTableProvider;
import org.apache.metron.hbase.mock.MockHTable;
import org.apache.metron.integration.*;
import org.apache.metron.integration.components.ConfigUploadComponent;
import org.apache.metron.integration.components.KafkaComponent;
import org.apache.metron.integration.components.ZKServerComponent;
import org.apache.metron.parsers.integration.components.ParserTopologyComponent;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.*;

import static org.junit.jupiter.api.Assertions.*;

public class SimpleHbaseEnrichmentWriterIntegrationTest extends BaseIntegrationTest {

  /**
   * {
   *     "parserClassName": "org.apache.metron.parsers.csv.CSVParser",
   *     "writerClassName": "org.apache.metron.writer.hbase.SimpleHbaseEnrichmentWriter",
   *     "sensorTopic": "dummy",
   *     "outputTopic": "output",
   *     "errorTopic": "error",
   *     "parserConfig": {
   *        "shew.table": "dummy",
   *        "shew.cf": "cf",
   *        "shew.keyColumns": "col2",
   *        "shew.enrichmentType": "et",
   *        "shew.hbaseProvider": "org.apache.metron.hbase.mock.MockHBaseTableProvider",
   *        "columns" : {
   *             "col1": 0,
   *             "col2": 1,
   *             "col3": 2
   *        }
   *     }
   * }
   */
  @Multiline
  public static String parserConfigJSON;

  @Test
  public void test() throws UnableToStartException, IOException {
    final String sensorType = "dummy";

    // the input messages to parse
    final List<byte[]> inputMessages = new ArrayList<byte[]>() {{
      add(Bytes.toBytes("col11,col12,col13"));
      add(Bytes.toBytes("col21,col22,col23"));
      add(Bytes.toBytes("col31,col32,col33"));
    }};

    // setup external components; kafka, zookeeper
    MockHBaseTableProvider.addToCache(sensorType, "cf");
    final Properties topologyProperties = new Properties();
    final ZKServerComponent zkServerComponent = getZKServerComponent(topologyProperties);
    final KafkaComponent kafkaComponent = getKafkaComponent(topologyProperties, new ArrayList<KafkaComponent.Topic>() {{
      add(new KafkaComponent.Topic(sensorType, 1));
    }});
    topologyProperties.setProperty("kafka.broker", kafkaComponent.getBrokerList());

    SensorParserConfig parserConfig = JSONUtils.INSTANCE.load(parserConfigJSON, SensorParserConfig.class);

    System.out.println("Workspace: " + System.getProperty("user.dir"));
    System.out.println("Configs path: ../" + TestConstants.SAMPLE_CONFIG_PATH);
    ConfigUploadComponent configUploadComponent = new ConfigUploadComponent()
            .withTopologyProperties(topologyProperties)
            .withGlobalConfigsPath("../" + TestConstants.SAMPLE_CONFIG_PATH)
            .withParserSensorConfig(sensorType, parserConfig);

    ParserTopologyComponent parserTopologyComponent = new ParserTopologyComponent.Builder()
            .withSensorTypes(Collections.singletonList(sensorType))
            .withTopologyProperties(topologyProperties)
            .withBrokerUrl(kafkaComponent.getBrokerList())
            .withOutputTopic(parserConfig.getOutputTopic())
            .build();

    ComponentRunner runner = new ComponentRunner.Builder()
            .withComponent("zk", zkServerComponent)
            .withComponent("kafka", kafkaComponent)
            .withComponent("config", configUploadComponent)
            .withComponent("org/apache/storm", parserTopologyComponent)
            .withMillisecondsBetweenAttempts(5000)
            .withCustomShutdownOrder(new String[]{"org/apache/storm","config","kafka","zk"})
            .withNumRetries(10)
            .build();
    try {
      runner.start();
      kafkaComponent.writeMessages(sensorType, inputMessages);
      ProcessorResult<List<LookupKV<EnrichmentKey, EnrichmentValue>>> result =
              runner.process(new Processor<List<LookupKV<EnrichmentKey, EnrichmentValue>>>() {
                List<LookupKV<EnrichmentKey, EnrichmentValue>> messages = null;

                @Override
                public ReadinessState process(ComponentRunner runner) {
                  MockHTable table = (MockHTable) MockHBaseTableProvider.getFromCache(sensorType);
                  if (table != null && table.size() == inputMessages.size()) {
                    EnrichmentConverter converter = new EnrichmentConverter();
                    messages = new ArrayList<>();
                    try {
                      for (Result r : table.getScanner(Bytes.toBytes("cf"))) {
                        messages.add(converter.fromResult(r, "cf"));
                      }
                    } catch (IOException e) {
                    }
                    return ReadinessState.READY;
                  }
                  return ReadinessState.NOT_READY;
                }

                @Override
                public ProcessorResult<List<LookupKV<EnrichmentKey, EnrichmentValue>>> getResult() {
                  ProcessorResult.Builder<List<LookupKV<EnrichmentKey,EnrichmentValue>>> builder = new ProcessorResult.Builder();
                  return builder.withResult(messages).build();
                }
              });
      Set<String> validIndicators = new HashSet<>(ImmutableList.of("col12", "col22", "col32"));
      Map<String, Map<String, String>> validMetadata = new HashMap<String, Map<String, String>>() {{
        put("col12", new HashMap<String, String>() {{
          put("col1", "col11");
          put("col3", "col13");
        }});
        put("col22", new HashMap<String, String>() {{
          put("col1", "col21");
          put("col3", "col23");
        }});
        put("col32", new HashMap<String, String>() {{
          put("col1", "col31");
          put("col3", "col33");
        }});
      }};
      for (LookupKV<EnrichmentKey, EnrichmentValue> kv : result.getResult()) {
        assertTrue(validIndicators.contains(kv.getKey().indicator));
        assertEquals(kv.getValue().getMetadata().get("source.type"), "dummy");
        assertNotNull(kv.getValue().getMetadata().get("timestamp"));
        assertNotNull(kv.getValue().getMetadata().get("original_string"));
        Map<String, String> metadata = validMetadata.get(kv.getKey().indicator);
        for (Map.Entry<String, String> x : metadata.entrySet()) {
          assertEquals(kv.getValue().getMetadata().get(x.getKey()), x.getValue());
        }
        assertEquals(metadata.size() + 4, kv.getValue().getMetadata().size());
      }
    }
    finally {
      if(runner != null) {
        runner.stop();
      }
    }
  }
}


text:
# Entity toolbox

### Summary
This module allows to easily create and manage entity types.

### Requirements
* entity
* views
* views_ui
* ctools
* entityreference
* inline_entity_form
* entity_operations

### Installation
Install as usual, see http://drupal.org/node/895232 for further information.

### Configuration
##### Settings
The settings are available at "admin/config/entity_toolbox/settings".

Available settings are :

* Cache enabled
* AJAX enabled
* Notifications enabled

### Basics
##### Entity groups
Entity groups are containers for several types of related entities.
To declare a new group, implement hook_entity_group_info().
##### Entities
To declare a new entity type, use hook_entity_toolbox_info().
###### Properties
###### Entity operations

### Usage
##### Creating entity group and entity modules.

1. Create a container module :
    * example_module.info
    * example_module.module
    * example_module.info.inc
    * example_module.functions.inc
    * /src
        * /classes
            * /controllers
                * ExampleGroupController.inc
            * /groups
                * ExampleGroup.inc
2. Within the same module, add a directory named "entities" and create a module for each entity type you wish to add :
    * /entities
        * /foo
            * foo.info
            * foo.install
            * foo.module
            * foo.info.inc
            * foo.functions.inc
            * /src
                * /classes
                    * /controllers
                        * FooController.inc
                        * FooTypeController.inc
                    * /entities
                        * Foo.inc
                        * FooType.inc
                * /templates
                    foo.tpl.php

##### Implementing the hooks
###### .info.inc file
If the module manages an entity group, implement the following.

```
/**
 * Implements hook_entity_group_info().
 */
function entity_toolbox_example_entity_group_info() {
  $info            = array();
  $info['example'] = array(
    'label'       => t('Example'),
    'description' => t('Example entities.'),
    'path'        => 'admin/example',
    'classes'     => array(
      'group'      => 'ExampleGroup',
      'controller' => 'ExampleGroupController'
    ),
  );

  return $info;
}
```
If the module manages an entity type, implement the following.
```
/**
 * Implements hook_entity_toolbox_info().
 */
function foo_entity_toolbox_info() {
  $info             = array();
  $info['foo']      = array(
    'fieldable' => TRUE,
    'group'     => 'example',
  );
  $info['foo_type'] = array(
    'fieldable' => FALSE,
    'group'     => 'example',
  );

  return $info;
}
```
###### .module file
```
/**
 * Implements hook_menu().
 */
function foo_menu() {
  $items = array();
  $items += menu_build('foo');

  return $items;
}

/**
 * Implements hook_entity_info().
 */
function foo_entity_info() {
  $info = array();

  $info += entity_info_retrieve('foo');
  $info += entity_info_retrieve('foo_type');

  return $info;
}

/**
 * Implements hook_entity_property_info().
 */
function foo_entity_property_info() {
  $info = array();
  $info += entity_property_info_build('foo');
  $info += entity_property_info_build('foo_type');

  return $info;
}

/**
 * Implements hook_entity_operation_info().
 */
function foo_entity_operation_info() {
  $info = array();
  $info += entity_operation_info_build('foo');
  $info += entity_operation_info_build('foo_type');

  return $info;
}

/**
 * Implements hook_permission().
 */
function foo_permission() {
  $permissions = array();
  $permissions += permissions_build('foo');
  $permissions += permissions_build('foo_type');

  return $permissions;
}

/**
 * Implements hook_theme().
 */
function foo_theme($existing, $type, $theme, $path) {
  $themes = array();
  $themes += theme_build('foo');

  return $themes;
}
```
###### .install file
```
/**
 * Implements hook_schema().
 */
function foo_schema() {
  $schema = array();
  $schema += schema_build('foo');
  $schema += schema_build('foo_type');

  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function foo_uninstall() {
  entity_toolbox_uninstall('foo');
}
```
###### TODO

- [ ]


text: alert('It woooooooorks');


text:
from __future__ import division

try:
    import cPickle as pickle
except ImportError:
    import pickle

import io
import os
import random
from collections import Counter, defaultdict

from model.base.document import Document

def save_to_disk(path_to_disk, obj, overwrite=False):
    """ Pickle an object to disk """
    dirname = os.path.dirname(path_to_disk)
    if not os.path.exists(dirname):
        raise ValueError("Path " + dirname + " does not exist")

    if not overwrite and os.path.exists(path_to_disk):
        raise ValueError("File " + path_to_disk + "already exists")

    pickle.dump(obj, open(path_to_disk, 'wb'))

def load_from_disk(path_to_disk):
    """ Load a pickle from disk to memory """
    if not os.path.exists(path_to_disk):
        raise ValueError("File " + path_to_disk + " does not exist")

    return pickle.load(open(path_to_disk, 'rb'))

def get_documents(data_dir, as_generator=True, shuffle=False):
    """
    Extract documents from *.txt files in a given directory
    :param data_dir: path to the directory with .txt files
    :param as_generator: flag whether to return a document generator or a list
    :param shuffle: flag whether to return the documents
    in a shuffled vs sorted order

    :return: generator or a list of Document objects
    """
    files = list({filename[:-4] for filename in os.listdir(data_dir) if '.DS_S' not in filename})
    files.sort()
    if shuffle:
        random.shuffle(files)

    generator = (Document(doc_id, os.path.join(data_dir, f + '.txt'))
                 for doc_id, f in enumerate(files))
    return generator if as_generator else list(generator)

def get_all_answers(data_dir, filtered_by=None):
    """
    Extract ground truth answers from *.lab files in a given directory
    :param data_dir: path to the directory with .lab files
    :param filtered_by: whether to filter the answers.

    :return: dictionary of the form e.g. {'101231': set('lab1', 'lab2') etc.}
    """
    answers = dict()

    files = {filename[:-4] for filename in os.listdir(data_dir)}
    for f in files:
        answers[f] = get_answers_for_doc(f + '.txt',
                                         data_dir,
                                         filtered_by=filtered_by)

    return answers

def get_answers_for_doc(doc_name, data_dir, filtered_by=None):
    """
    Read ground_truth answers from a .lab file corresponding to the doc_name
    :param doc_name: the name of the document, should end with .txt
    :param data_dir: directory in which the documents and answer files are
    :param filtered_by: whether to filter the answers.

    :return: set of unicodes containing answers for this particular document
    """
    filename = os.path.join(data_dir, doc_name[:-4] + '.lab')

    if not os.path.exists(filename):
        raise ValueError("Answer file " + filename + " does not exist")

    with io.open(filename, 'r') as f:
        answers = {line.rstrip('\n') for line in f}

    if filtered_by:
        answers = {kw for kw in answers if kw in filtered_by}

    return answers

def calculate_label_distribution(data_dir, filtered_by=None):
    """
    Calculate the distribution of labels in a directory. Function can be used
    to find the most frequent and not used labels, so that the target
    vocabulary can be trimmed accordingly.
    :param data_dir: directory path with the .lab files
    :param filtered_by: a set of labels that defines the vocabulary

    :return: list of KV pairs of the form (14, ['lab1', 'lab2']), which means
             that both lab1 and lab2 were labels in 14 documents
    """
    answers = [kw for v in get_all_answers(data_dir, filtered_by=filtered_by).values()
               for kw in v]
    counts = Counter(answers)

    histogram = defaultdict(list)
    for kw, cnt in counts.items():
        histogram[cnt].append(kw)

    return histogram

def calculate_number_of_labels_distribution(data_dir, filtered_by=None):
    """ Look how many papers are there with 3 labels, 4 labels etc.
     Return a histogram. """
    answers = get_all_answers(data_dir, filtered_by=filtered_by).values()
    lengths = [len(ans_set) for ans_set in answers]
    return Counter(lengths).items()

def get_coverage_ratio_for_label_subset(no_of_labels, hist=None):
    """
    Compute fraction of the samples we would be able to predict, if we reduce
    the number of labels to a certain subset of the size no_of_labels.
    :param no_of_labels: the number of labels that we limit the ontology to
    :param hist: histogram of the samples.
                 Result of calculate_label_distribution function

    :return: number of labels that we need to consider, coverage ratio
    """
    hist = hist or calculate_label_distribution()
    hist = sorted([(k, len(v)) for k, v in hist.items()])

    total_shots = sum([x[0] * x[1] for x in hist])
    labels_collected = 0
    hits_collected = 0
    for papers, labs in reversed(hist):
        hits_collected += papers * labs
        labels_collected += labs
        if labels_collected >= no_of_keywords:
            return labels_collected, hits_collected / float(total_shots)

    return -1

def get_top_n_labels(n, hist=None):
    """
    Return the n most popular labels
    :param n: number of labels to return
    :param hist: histogram, result of calculate_label_distribution() function

    :return: sorted list of strings
    """
    hist = hist or calculate_label_distribution()
    labels = sorted([(k, v) for k, v in hist.items()], reverse=True)

    answer = []
    for _count, kws in labels:
        answer.extend(kws)
        if len(answer) >= n:
            break

    return answer[:n]


text:
#pragma once
#include <aws/cur/CostandUsageReportService_EXPORTS.h>

namespace Aws
{
template<typename RESULT_TYPE>
class AmazonWebServiceResult;

namespace Utils
{
namespace Json
{
  class JsonValue;
} // namespace Json
} // namespace Utils
namespace CostandUsageReportService
{
namespace Model
{
  class AWS_COSTANDUSAGEREPORTSERVICE_API ModifyReportDefinitionResult
  {
  public:
    ModifyReportDefinitionResult();
    ModifyReportDefinitionResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
    ModifyReportDefinitionResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);

  };

} // namespace Model
} // namespace CostandUsageReportService
} // namespace Aws


text:
package com.qingbo.ginkgo.ygb.account.repository;

import java.util.List;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import com.qingbo.ginkgo.ygb.account.entity.SubQddAccount;

public class SubQDDAccountRepositoryTester extends BaseRepositoryTester {
	@Autowired private SubQddAccountRepository subQDDAccountRepository;

	@Test
	public void findAll() {
		List<SubQddAccount> list = subQDDAccountRepository.findAll();
		printList(list);
	}
}


text:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Dennis Bartlett</title>
    <link>https://dcbartlett.github.io/</link>
    <description>Recent content on Dennis Bartlett</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 13 Mar 2017 00:00:00 -0600</lastBuildDate>
    <atom:link href="https://dcbartlett.github.io/index.xml" rel="self" type="application/rss+xml" />

    <item>
      <title>Mobile Apps in just an hour.</title>
      <link>https://dcbartlett.github.io/post/mobile-apps-in-one-hour/</link>
      <pubDate>Mon, 13 Mar 2017 00:00:00 -0600</pubDate>

      <guid>https://dcbartlett.github.io/post/mobile-apps-in-one-hour/</guid>
      <description></description>
    </item>

    <item>
      <title>Welcome to the internet</title>
      <link>https://dcbartlett.github.io/post/welcome-to-the-internet/</link>
      <pubDate>Sat, 11 Mar 2017 00:00:00 -0600</pubDate>

      <guid>https://dcbartlett.github.io/post/welcome-to-the-internet/</guid>
      <description></description>
    </item>

  </channel>
</rss>


text:
//!
//! \file OrthancConnectionDialog.cpp
//! \brief The OrthancConnectionDialog.cpp file contains the definition of
//!        non-inline methods of the OrthancConnectionDialog class.
//!
//! \author Quentin Smetz
//!

#include "OrthancConnectionDialog.h"
#include "Model/ProgramConfiguration.h"
using namespace std;
using namespace customwidget;

// Constructor
OrthancConnectionDialog::OrthancConnectionDialog(QWidget* parent)
    : OkCancelDialog(parent), m_orthanc(0)
{
    setModal(true);
    setWindowTitle("Connexion");

    // Create the interface
    QFormLayout* formLayout = new QFormLayout();

    m_hostLineEdit = new LineEdit(QString(ProgramConfiguration::instance()->defaultHost().c_str()));
    formLayout->addRow("Hôte", m_hostLineEdit);

    m_portSpinBox = new SpinBox();
    m_portSpinBox->setRange(1, 65535);
    m_portSpinBox->setValue(ProgramConfiguration::instance()->defaultPort());
    formLayout->addRow("Port", m_portSpinBox);

    m_userLineEdit = new LineEdit("");
    formLayout->addRow("Utilisateur", m_userLineEdit);

    m_passLineEdit = new LineEdit("");
    formLayout->addRow("Mot de passe", m_passLineEdit);

    setLayout(formLayout);
}

// Destructor
OrthancConnectionDialog::~OrthancConnectionDialog()
{
    if(m_orthanc != 0)
        delete m_orthanc;
}

// The 'accept' slot
void OrthancConnectionDialog::accept()
{
    if(m_orthanc != 0)
        delete m_orthanc;

    setEnabled(false);

    try
    {
        m_orthanc = new OrthancClient::OrthancConnection(computeUrl().toStdString(),
                                                         m_userLineEdit->text().toStdString(),
                                                         m_passLineEdit->text().toStdString());
    }
    catch(OrthancClient::OrthancClientException& e)
    {
        cout << e.What() << endl;
    }

    OkCancelDialog::accept();
}

// The 'computeUrl' method
QString OrthancConnectionDialog::computeUrl() const
{
    QString url("");
    url += m_hostLineEdit->text();
    url += ":";
    url += QString::number(m_portSpinBox->value());

    return url;
}


text:
package com.github.pwittchen.networkevents.library.receiver;

import android.content.Context;
import android.content.Intent;

import com.github.pwittchen.networkevents.library.ConnectivityStatus;
import com.github.pwittchen.networkevents.library.NetworkEventsConfig;
import com.squareup.otto.Bus;

public final class InternetConnectionChangeReceiver extends BaseBroadcastReceiver {

    public InternetConnectionChangeReceiver(Bus bus) {
        super(bus);
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(NetworkEventsConfig.INTENT)) {
            boolean connectedToInternet = intent.getBooleanExtra(NetworkEventsConfig.INTENT_EXTRA, false);
            onPostReceive(connectedToInternet);
        }
    }

    public void onPostReceive(boolean connectedToInternet) {
        ConnectivityStatus connectivityStatus
                = (connectedToInternet)
                ? ConnectivityStatus.WIFI_CONNECTED_HAS_INTERNET
                : ConnectivityStatus.WIFI_CONNECTED_HAS_NO_INTERNET;

        if (statusNotChanged(connectivityStatus)) {
            return;
        }

        postConnectivityChanged(connectivityStatus);
    }
}


text:
import React from 'react';
import styled, { withTheme } from 'styled-components';
import PropTypes from 'prop-types';
import withStyle from './Base';
import { transparentize } from 'polished';

const StyledTextarea = styled.textarea`
  border: none;
  border-bottom: 2px solid
    ${props =>
      transparentize(
        props.error || props.hint ? 0.8 : 0.5,
        props.indicatorColor
      )};
  width: 100%;
  resize: none;

  &:focus {
    outline: none;
    border-bottom: 2px solid ${props => props.indicatorColor};
  }
`;

const Textarea = ({ error, hint, ...props }) => {
  let indicatorColor = props.indicatorColor;
  if (error) {
    indicatorColor = props.theme.colors.error;
  } else if (hint) {
    indicatorColor = props.theme.colors.warning;
  }
  return <StyledTextarea {...props} indicatorColor={indicatorColor} />;
};

Textarea.propTypes = {
  indicatorColor: PropTypes.string,
  error: PropTypes.bool,
  errorText: PropTypes.string,
  hint: PropTypes.bool,
  hintText: PropTypes.string
};

Textarea.defaultProps = {
  indicatorColor: 'lightgrey'
};

export default withTheme(withStyle(Textarea));