text:
- fixed bug that was preventing learning of index predicates in Dedupe mode

# 2.0.3
- Improved memory performance of connected components

# 2.0

- Python 3 only
- Static typing and type Hints
- Incorporate sqlite to extend normal API to millions of records
- Multiprocessing enabled for Windows
- Multiprocessing mode changed to spawn for Mac OS X
- Moved from CamelCase to lowercase_with_underscore for method names.
- Dropped ability to save indices in save settings.
- Moved from Deduper.match -> Dedupe.partition, RecordLink.match -> RecordLink.join, Gazetteer.match -> Gazetteer.search
- Renamed Matching.blocker -> Matching.fingerprinter
- Moved to autodoc for documentation
- Dropped threshold methods
- matchBlocks has been replaced by score, which takes pairs of records not blocks

# 1.10.0
- Dropped python 2.7 support

# 1.9.4
- Cleaned up block learning

# 1.9.3
- Improved performance of connected components algorithm with very large components
- Fixed pickling unpickling bug of Index predicate classes

# 1.9.0
- Implemented a disagreement based active labeler to improve blocking recall

# 1.8.2
- removed shelve-backed persistence in blocking data in favor of an improved in-memory implementation

# 1.8.0
- matchBlocks is not a generator; match is now optionally a generator. If the
  generator option is turned of for the Gazette match is lazy

# 1.7.8
- Speed up blocking, on our way to 3-predicates

# 1.7.5
- Significantly reduced memory footprint during connected_components

# 1.7.3
- Significantly reduced memory footprint during scoreDuplicates

# 1.7.2
- Improper release

# 1.7.1
- TempShelve class that addresses various bugs related to cleaning up tempoary shelves

# 1.7.0
- Added `target` argument to blocker and predicates for changing the behavior
  of the predicates for the target and source dataset if we are linking.

# 1.6.8
- Use file-backed blocking with dbm, dramatically increases size of data that can be handled without special programming

# 1.6.7
- Reduce memory footprint of matching

# 1.6.0
- Simplify .train method

# 1.5.5
- Levenshtein search based index predicates thanks to @mattandahalfew

# 1.5.0
- simplified the sample API, this might be a breaking change for some
- the active learner interface is now more modular to allow for a different learner
- random sampling of pairs has been improved for linking case and
  dedupe case, h/t to @MarkusShepherd

## 1.4.15
- frozendicts have finally been removed
- first N char predicates return their entire length if length is less
  than N, instead of nothing
- crossvalidation is skipped in active learning if using default rlr learner

## 1.4.5
- Block indexes can now be persisted by using the index=True argument
  in the writeSettings method

## 1.4.1
- Now uses C version of double metaphone for speed
- Much faster compounding of blocks in block learning

## 1.4.0
- Block learning now tries to minimize the total number of comparisons
  not just the comparisons of distinct records. This decouples makes
  block learning from learning classifier learning. This change has
  requires new, different arguments to the train method.

## 1.3.8
- Console labeler now shows fields in the order they are defined in
  the data model. The labeler also reports number of labeled examples
- `pud` argument added to the `train` method. Proportion of uncovered
  dupes. This deprecates `uncovered_dupes` argument

## 1.3.0
- If we have enough training data, consider Compound predicates of length 3 in addition to predicates of length 2

## 1.1.1
- None now treated as missing data indicator. Warnings for deprecations of older types of missing data indicators

## 1.1.0
Features
- Handle FuzzyCategoricalType in datamodel

## 1.0.0
Features
- Speed up learning
- Parallelize sampling
- Optional [CRF Edit Distance](https://dedupe.readthedocs.io/en/latest/Variable-definition.html#optional-edit-distance)

## 0.8.0
Support for Python 3.4 added. Support for Python 2.6 dropped.

Features
- Windows OS supported
- train method has argument for not considering index predicates
- TfIDFNGram Index Predicate added (for shorter string)
- SuffixArray Predicate
- Double Metaphone Predicates
- Predicates for numbers, OrderOfMagnitude, Round
- Set Predicate OrderOfCardinality
- Final, learned predicates list will now often be smaller without
  loss of coverage
- Variables refactored to support external extensions like
  https://github.com/datamade/dedupe-variable-address
- Categorical distance, regularized logistic regression, affine gap
  distance, canonicalization have been turned into separate libraries.
- Simplejson is now dependency

## 0.7.5
Features
- Individual record cluster membership scores
- New predicates
- New Exists Variable Type

Bug Fixes
- Latlong predicate fixed
- Set TFIDF canopy working properly

## 0.7.4
Features
- Sampling methods now use blocked sampling

## 0.7.0
Version 0.7.0 is backwards compatible, except for the match method of Gazetteer class

Features
- new index, unindex, and match methods in Gazetter Matching. Useful for
  streaming matching

## 0.6.0
Version 0.6.0 is *not* backwards compatible.

Features :
- new Text, ShortString, and exact string types
- multiple variables can be defined on same field
- new Gazette linker for matching dirty records against a master list
- performance improvements, particularly in memory usage
- canonicalize function in dedupe.convenience for creating a canonical representation of a cluster of records
- tons of bugfixes

API breaks
- when initializing an ActiveMatching object, `variable_definition` replaces `field_definition` and is a list of    dictionaries instead of a dictionary. See the documentation for details
- also when initializing a Matching object, `num_processes` has been replaced by `num_cores`, which now defaults to the
number of cpus on the machine
- when initializing a StaticMatching object, `settings_file` is now expected to be a file object not a string. The `readTraining`, `writeTraining`, `writeSettings` methods also all now expect file objects

## 0.5
Version 0.5 is *not* backwards compatible.

Features :

- Special case code for linking two datasets that, individually are unique
- Parallel processing using python standard library multiprocessing
- Much faster canopy creation using zope.index
- Asynchronous active learning methods

API breaks :
- `duplicateClusters` has been removed, it has been replaced by
  `match` and `matchBlocks`
- `goodThreshold` has been removed, it has been replaced by
  `threshold` and `thresholdBlocks`
- the meaning of `train` has changed. To train from training file use `readTraining`. To use console labeling, pass a dedupe instance to the `consoleLabel` function
- The convenience function dataSample has been removed. It has been replaced by
the `sample` methods
- It is no longer necessary to pass `frozendicts` to `Matching` classes
- `blockingFunction` has been removed and been replaced by the `blocker` method


text:
* Treat everyone with dignity and respect.
* No harassment.
* Gracefully accept criticism.
* No sex.
* No politics.
* No trolling.

Report unacceptable behavior to tonygermaneri@gmail.com.

redpajama_set_name: RedPajamaGithub


text:
'use strict';

var async = require('async');
var User = require('./models/User');
var Post = require('./models/Post');

module.exports = {
    createUsers: function() {
            var raw = [{
                firstName: "John",
                lastName: "Snow",
                email: "John@example.com"
            }, {
                firstName: "Jack",
                lastName: "In The Box",
                email: "Jack@another.com"
            }];
            var users = [];
            for (var i = 0; i < raw.length; i++) {
                var user = new User(raw[i]);
                user.save();
                users.push(user);
            }
            new Post({
                title: "A Blog Post!",
                author: {
                    firstName: 'John'
                }
            }).save()
            return users;
        },
    init: function() {
        this.createUsers();
    },
    destroy: function(done) {
        // mongoose creates a database when a connection is made
        // it is unclear how to 'abort' if database already exists
        // this is a dirty check to make sure developer has not already
        // made other collections in the database before we destroy it
        var db = User.db;
        if (Object.keys(db.collections).length > 2) {
            console.warn("Other collections exist in " + db.name + "!");
            return done
        };
        db.db.dropDatabase(function(err, result) {
            if (err) console.dir(err);
            console.log("Removing database.")
            return done();
        });
    }
}


text:
#include "RaceTags.h"

#include "ActionLog.h"
#include "EventGraph.h"
#include "CallTraceBuilder.h"
#include "StringSet.h"
#include "strutil.h"

#include <string.h>
#include <stdlib.h>

RaceTags::RaceTags(
		const VarsInfo& races,
		const ActionLog& log,
		const StringSet& vars,
		const StringSet& scopes,
		const StringSet& mem_values,
		const CallTraceBuilder& event_cause)
	: m_races(races),
	  m_log(log),
	  m_vars(vars),
	  m_scopes(scopes),
	  m_memValues(mem_values),
	  m_eventCause(event_cause),
	  m_initialized(false) {
}

RaceTags::~RaceTags() {
}

RaceTags::RaceTagSet RaceTags::emptyTagSet() {
	return 0;
}

RaceTags::RaceTagSet RaceTags::addTag(RaceTagSet tags, RaceTag tag) {
	return tags | (1ll << tag);
}

RaceTags::RaceTagSet RaceTags::removeTag(RaceTagSet tags, RaceTag tag) {
	return tags & (~(1ll << tag));
}

RaceTags::RaceTagSet RaceTags::mergeTags(RaceTagSet tags1, RaceTagSet tags2) {
	return tags1 | tags2;
}

bool RaceTags::hasTag(RaceTagSet tags, RaceTag tag) {
	return (tags & (1ll << tag)) != 0;
}

const char* RaceTags::tagName(RaceTag tag) {
	switch (tag) {
	case WRITE_SAME_VALUE: return "WRITE_SAME_VALUE";
	case ONLY_LOCAL_WRITE: return "ONLY_LOCAL_WRITE";
	case NO_EVENT_ATTACHED: return "NO_EVENT_ATTACHED";
	case LATE_EVENT_ATTACH: return "LATE_EVENT_ATTACH";
	case MAYBE_LAZY_INIT: return "MAYBE_LAZY_INIT";
	case RACE_WITH_UNLOAD: return "RACE_WITH_UNLOAD";
	case COOKIE_OR_CLASSNAME: return "COOKIE_OR_CLASSNAME";
	default: return "Unknown tag";
	}
}

std::string RaceTags::tagsToString(RaceTagSet tags) {
	std::string r;
	for (int t = 0; t < static_cast<int>(NUM_RACE_TAGS); ++t) {
		if (hasTag(tags, static_cast<RaceTag>(t))) {
			if (!r.empty()) r += " ";
			r += tagName(static_cast<RaceTag>(t));
		}
	}
	return r;
}

RaceTags::RaceTagSet RaceTags::getVariableTags(int var_id) const {
	RaceTags::RaceTagSet result = emptyTagSet();
	VarsInfo::AllVarData::const_iterator it = m_races.variables().find(var_id);
	if (it == m_races.variables().end()) return result;
	const VarsInfo::VarData& var = it->second;
	if (isOnlyLocalWrites(var) && !varIsUserVisible(var_id)) {
		result = addTag(result, ONLY_LOCAL_WRITE);
	}
	if (hasOnlySameValueWrites(var)) {
		result = addTag(result, WRITE_SAME_VALUE);
	}
	result = mergeTags(result, getEventRaceClasses(var));
	if (isLazyInit(var)) {
		result = addTag(result, MAYBE_LAZY_INIT);
	}
	if (hasOnlyUnloadRaces(var)) {
		result = addTag(result, RACE_WITH_UNLOAD);
	}
/*	if (isCounterVar(var)) {
		result = addTag(result, COUNTER);
	}*/
	if (isCookie(var_id)) {
		result = addTag(result, COOKIE_OR_CLASSNAME);
	}
	if (isClassName(var_id)) {
		result = addTag(result, COOKIE_OR_CLASSNAME);
	}
	return result;
}

bool RaceTags::hasUndefinedInitilizationRace(int var_id) const {
	VarsInfo::AllVarData::const_iterator it = m_races.variables().find(var_id);
	if (it == m_races.variables().end()) return false;
	const VarsInfo::VarData& var = it->second;
	if (var.numWrites() > 0) {
		int write_op = var.getWriteWithIndex(0)->m_eventActionId;
		for (size_t i = 0; i < var.m_accesses.size(); ++i) {
			if (!var.m_accesses[i].m_isRead) continue;
			int read_op = var.m_accesses[i].m_eventActionId;
			if (read_op < write_op) return false;
			std::vector<int> tmp;
			if (!isValueTypeReadOrNull(read_op, var.m_accesses[i].m_commandIdInEvent) &&
				!m_races.hasPathViaRaces(write_op, read_op, var.m_accesses[i].m_commandIdInEvent, &tmp)) {
				bool result = true;
				for (size_t j = 0; j < var.m_accesses.size(); ++j) {
					if (var.m_accesses[j].m_isRead) continue;
					if (m_races.hasPathViaRaces(var.m_accesses[j].m_eventActionId,
							read_op, var.m_accesses[i].m_commandIdInEvent, &tmp)) {
						result = false;
						break;
					}
				}
				if (result) return true;
			}
		}
	}
	return false;
}

bool RaceTags::hasNetworkResponseRace(int var_id, bool ww_race) const {
	VarsInfo::AllVarData::const_iterator it = m_races.variables().find(var_id);
	if (it == m_races.variables().end()) return false;
	const VarsInfo::VarData& var = it->second;
	for (size_t i = 0; i < var.m_noParentRaces.size(); ++i) {
		if (isNetworkResponseRace(var.m_noParentRaces[i])) {
			const VarsInfo::Race_Info& race = m_races.races()[var.m_noParentRaces[i]];
			if (ww_race == false) {
				return true;
			} else if (race.m_access1 == VarsInfo::MEMORY_WRITE &&
					race.m_access2 == VarsInfo::MEMORY_WRITE) {
				const char* v1 = getValueOfReadOrWrite(race.m_event1, race.m_cmdInEvent1);
				const char* v2 = getValueOfReadOrWrite(race.m_event2, race.m_cmdInEvent2);
				return v1 == NULL || v1 != v2;
			}
		}
	}
	return false;
}

bool RaceTags::isNetworkResponseRace(int race_id) const {
	if (race_id < 0 || race_id >= static_cast<int>(m_races.races().size())) return false;
	const VarsInfo::Race_Info& race = m_races.races()[race_id];
	return isNetworkResponseOp(race.m_event1) || isNetworkResponseOp(race.m_event2);
}

std::string RaceTags::getVarDefSet(int var_id) const {
	VarsInfo::AllVarData::const_iterator it = m_races.variables().find(var_id);
	if (it == m_races.variables().end()) return "";
	const VarsInfo::VarData& var = it->second;

	std::set<std::string> def_set;
	for (size_t i = 0; i < var.m_accesses.size(); ++i) {
		const char* v = getValueOfReadOrWrite(var.m_accesses[i].m_eventActionId, var.m_accesses[i].m_commandIdInEvent);
		if (v != NULL) def_set.insert(v);
	}

	std::string result;
	for (std::set<std::string>::const_iterator it = def_set.begin(); it != def_set.end(); ++it) {
		if (!result.empty()) result += " ";
		result += *it;
	}
	return result;
}

RaceTags::RaceTagSet RaceTags::getEventRaceClasses(const VarsInfo::VarData& var) const {
	bool actual_race = false;
	std::set<int> race_reads;
	for (size_t i = 0; i < var.m_accesses.size(); ++i) {
		if (!var.m_accesses[i].m_isRead) continue;
		int num_reads_till_file = numReadCmdsUntilEventFire(var.m_accesses[i].m_eventActionId, var.m_accesses[i].m_commandIdInEvent);
		if (num_reads_till_file == -1) continue;
		if (num_reads_till_file == 0) actual_race = true;
		race_reads.insert(var.m_accesses[i].m_eventActionId);
	}
	if (race_reads.empty()) return emptyTagSet();  // Not an event variable.
	for (size_t i = 0; i < var.m_allRaces.size(); ++i) {
		const VarsInfo::Race_Info& race = m_races.races()[var.m_allRaces[i]];
		// Unload races should not matter for events.
		if (isUnloadOp(race.m_event1) || isUnloadOp(race.m_event2)) continue;
		// Only if a race does not involve event invocation, do not return an event race tag.
		if (race_reads.count(race.m_event1) == 0 && race_reads.count(race.m_event2) == 0) return emptyTagSet();
	}
	return addTag(emptyTagSet(), actual_race ? RaceTags::LATE_EVENT_ATTACH : RaceTags::NO_EVENT_ATTACHED);
}

bool RaceTags::hasOnlySameValueWrites(const VarsInfo::VarData& var) const {
	int write_value = -1;
	for (size_t i = 0; i < var.m_accesses.size(); ++i) {
		if (var.m_accesses[i].m_isRead) continue;
		const ActionLog::EventAction& op = m_log.event_action(var.m_accesses[i].m_eventActionId);
		int cmd_id = var.m_accesses[i].m_commandIdInEvent;
		if (cmd_id + 1 < static_cast<int>(op.m_commands.size()) &&
			op.m_commands[cmd_id + 1].m_cmdType == ActionLog::MEMORY_VALUE) {
			int new_value = op.m_commands[cmd_id + 1].m_location;
			if (write_value == -1) write_value = new_value;
			if (write_value == new_value) continue;
		}
		return false;
	}
	// TODO(veselin): Fix this to be more accurate.
	for (size_t i = 0; i < var.m_allRaces.size(); ++i) {
		const VarsInfo::Race_Info& race = m_races.races()[var.m_allRaces[i]];
		if (race.m_access1 != VarsInfo::MEMORY_WRITE ||
			race.m_access2 != VarsInfo::MEMORY_WRITE)
			return false;
	}
	return true;
}

bool RaceTags::isOnlyLocalWrites(const VarsInfo::VarData& var) const {
	for (size_t i = 0; i < var.m_noParentRaces.size(); ++i) {
		const VarsInfo::Race_Info& race = m_races.races()[var.m_noParentRaces[i]];
		if (race.m_access1 != VarsInfo::MEMORY_WRITE ||
			race.m_access2 != VarsInfo::MEMORY_WRITE ||
			hasReadInOpAfter(var, race.m_event1) ||
			hasReadInOpAfter(var, race.m_event2)) {
			return false;
		}
	}
	return true;
}

bool RaceTags::hasReadInOpAfter(const VarsInfo::VarData& var, int op_id) const {
	for (size_t i = 0; i < var.m_accesses.size(); ++i) {
		if (var.m_accesses[i].m_eventActionId > op_id) {
			return var.m_accesses[i].m_isRead;
		}
	}
	return false;
}

int RaceTags::numReadCmdsUntilEventFire(int op_id, int cmd_id) const {
	const ActionLog::EventAction& op = m_log.event_action(op_id);
	int num_reads = 0;
	for (size_t i = cmd_id + 1; i < op.m_commands.size(); ++i) {
		const ActionLog::Command& cmd = op.m_commands[i];
		if (cmd.m_cmdType == ActionLog::ENTER_SCOPE &&
				strncmp(m_scopes.getString(cmd.m_location), "fire:", 5) == 0) {
			return num_reads;
		} else if (cmd.m_cmdType == ActionLog::READ_MEMORY) {
			++num_reads;
		} else {
			break;
		}
	}
	return -1;
}

bool RaceTags::isLazyInit(const VarsInfo::VarData& var) const {
	if (var.numWrites() == 1 && var.numReads() > 0) {
		if (var.getWriteWithIndex(0)->m_eventActionId == var.getReadWithIndex(0)->m_eventActionId &&
			var.getWriteWithIndex(0)->m_commandIdInEvent > var.getReadWithIndex(0)->m_commandIdInEvent) {
/*			// TODO: Check that it starts from NULL or undefined.
            const ActionLog::Operation& op = m_log.operation(var.m_reads[0].m_operationId);
			int cmd_id = var.m_reads[0].m_commandIdInOp;
			if (cmd_id + 1 < op.m_commands.size() &&
					op.m_commands[cmd_id + 1].m_cmdType == ActionLog::MEMORY_VALUE &&
					op.m_commands[cmd_id + 1].m_location) {

			}
*/
			return true;
		}
	}
	return false;
}

bool RaceTags::hasOnlyUnloadRaces(const VarsInfo::VarData& var) const {
	if (var.m_noParentRaces.size() == 0) return false;
	for (size_t i = 0; i < var.m_noParentRaces.size(); ++i) {
		const VarsInfo::Race_Info& race = m_races.races()[var.m_noParentRaces[i]];
		if (isUnloadOp(race.m_event1) == false && isUnloadOp(race.m_event2) == false) return false;
	}
	return true;
}

bool RaceTags::isUnloadOp(int op_id) const {
	const ActionLog::EventAction& op = m_log.event_action(op_id);
	for (size_t i = 0; i < op.m_commands.size(); ++i) {
		const ActionLog::Command& cmd = op.m_commands[i];
		if (cmd.m_cmdType == ActionLog::ENTER_SCOPE) {
			const char* location = m_scopes.getString(cmd.m_location);
			return strncmp(location, "fire:unload", 10) == 0 ||
					strcmp(location, "delete_document") == 0;
		}
	}
	return false;
}

bool RaceTags::isNetworkResponseOp(int op_id) const {
	const ActionLog::EventAction& op = m_log.event_action(op_id);
	for (size_t i = 0; i < op.m_commands.size() && i < 32; ++i) {
		const ActionLog::Command& cmd = op.m_commands[i];
		if (cmd.m_cmdType == ActionLog::ENTER_SCOPE) {
			const char* location = m_scopes.getString(cmd.m_location);
			return strncmp(location, "fire:readystatechange", 21) == 0;
		}
	}
	return false;
}

bool RaceTags::isCounterVar(const VarsInfo::VarData& var) const {
	if (var.m_allRaces.size() == 0) return false;
	if (var.numWrites() == 0) return false;
	for (size_t i = 0; i < var.m_allRaces.size(); ++i) {
		const VarsInfo::Race_Info& race = m_races.races()[var.m_allRaces[i]];
		if (race.m_access1 == VarsInfo::MEMORY_WRITE ||
			race.m_access2 == VarsInfo::MEMORY_WRITE) return false;
		if (race.m_access1 == VarsInfo::MEMORY_UPDATE &&
				!isCounterIncrementOrDecrementUpdate(var, race.m_event1)) return false;
		if (race.m_access2 == VarsInfo::MEMORY_UPDATE &&
				!isCounterIncrementOrDecrementUpdate(var, race.m_event2)) return false;
	}

	// Make sure it decrements to 0 in the end, since we have seen counters that only
	// increase.
	const VarsInfo::VarAccess* last_write = var.getWriteWithIndex(var.numWrites() - 1);
	const char* last_value = getValueOfReadOrWrite(
			last_write->m_eventActionId, last_write->m_commandIdInEvent);
	return last_value != NULL && strcmp(last_value, "0") == 0;
}

bool RaceTags::isCounterIncrementOrDecrementUpdate(const VarsInfo::VarData& var, int op_id) const {
	int read_cmd = VarsInfo::getCommandIdForVarReadInEventAction(var, op_id);
	int write_cmd = VarsInfo::getCommandIdForVarWriteInEventAction(var, op_id);
	if (read_cmd == -1 || write_cmd == -1) return false;
	if (read_cmd > write_cmd) return false;
	// Parse the read value.
	const char* read_value = getValueOfReadOrWrite(op_id, read_cmd);
	if (read_value == NULL) return false;
	int read_int;
	if (!ParseInt32(read_value, &read_int)) return false;
	// Parse the written value.
	const char* write_value = getValueOfReadOrWrite(op_id, write_cmd);
	if (write_value == NULL) return false;
	int write_int;
	if (!ParseInt32(write_value, &write_int)) return false;
	return abs(read_int - write_int) == 1;
}

bool RaceTags::isValueTypeReadOrNull(int op_id, int cmd_id) const {
	const char* read_value = getValueOfReadOrWrite(op_id, cmd_id);
	if (read_value == NULL) return false;
	int read_int;
	if (ParseInt32(read_value, &read_int)) return true;
	return (strcmp(read_value, "undefined") == 0 ||
			strcmp(read_value, "NULL") == 0 ||
			strcmp(read_value, "true") == 0 ||
			strcmp(read_value, "false") == 0);
}

bool RaceTags::isCookie(int var_id) const {
	const char* name = m_vars.getString(var_id);
	if (name == NULL) return false;
	return strstr(name, ".cookie") != NULL;
}

bool RaceTags::isClassName(int var_id) const {
	const char* name = m_vars.getString(var_id);
	if (name == NULL) return false;
	return strstr(name, ".className") != NULL;
}

const char* RaceTags::getValueOfReadOrWrite(int op_id, int cmd_id) const {
	const ActionLog::EventAction& op = m_log.event_action(op_id);
	if (cmd_id + 1 >= static_cast<int>(op.m_commands.size())) return NULL;
	const ActionLog::Command& cmd = op.m_commands[cmd_id + 1];
	if (cmd.m_cmdType != ActionLog::MEMORY_VALUE) return NULL;
	return m_memValues.getString(cmd.m_location);
}

double RaceTags::getExceptionCorruptionRiskRank(const VarsInfo::VarData& var) const {
	double result = 0.0;
	for (size_t i = 0; i < var.m_allRaces.size(); ++i) {
		const VarsInfo::Race_Info& race = m_races.races()[var.m_allRaces[i]];
		if (race.m_coveredBy != -1) continue;
		if (race.m_access1 != VarsInfo::MEMORY_WRITE) {
			result += numWritesBeforeCommand(race.m_event1, race.m_cmdInEvent1);
		}
		if (race.m_access2 != VarsInfo::MEMORY_WRITE) {
			result += numWritesBeforeCommand(race.m_event2, race.m_cmdInEvent2);
		}
	}
	return result;
}

int RaceTags::numWritesBeforeCommand(int op_id, int cmd_id) const {
	const ActionLog::EventAction& op = m_log.event_action(op_id);
	int cmd_count = cmd_id;
	if (cmd_count > static_cast<int>(op.m_commands.size())) { cmd_count = op.m_commands.size(); }
	int write_count = 0;
	for (int i = 0; i < cmd_count; ++i) {
		if (op.m_commands[i].m_cmdType == ActionLog::WRITE_MEMORY) ++write_count;
	}
	return write_count;
}

bool RaceTags::varIsUserVisible(int var_id) const {
	std::string name = m_vars.getString(var_id);
	std::string::size_type p1 = name.find("[0x");
	std::string::size_type p2 = name.find("].");
	if (p1 == std::string::npos || p2 == std::string::npos) return false;
	const std::string class_name(name.begin(), name.begin() + p1);
	const std::string field_name(name.begin() + p2 + 2, name.end());
	if (class_name == "DOMNode") {
		return field_name == "innerHTML" ||
				field_name == "id" ||
				field_name == "className" ||
				field_name == "style" ||
				field_name == "dir" ||
				field_name == "accesskey" ||
				// img
				field_name == "src" ||
				field_name == "alt" ||
				field_name == "ismap" ||
				field_name == "usemap" ||
				// a
				field_name == "href" ||
				// iframe
				field_name == "seamless" ||
				field_name == "srcdoc" ||
				field_name == "width" ||
				field_name == "height" ||
				field_name == "sandbox" ||
				// textarea
				field_name == "readonly" ||
				field_name == "disabled" ||
				// button
				field_name == "type" ||
				field_name == "value";
	}
	return false;
}

bool RaceTags::varHasNonObviousRaces(const VarsInfo::VarData& var) const {
	for (size_t i = 0; i < var.m_allRaces.size(); ++i) {
		const VarsInfo::Race_Info& race = m_races.races()[var.m_allRaces[i]];
		if (m_eventCause.eventCreatedBy(race.m_event1) == race.m_event1 &&
			m_eventCause.eventCreatedBy(race.m_event2) == race.m_event2) {
			return true;
		}
	}
	return false;
}


text:
SMSServer - SMPP gateway

This interface is used for SMPP gateways. Currently SMPP is supported through JSMPP only.

Configuration File

This interface requires the following settings in SMSServer's configuration file:

Option	Description

impl	Full class name of SMPP gateway that extends AbstractSMPPGateway.

host	SMPP host.

port	SMPP port.

systemid	SMPP system Id.

password	SMPP Password.

systemtype	SMPP system type.

bindtype	SMPP bind type r Receiver, t Transmitter, tr Transceiver.

The following settings are optional:

Option	Description

bindton	Bind Address Type Of Number.

bindnpi	Bind Address Numbering Plan Indicator.

sourceton	Source Address Type Of Number.

sourcenpi	Source Address Numbering Plan Indicator.

destton	Destination Address Type Of Number.

destnpi	Destination Address Numbering Plan Indicator.

enquirelink	Interval time in milliseconds to check SMPP connection.

Example:

gateway.0=mysmpp, SMPPGateway

mysmpp.impl=org.smslib.smpp.jsmpp.JSMPPGateway

mysmpp.host=localhost

mysmpp.port=2715

mysmpp.systemid=smppclient1

mysmpp.password=password

mysmpp.systemtype=smpp

mysmpp.bindtype=tr

mysmpp.bindton=0

mysmpp.bindnpi=0

mysmpp.sourceton=0

mysmpp.sourcenpi=0

mysmpp.destton=0

mysmpp.destnpi=0

mysmpp.enquirelink=5000

Possible Type Of Number values

Value	Description

0	Unknown

1	International

2	National

3	Network Specific

4	Subscriber Number

5	Alphanumeric

6	Abbreviated

Possible Numbering Plan Indicator values

Value	Description

0	Unknown

1	ISDN

2	Data

3	Telex

6	Land Mobile

8	National

9	Private

10	ERMES

13	Internet

18	WAP


text:
# Threads
adepted from:
https://www.olcf.ornl.gov/support/system-user-guides/accelerated-computing-guide/#2661

http://cuda-programming.blogspot.co.il/2013/01/vector-addition-in-cuda-cuda-cc-program.html

CUDA threads are logically divided into 1,2, or 3 dimensional groups referred to as thread blocks.
Threads within a block can cooperate though access to low latency shared memory as well as synchronization capabilities.
All threads in a block must reside on the same streaming multiprocessor and share the limited resources, additionally a 1024
threads per block upper limit is imposed.

The thread blocks of a given kernel are partitioned into a 1,2, or 3 dimensional logical grouping referred to as a grid.
The grid encompasses all threads required to execute a given kernel. There is no cooperation between blocks in a grid,
as such blocks must be able to be executed independently. When a kernel is launched the number of threads per threadblock
and the number of threadblocks is specified, this in turn defines the total number of cuda threads launched.

Each thread has access to it's integer position within it's own block as well as the integer position of the thread's
enclosing block within the grid, as displayed below. In general the thread uses this position information to read/write
to/from device global memory. In this fashion although each thread is executing the same kernel code each thread has it's
own data to operate on.

(from stack overflow)
# Calculations
#### Hardware
If a GPU device has, for example, 4 multiprocessing units, and they can run 768 threads each: then at a given moment no more than 4*768 threads will be really running in parallel (if you planned more threads, they will be waiting their turn).

#### Software

threads are organized in blocks. A block is executed by a multiprocessing unit. The threads of a block can be indentified (indexed) using 1Dimension(x), 2Dimensions (x,y) or 3Dim indexes (x,y,z) but in any case xyz <= 768 for our example (other restrictions apply to x,y,z, see the guide and your device capability).

Obviously, if you need more than those 4*768 threads you need more than 4 blocks. Blocks may be also indexed 1D, 2D or 3D. There is a queue of blocks waiting to enter the GPU (because, in our example, the GPU has 4 multiprocessors and only 4 blocks are being executed simultaneously).

#### Now a simple case: processing a 512x512 image

Suppose we want one thread to process one pixel (i,j).

We can use blocks of 64 threads each. Then we need 512*512/64 = 4096 blocks (so to have 512x512 threads = 4096*64)

It's common to organize (to make indexing the image easier) the threads in 2D blocks having blockDim = 8 x 8 (the 64 threads per block). I prefer to call it threadsPerBlock.

dim3 threadsPerBlock(8, 8);  // 64 threads
and 2D gridDim = 64 x 64 blocks (the 4096 blocks needed). I prefer to call it numBlocks.

dim3 numBlocks(imageWidth/threadsPerBlock.x,  /* for instance 512/8 = 64*/
              imageHeight/threadsPerBlock.y);
The kernel is launched like this:

myKernel <<<numBlocks,threadsPerBlock>>>( /* params for the kernel function */ );
Finally: there will be something like "a queue of 4096 blocks", where a block is waiting to be assigned one of the multiprocessors of the GPU to get its 64 threads executed.

In the kernel the pixel (i,j) to be processed by a thread is calculated this way:

uint i = (blockIdx.x * blockDim.x) + threadIdx.x;
uint j = (blockIdx.y * blockDim.y) + threadIdx.y;

http://on-demand.gputechconf.com/gtc-express/2011/presentations/StreamsAndConcurrencyWebinar.pdf


text:
from __future__ import print_function
import os
import sys
import ssl
import yaml
import operator
from datetime import datetime
from glob import glob
from getpass import getpass
import numpy as np
import ocw.utils as utils
import ocw.dataset_processor as dsp
from ocw.dataset import Bounds
from ocw.dataset_loader import DatasetLoader
from metrics_and_plots import *

def load_datasets_from_config(extra_opts, *loader_opts):
    '''
    Generic dataset loading function.
    '''
    for opt in loader_opts:
        loader_name = opt['loader_name']
        if loader_name == 'esgf':
            if extra_opts['password'] is None:
                extra_opts['username'] = raw_input('Enter your ESGF OpenID:\n')
                extra_opts['password'] = getpass(
                                        prompt='Enter your ESGF password:\n')

            opt['esgf_username'] = extra_opts['username']
            opt['esgf_password'] = extra_opts['password']
        elif loader_name == 'rcmed':
            opt['min_lat'] = extra_opts['min_lat']
            opt['max_lat'] = extra_opts['max_lat']
            opt['min_lon'] = extra_opts['min_lon']
            opt['max_lon'] = extra_opts['max_lon']
            opt['start_time'] = extra_opts['start_time']
            opt['end_time'] = extra_opts['end_time']

    loader = DatasetLoader(*loader_opts)
    loader.load_datasets()
    return loader.datasets

if hasattr(ssl, '_create_unverified_context'):
    ssl._create_default_https_context = ssl._create_unverified_context

config_file = str(sys.argv[1])

print('Reading the configuration file {}'.format(config_file))
config = yaml.load(open(config_file))
time_info = config['time']
temporal_resolution = time_info['temporal_resolution']

# Read time info
start_time = datetime.strptime(time_info['start_time'].strftime('%Y%m%d'),'%Y%m%d')
end_time = datetime.strptime(time_info['end_time'].strftime('%Y%m%d'),'%Y%m%d')

# Read space info
space_info = config['space']
if not 'boundary_type' in space_info:
    min_lat = space_info['min_lat']
    max_lat = space_info['max_lat']
    min_lon = space_info['min_lon']
    max_lon = space_info['max_lon']
else:
    min_lat, max_lat, min_lon, max_lon = utils.CORDEX_boundary(space_info['boundary_type'][6:].replace(" ","").lower())

# Additional arguments for the DatasetLoader
extra_opts = {'min_lat': min_lat, 'max_lat': max_lat, 'min_lon': min_lon,
              'max_lon': max_lon, 'start_time': start_time,
              'end_time': end_time, 'username': None, 'password': None}

# Get the dataset loader options
data_info = config['datasets']

# Extract info we don't want to put into the loader config
# Multiplying Factor to scale obs by. Currently only supported for reference
# (first) dataset. We should instead make this a parameter for each
# loader and Dataset objects.
fact = data_info[0].pop('multiplying_factor', 1)

""" Step 1: Load the datasets """
print('Loading datasets:\n{}'.format(data_info))
datasets = load_datasets_from_config(extra_opts, *data_info)
multiplying_factor = np.ones(len(datasets))
multiplying_factor[0] = fact
names = [dataset.name for dataset in datasets]
for i, dataset in enumerate(datasets):
    if temporal_resolution == 'daily' or temporal_resolution == 'monthly':
        datasets[i] = dsp.normalize_dataset_datetimes(dataset,
                                                      temporal_resolution)
        if multiplying_factor[i] != 1:
            datasets[i].values *= multiplying_factor[i]

""" Step 2: Subset the data for temporal and spatial domain """
# Create a Bounds object to use for subsetting
if time_info['maximum_overlap_period']:
    start_time, end_time = utils.get_temporal_overlap(datasets)
    print('Maximum overlap period')
    print('start_time: {}'.format(start_time))
    print('end_time: {}'.format(end_time))

if temporal_resolution == 'monthly' and end_time.day !=1:
    end_time = end_time.replace(day=1)

for i, dataset in enumerate(datasets):
    min_lat = np.max([min_lat, dataset.lats.min()])
    max_lat = np.min([max_lat, dataset.lats.max()])
    min_lon = np.max([min_lon, dataset.lons.min()])
    max_lon = np.min([max_lon, dataset.lons.max()])

if not 'boundary_type' in space_info:
    bounds = Bounds(lat_min=min_lat,
                    lat_max=max_lat,
                    lon_min=min_lon,
                    lon_max=max_lon,
                    start=start_time,
                    end=end_time)
else:
    bounds = Bounds(boundary_type=space_info['boundary_type'],
                    start=start_time,
                    end=end_time)

for i, dataset in enumerate(datasets):
    datasets[i] = dsp.subset(dataset, bounds)
    if dataset.temporal_resolution() != temporal_resolution:
        datasets[i] = dsp.temporal_rebin(dataset, temporal_resolution)

# Temporally subset both observation and model datasets
# for the user specified season
month_start = time_info['month_start']
month_end = time_info['month_end']
average_each_year = time_info['average_each_year']

# For now we will treat the first listed dataset as the reference dataset for
# evaluation purposes.
for i, dataset in enumerate(datasets):
    datasets[i] = dsp.temporal_subset(dataset, month_start, month_end,
                                      average_each_year)

reference_dataset = datasets[0]
target_datasets = datasets[1:]
reference_name = names[0]
target_names = names[1:]

# generate grid points for regridding
if config['regrid']['regrid_on_reference']:
    new_lat = reference_dataset.lats
    new_lon = reference_dataset.lons
else:
    delta_lat = config['regrid']['regrid_dlat']
    delta_lon = config['regrid']['regrid_dlon']
    nlat = (max_lat - min_lat)/delta_lat+1
    nlon = (max_lon - min_lon)/delta_lon+1
    new_lat = np.linspace(min_lat, max_lat, nlat)
    new_lon = np.linspace(min_lon, max_lon, nlon)

# Get flag for boundary checking for regridding. By default, this is set to True
# since the main intent of this program is to evaluate RCMs. However, it can be
# used for GCMs in which case it should be set to False to save time.
boundary_check = config['regrid'].get('boundary_check', True)

# number of target datasets (usually models, but can also be obs / reanalysis)
ntarget = len(target_datasets)
print('Dataset loading completed')
print('Reference data: {}'.format(reference_name))
print('Number of target datasets: {}'.format(ntarget))
for target_name in target_names:
    print(target_name)

""" Step 3: Spatial regriding of the datasets """
print('Regridding datasets: {}'.format(config['regrid']))
if not config['regrid']['regrid_on_reference']:
    reference_dataset = dsp.spatial_regrid(reference_dataset, new_lat, new_lon)
    print('Reference dataset has been regridded')
for i, dataset in enumerate(target_datasets):
    target_datasets[i] = dsp.spatial_regrid(dataset, new_lat, new_lon,
                                           boundary_check=boundary_check)
    print('{} has been regridded'.format(target_names[i]))
print('Propagating missing data information')
datasets = dsp.mask_missing_data([reference_dataset]+target_datasets)
reference_dataset = datasets[0]
target_datasets = datasets[1:]

""" Step 4: Checking and converting variable units """
print('Checking and converting variable units')
reference_dataset = dsp.variable_unit_conversion(reference_dataset)
for i, dataset in enumerate(target_datasets):
    target_datasets[i] = dsp.variable_unit_conversion(dataset)

print('Generating multi-model ensemble')
if len(target_datasets) >= 2.:
    target_datasets.append(dsp.ensemble(target_datasets))
    target_names.append('ENS')

""" Step 5: Generate subregion average and standard deviation """
if config['use_subregions']:
    # sort the subregion by region names and make a list
    subregions= sorted(config['subregions'].items(),key=operator.itemgetter(0))

    # number of subregions
    nsubregion = len(subregions)

    print('Calculating spatial averages and standard deviations of {} subregions'
          .format(nsubregion))

    reference_subregion_mean, reference_subregion_std, subregion_array = (
        utils.calc_subregion_area_mean_and_std([reference_dataset], subregions))
    target_subregion_mean, target_subregion_std, subregion_array = (
        utils.calc_subregion_area_mean_and_std(target_datasets, subregions))

""" Step 6: Write a netCDF file """
workdir = config['workdir']
if workdir[-1] != '/':
    workdir = workdir+'/'
print('Writing a netcdf file: ',workdir+config['output_netcdf_filename'])
if not os.path.exists(workdir):
    os.system("mkdir -p "+workdir)

if config['use_subregions']:
    dsp.write_netcdf_multiple_datasets_with_subregions(
        reference_dataset, reference_name, target_datasets, target_names,
        path=workdir+config['output_netcdf_filename'],
        subregions=subregions, subregion_array=subregion_array,
        ref_subregion_mean=reference_subregion_mean,
        ref_subregion_std=reference_subregion_std,
        model_subregion_mean=target_subregion_mean,
        model_subregion_std=target_subregion_std)
else:
    dsp.write_netcdf_multiple_datasets_with_subregions(
                                reference_dataset, reference_name, target_datasets,
                                target_names,
                                path=workdir+config['output_netcdf_filename'])

""" Step 7: Calculate metrics and draw plots """
nmetrics = config['number_of_metrics_and_plots']
if config['use_subregions']:
    Map_plot_subregion(subregions, reference_dataset, workdir)

if nmetrics > 0:
    print('Calculating metrics and generating plots')
    for imetric in np.arange(nmetrics)+1:
        metrics_name = config['metrics'+'%1d' %imetric]
        plot_info = config['plots'+'%1d' %imetric]
        file_name = workdir+plot_info['file_name']

        print('metrics {0}/{1}: {2}'.format(imetric, nmetrics, metrics_name))
        if metrics_name == 'Map_plot_bias_of_multiyear_climatology':
            row, column = plot_info['subplots_array']
            if 'map_projection' in plot_info.keys():
                Map_plot_bias_of_multiyear_climatology(
                    reference_dataset, reference_name, target_datasets, target_names,
                    file_name, row, column,
                    map_projection=plot_info['map_projection'])
            else:
                Map_plot_bias_of_multiyear_climatology(
                    reference_dataset, reference_name, target_datasets, target_names,
                    file_name, row, column)
        elif metrics_name == 'Taylor_diagram_spatial_pattern_of_multiyear_climatology':
            Taylor_diagram_spatial_pattern_of_multiyear_climatology(
                reference_dataset, reference_name, target_datasets, target_names,
                file_name)
        elif config['use_subregions']:
            if (metrics_name == 'Timeseries_plot_subregion_interannual_variability'
                and average_each_year):
                row, column = plot_info['subplots_array']
                Time_series_subregion(
                    reference_subregion_mean, reference_name, target_subregion_mean,
                    target_names, False, file_name, row, column,
                    x_tick=['Y'+str(i+1)
                            for i in np.arange(target_subregion_mean.shape[1])])

            if (metrics_name == 'Timeseries_plot_subregion_annual_cycle'
                and not average_each_year and month_start==1 and month_end==12):
                row, column = plot_info['subplots_array']
                Time_series_subregion(
                    reference_subregion_mean, reference_name,
                    target_subregion_mean, target_names, True,
                    file_name, row, column,
                    x_tick=['J','F','M','A','M','J','J','A','S','O','N','D'])

            if (metrics_name == 'Portrait_diagram_subregion_interannual_variability'
                and average_each_year):
                Portrait_diagram_subregion(reference_subregion_mean, reference_name,
                                           target_subregion_mean, target_names,
                                           False, file_name)

            if (metrics_name == 'Portrait_diagram_subregion_annual_cycle'
                and not average_each_year and month_start==1 and month_end==12):
                Portrait_diagram_subregion(reference_subregion_mean, reference_name,
                                           target_subregion_mean, target_names,
                                           True, file_name)
        else:
            print('please check the currently supported metrics')


text:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import java.util.Scanner;

import org.omg.CORBA.portable.InputStream;
import org.wltea.analyzer.IKSegmentation;
import org.wltea.analyzer.Lexeme;
import org.wltea.analyzer.seg.CJKSegmenter;

import weibo4j.Status;
import weibo4j.User;
import weibo4j.Weibo;
import weibo4j.WeiboException;

public class mySQLite {

	private String DATABASE_CONNECTION;

	public mySQLite(String strDBConnection) {
		DATABASE_CONNECTION = strDBConnection;
	}

	public boolean insertParseText(String strFileName, String strTableName) {
		Connection conn = null;
		try {
			Class.forName("org.sqlite.JDBC");
		} catch (ClassNotFoundException e1) {
			e1.printStackTrace();
		}
		try {
			conn = DriverManager.getConnection(DATABASE_CONNECTION);
			// 建立事务机制,禁止自动提交,设置回滚点
			conn.setAutoCommit(false);

			Statement stat = conn.createStatement();
			Scanner scannerStatus = new Scanner(new File(strFileName));
			while (scannerStatus.hasNext()) {
				FileInputStream fileStream = null;
				fileStream = new FileInputStream(strFileName);
				Reader reader = new InputStreamReader(fileStream);
				IKSegmentation mySegment = new IKSegmentation(reader);
				try {
					Lexeme nextLexeme = mySegment.next();
					while (nextLexeme != null) {
						String strSeg = nextLexeme.getLexemeText();
						System.out.println(strSeg);
						ResultSet rs = stat.executeQuery("insert into "
								+ strTableName + " values ('" + strSeg + "');");
						conn.commit();
						nextLexeme = mySegment.next();
					}
				} catch (IOException e) {

					e.printStackTrace();
				}
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e1) {
			System.out.println("i'm in mySQLite and insertParseText");
			e1.printStackTrace();
		}finally{
			try {
				conn.close();
			} catch (SQLException e) {
				System.out.println("i'm in mySQLite and insertParseText");
				e.printStackTrace();
			}
		}

		return false;
	}

	/**
	 * 将用户信息插入数据库
	 *
	 * @param strInfo
	 *            数组,1:ID,2:Access Token,3:Access secret
	 * @return 成功插入,返回真,否则为假
	 */
	@SuppressWarnings("finally")
	public boolean insertUserInfo(String[] strInfo) {
		Connection conn = null;
		try {
			Class.forName("org.sqlite.JDBC");
			conn = DriverManager.getConnection(DATABASE_CONNECTION);
			// 建立事务机制,禁止自动提交,设置回滚点
			conn.setAutoCommit(false);

			Statement stat = conn.createStatement();
			ResultSet rs = stat
					.executeQuery("select * from userInfo where id = '"
							+ strInfo[0] + "';");
			String strSQLiteID = rs.getString("id");
			User userInfo = getUserInfo(strInfo);
			// String strUserInfo=userInfo.toString();
			// strUserInfo=strUserInfo.substring(5,strUserInfo.length()-1);

			if (strSQLiteID == null)// 如果该id还不存在于数据库中,将其插入
			{
				stat.executeUpdate("insert into userInfo(id,screenName,access_token,access_secret) values ('"
						+ strInfo[0]
						+ "','"
						+ userInfo.getScreenName()
						+ "','"
						+ strInfo[1] + "','" + strInfo[2] + "');");
				conn.commit();
			}

			// //以下一共替换了三个字符串,一是日期,一是id,一是false,给这三者都加上了引号,这样,
			// //执行插入操作时就不会报错了。这两个正则式匹配了日期及id
			String regEx = "createdAt=(.*),\\W?fa";
			String regEx2 = "id=(\\d+)";

			String strUserInfo = userInfo.toString().replaceAll(regEx,
					"createdAt='$1',fa");
			strUserInfo = strUserInfo.substring(5, strUserInfo.length() - 1);
			strUserInfo = strUserInfo.replaceAll(regEx2, "id='$1'");
			strUserInfo = strUserInfo.replaceAll("false", "'false'");
			String strExecute = "update userInfo set " + strUserInfo
					+ " where id = '" + strInfo[0] + "';";
			stat.executeUpdate(strExecute);
			conn.commit();
			rs.close();
			stat.close();
		} catch (SQLException e) {
			e.printStackTrace();
			System.out.println("i'm in mySQLite and inseruserinfo");
			return false;
		} finally {
			try {
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
			return true;
		}
	}

	public boolean insertStatus(List<Status> listStatus) {
		Connection conn = null;
		try {
			Class.forName("org.sqlite.JDBC");
			conn = DriverManager.getConnection(DATABASE_CONNECTION);
			// 建立事务机制,禁止自动提交,设置回滚点
			conn.setAutoCommit(false);

			Statement stat = conn.createStatement();
			for (int i = 0; i < listStatus.size(); i++) {
				String strStatusID = String.valueOf(listStatus.get(i).getId());
				String strStatusInfo = listStatus.get(0).toString();
				ResultSet rs3 = stat.executeQuery("select * from statusInfo where id = '"
						+ strStatusID + "';");
				String strSQLiteID = rs3.getString("id");

				if (strSQLiteID == null)// 如果该id还不存在于数据库中,将其插入
				{
					 stat.executeUpdate("insert into userInfo(id) values ('"
					 + strStatusID + "');");
					 conn.commit();
				}

				// //以下一共替换了三个字符串,一是日期,一是id,一是false,给这三者都加上了引号,这样,
				// //执行插入操作时就不会报错了。这两个正则式匹配了日期及id
				String regEx = "createdAt=(.*),\\W?fa";
				String regEx2 = "id=(\\d+)";

				String strUserInfo = strStatusInfo.toString().replaceAll(regEx,
						"createdAt='$1',fa");
				strUserInfo = strUserInfo
						.substring(5, strUserInfo.length() - 1);
				strUserInfo = strUserInfo.replaceAll(regEx2, "id='$1'");
				strUserInfo = strUserInfo.replaceAll("false", "'false'");
				String strExecute = "update userInfo set " + strUserInfo
						+ " where id = '" + strStatusID + "';";
				// stat.executeUpdate(strExecute);
				rs3.close();
				conn.commit();
			}
			stat.close();
		} catch (SQLException e) {
			e.printStackTrace();
			System.out.println("i'm in mySQLite and insertstatus");
			return false;
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} finally {
			try {
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return true;
	}

	/**
	 * this function create two Table,1.userInfo 2.statusInfo
	 */
	private void testSQLite() {
		Connection conn=null;
		try {
			Class.forName("org.sqlite.JDBC");

			conn = DriverManager.getConnection(DATABASE_CONNECTION);
			// 建立事务机制,禁止自动提交,设置回滚点
			conn.setAutoCommit(false);

			Statement stat = conn.createStatement();
			// User{weibo=null, id=2438418282, name='心情慵懒',
			// screenName='心情慵懒', location='甘肃 陇南', description='',
			// profileImageUrl='http://tp3.sinaimg.cn/2438418282/50/5612515360/1',
			// province='62', city='26', domain ='', gender ='m',
			// url='',
			// allowAllActMsg=false,
			// followersCount=1,
			// friendsCount=40, createdAt=Sun Oct 02 00:00:00 CST 2011,
			// favouritesCount=0, following=false, statusesCount=0,
			// geoEnabled=false,
			// voiderified=false,
			// status=null}

			stat.executeUpdate("create table userInfo ("
					+ "id PRIMARY KEY NOT NULL,"// 用户UID",主键
					+ "screenName,"// 微博昵称
					+ "name,"// 友好显示名称,同微博昵称
					+ "province,"// 省份编码(参考省份编码表)
					+ "city,"// 城市编码(参考城市编码表)
					+ "location,"// 地址
					+ "description,"// 个人描述
					+ "url,"// 用户博客地址
					+ "profileImageUrl,"// 自定义图像
					+ "domain,"// 用户个性化URL
					+ "gender,"// 性别,m--男,f--女,n--未知
					+ "followersCount,"// 粉丝数
					+ "friendsCount,"// 关注数
					+ "statusesCount,"// 微博数
					+ "favouritesCount,"// 收藏数
					+ "createdAt,"// 创建时间
					+ "following,"// 是否已关注(此特性暂不支持)
					+ "verified,"// 加V标示,是否微博认证用户
					+ "status,"// 状态,由取回的字符中提取,意义不明
					+ "geoEnabled,"// 地理状态信息
					+ "allowAllActMsg,"// 由取回的字符中提取,意义不明
					+ "weibo,"// 由取回的字符中提取,意义不明
					+ "access_token,"// 访问Token
					+ "access_secret)");// 访问密钥

			// [createdAt=Sat Oct 01 23:51:54 CST 2011,
			// id=3363835379243442, text=养生之道,首在养气。,
			// source=新浪免费邮箱,
			// isTruncated=false, inReplyToStatusId=-1, inReplyToUserId=-1,
			// isFavorited=false, inReplyToScreenName=,
			// latitude=-1.0,
			// longitude=-1.0,
			// thumbnail_pic=, bmiddle_pic=,
			// original_pic=,
			// mid=3363835379243442,
			// user=null,
			// retweeted_status=null]}

			stat.executeUpdate("create table statusInfo (" + "created_at,"// 创建时间
					+ "id PRIMARY KEY NOT NULL,"// 微博ID,主键
					+ "text,"// 微博信息内容
					+ "source,"// 微博来源
					+ "favorited,"// 是否已收藏
					+ "truncated,"// 是否被截断
					+ "in_reply_to_status_id,"// 回复ID
					+ "in_reply_to_user_id,"// 回复人UID
					+ "in_reply_to_screen_name,"// 回复人昵称
					+ "thumbnail_pic,"// 缩略图
					+ "bmiddle_pic,"// 中型图片
					+ "original_pic,"// 原始图片
					+ "user,"// 作者信息
					+ "retweeted_status)");// 转发的博文,内容为status,如果不是转发,则没有此字段
			conn.commit();
			conn.close();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			System.out.println("create table error");
			e.printStackTrace();
		} finally {
			try {
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * 由数据库的表中取出一列数据
	 *
	 * @param strTable
	 *            表名称
	 * @param strColumn
	 *            列名称
	 * @return 数组,包含了该列数据
	 */
	public String[] getColumnDataFromDB(String strTable, String strColumn) {
		String[] strResult = null;
		Connection conn=null;
		try {
			Class.forName("org.sqlite.JDBC");
			conn = DriverManager.getConnection(DATABASE_CONNECTION);
			// 建立事务机制,禁止自动提交,设置回滚点
			conn.setAutoCommit(false);

			Statement stat = conn.createStatement();
			ResultSet rs = stat
					.executeQuery("SELECT COUNT(*) AS NumberOfUsers FROM "
							+ strTable + ";");
			String strNumber = rs.getString("NumberOfUsers").trim();
			if (strNumber == null || strNumber == "" || strNumber.equals("0"))
				return null;
			int nUser = Integer.parseInt(rs.getString("NumberOfUsers"));
			strResult = new String[nUser];
			ResultSet rs2 = stat.executeQuery("select " + strColumn + " from "
					+ strTable + ";");
			int i = 0;
			while (rs2.next()) {
				strResult[i] = rs2.getString(strColumn);
				i++;
			}
			rs.close();
			rs2.close();
			stat.close();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
			System.out.println("i'm in mySQLite and getColumnData");
		} finally {
			try {
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return strResult;
	}

	/**
	 * 由数据库的表中取出一row数据
	 *
	 * @param strTable
	 *            表名称
	 *  @param strElementName
	 *            name of Element which you want to compare
	 * @param strRowValue
	 *            Condation ,if ElementName == strRowValue
	 * @return 数组,包含了该row数据,0:id,1:name,2:token,3:secret
	 */
	public String[] getRowDataFromDB(String strTable,String strElementName,String strRowValue) {
		Connection conn=null;
		String strResult[]=new String[4];
		try {
			Class.forName("org.sqlite.JDBC");
			conn = DriverManager.getConnection(DATABASE_CONNECTION);
			// 建立事务机制,禁止自动提交,设置回滚点
			conn.setAutoCommit(false);

			Statement stat = conn.createStatement();
//			ResultSet rs = stat
//					.executeQuery("SELECT COUNT(*) AS NumberOfUsers FROM "
//							+ strTable + ";");
//			String strNumber = rs.getString("NumberOfUsers").trim();
//			if (strNumber == null || strNumber == "" || strNumber.equals("0"))
//				return null;
			String strQuery="select * from "
					+ strTable + " where "+strElementName +"='"+strRowValue.trim()+"';";
			ResultSet rs = stat.executeQuery(strQuery);
			if(rs.next()){
			strResult[0]=rs.getString("id");
			strResult[1]=rs.getString("name");
			strResult[2]=rs.getString("access_token");
			strResult[3]=rs.getString("access_secret");
			}
			stat.close();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
			System.out.println("i'm in mySQLite and getRowData");
		} finally {
			try {
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return strResult;
	}

	/**
	 * get user information
	 *
	 * @param strUserInfo
	 *            3 dim String ,1:user id 2:user token 3:user token secret.
	 * @return User ,includ all the information can get from weibo.com
	 */
	@SuppressWarnings("finally")
	public User getUserInfo(String[] strUserInfo) {
		Weibo weiboInfo = new Weibo();
		weiboInfo.setToken(strUserInfo[1], strUserInfo[2]);
		User user = null;
		try {
			user = weiboInfo.showUser(strUserInfo[0]);
			System.out.println("this user:" + user.toString());
		} catch (WeiboException e) {
			e.printStackTrace();
		} finally {
			return user;
		}
	}
}


text:
<!html>

    <title>{{ config.TITLE }}</title>
    <link type="text/css" rel="stylesheet" href="/status-static/main.css" />
    <link rel="alternate" type="application/rss+xml" title="{{ config.TITLE }} feed" href="/?format=rss" />

{{ config.TITLE }}

    {% block content %}
    {% if user %}
Create new message
{% endif %}
    {% for message in messages %}

{{ message.date.strftime("%Y.%m.%d %H:%M:%S") }} (UTC){% if user %} Edit{% endif %}

{{ message.content|safe }}

    {% endfor %}
    {% endblock %}
    {% if more and next_curs %}

>>

    {% endif %}


text:
import contextlib

import mock

from nova.cells import rpcapi as cells_rpcapi
from nova import db
from nova import exception
from nova import objects
from nova.objects import block_device as block_device_obj
from nova.tests.unit import fake_block_device
from nova.tests.unit import fake_instance
from nova.tests.unit.objects import test_objects

class _TestBlockDeviceMappingObject(object):
    def fake_bdm(self, instance=None):
        instance = instance or {}
        fake_bdm = fake_block_device.FakeDbBlockDeviceDict({
            'id': 123,
            'instance_uuid': instance.get('uuid') or 'fake-instance',
            'device_name': '/dev/sda2',
            'source_type': 'snapshot',
            'destination_type': 'volume',
            'connection_info': "{'fake': 'connection_info'}",
            'snapshot_id': 'fake-snapshot-id-1',
            'boot_index': -1
        })
        if instance:
            fake_bdm['instance'] = instance
        return fake_bdm

    def _test_save(self, cell_type=None):
        if cell_type:
            self.flags(enable=True, cell_type=cell_type, group='cells')
        else:
            self.flags(enable=False, group='cells')

        fake_bdm = self.fake_bdm()
        with contextlib.nested(
            mock.patch.object(
                db, 'block_device_mapping_update', return_value=fake_bdm),
            mock.patch.object(
                cells_rpcapi.CellsAPI, 'bdm_update_or_create_at_top')
        ) as (bdm_update_mock, cells_update_mock):
            bdm_object = objects.BlockDeviceMapping(context=self.context)
            bdm_object.id = 123
            bdm_object.volume_id = 'fake_volume_id'
            bdm_object.save()

            bdm_update_mock.assert_called_once_with(
                    self.context, 123, {'volume_id': 'fake_volume_id'},
                    legacy=False)
            if cell_type != 'compute':
                self.assertFalse(cells_update_mock.called)
            else:
                self.assertEqual(1, cells_update_mock.call_count)
                self.assertTrue(len(cells_update_mock.call_args[0]) > 1)
                self.assertIsInstance(cells_update_mock.call_args[0][1],
                                      block_device_obj.BlockDeviceMapping)
                self.assertEqual(cells_update_mock.call_args[1], {})

    def test_save_nocells(self):
        self._test_save()

    def test_save_apicell(self):
        self._test_save(cell_type='api')

    def test_save_computecell(self):
        self._test_save(cell_type='compute')

    def test_save_instance_changed(self):
        bdm_object = objects.BlockDeviceMapping()
        bdm_object.instance = objects.Instance()
        self.assertRaises(exception.ObjectActionError,
                          bdm_object.save, self.context)

    @mock.patch.object(db, 'block_device_mapping_get_by_volume_id')
    def test_get_by_volume_id(self, get_by_vol_id):
        get_by_vol_id.return_value = self.fake_bdm()

        vol_bdm = objects.BlockDeviceMapping.get_by_volume_id(
                self.context, 'fake-volume-id')
        for attr in block_device_obj.BLOCK_DEVICE_OPTIONAL_ATTRS:
            self.assertFalse(vol_bdm.obj_attr_is_set(attr))
        self.assertRemotes()

    @mock.patch.object(db, 'block_device_mapping_get_by_volume_id')
    def test_get_by_volume_id_not_found(self, get_by_vol_id):
        get_by_vol_id.return_value = None

        self.assertRaises(exception.VolumeBDMNotFound,
                          objects.BlockDeviceMapping.get_by_volume_id,
                          self.context, 'fake-volume-id')

    @mock.patch.object(db, 'block_device_mapping_get_by_volume_id')
    def test_get_by_volume_instance_uuid_missmatch(self, get_by_vol_id):
        fake_bdm_vol = self.fake_bdm(instance={'uuid': 'other-fake-instance'})
        get_by_vol_id.return_value = fake_bdm_vol

        self.assertRaises(exception.InvalidVolume,
                          objects.BlockDeviceMapping.get_by_volume_id,
                          self.context, 'fake-volume-id',
                          instance_uuid='fake-instance')

    @mock.patch.object(db, 'block_device_mapping_get_by_volume_id')
    def test_get_by_volume_id_with_expected(self, get_by_vol_id):
        get_by_vol_id.return_value = self.fake_bdm(
                fake_instance.fake_db_instance())

        vol_bdm = objects.BlockDeviceMapping.get_by_volume_id(
                self.context, 'fake-volume-id', expected_attrs=['instance'])
        for attr in block_device_obj.BLOCK_DEVICE_OPTIONAL_ATTRS:
            self.assertTrue(vol_bdm.obj_attr_is_set(attr))
        get_by_vol_id.assert_called_once_with(self.context, 'fake-volume-id',
                                              ['instance'])
        self.assertRemotes()

    def _test_create_mocked(self, cell_type=None):
        if cell_type:
            self.flags(enable=True, cell_type=cell_type, group='cells')
        else:
            self.flags(enable=False, group='cells')
        values = {'source_type': 'volume', 'volume_id': 'fake-vol-id',
                  'destination_type': 'volume',
                  'instance_uuid': 'fake-instance'}
        fake_bdm = fake_block_device.FakeDbBlockDeviceDict(values)

        with contextlib.nested(
            mock.patch.object(
                    db, 'block_device_mapping_create', return_value=fake_bdm),
            mock.patch.object(cells_rpcapi.CellsAPI,
                              'bdm_update_or_create_at_top')
        ) as (bdm_create_mock, cells_update_mock):
            bdm = objects.BlockDeviceMapping(context=self.context, **values)

            if cell_type == 'api':
                self.assertRaises(exception.ObjectActionError,
                                  bdm.create, self.context)
            elif cell_type == 'compute':
                bdm.create()
                bdm_create_mock.assert_called_once_with(
                    self.context, values, legacy=False)
                self.assertEqual(1, cells_update_mock.call_count)
                self.assertTrue(len(cells_update_mock.call_args[0]) > 1)
                self.assertIsInstance(cells_update_mock.call_args[0][1],
                                      block_device_obj.BlockDeviceMapping)
                self.assertEqual(cells_update_mock.call_args[1],
                                 {'create': True})
            else:
                bdm.create()
                self.assertFalse(cells_update_mock.called)
                bdm_create_mock.assert_called_once_with(
                    self.context, values, legacy=False)

    def test_create_nocells(self):
        self._test_create_mocked()

    def test_create_apicell(self):
        self._test_create_mocked(cell_type='api')

    def test_create_computecell(self):
        self._test_create_mocked(cell_type='compute')

    def test_create(self):
        values = {'source_type': 'volume', 'volume_id': 'fake-vol-id',
                  'destination_type': 'volume',
                  'instance_uuid': 'fake-instance'}
        bdm = objects.BlockDeviceMapping(context=self.context, **values)
        with mock.patch.object(cells_rpcapi.CellsAPI,
                               'bdm_update_or_create_at_top'):
            bdm.create()

        for k, v in values.iteritems():
            self.assertEqual(v, getattr(bdm, k))

    def test_create_fails(self):
        values = {'source_type': 'volume', 'volume_id': 'fake-vol-id',
                  'destination_type': 'volume',
                  'instance_uuid': 'fake-instance'}
        bdm = objects.BlockDeviceMapping(context=self.context, **values)
        bdm.create()

        self.assertRaises(exception.ObjectActionError,
                          bdm.create, self.context)

    def test_create_fails_instance(self):
        values = {'source_type': 'volume', 'volume_id': 'fake-vol-id',
                  'destination_type': 'volume',
                  'instance_uuid': 'fake-instance',
                  'instance': objects.Instance()}
        bdm = objects.BlockDeviceMapping(**values)
        self.assertRaises(exception.ObjectActionError,
                          bdm.create, self.context)

    def _test_destroy_mocked(self, cell_type=None):
        values = {'source_type': 'volume', 'volume_id': 'fake-vol-id',
                  'destination_type': 'volume', 'id': 1,
                  'instance_uuid': 'fake-instance', 'device_name': 'fake'}
        if cell_type:
            self.flags(enable=True, cell_type=cell_type, group='cells')
        else:
            self.flags(enable=False, group='cells')
        with contextlib.nested(
            mock.patch.object(db, 'block_device_mapping_destroy'),
            mock.patch.object(cells_rpcapi.CellsAPI, 'bdm_destroy_at_top')
        ) as (bdm_del, cells_destroy):
            bdm = objects.BlockDeviceMapping(context=self.context, **values)
            bdm.destroy()
            bdm_del.assert_called_once_with(self.context, values['id'])
            if cell_type != 'compute':
                self.assertFalse(cells_destroy.called)
            else:
                cells_destroy.assert_called_once_with(
                    self.context, values['instance_uuid'],
                    device_name=values['device_name'],
                    volume_id=values['volume_id'])

    def test_destroy_nocells(self):
        self._test_destroy_mocked()

    def test_destroy_apicell(self):
        self._test_destroy_mocked(cell_type='api')

    def test_destroy_computecell(self):
        self._test_destroy_mocked(cell_type='compute')

class TestBlockDeviceMappingObject(test_objects._LocalTest,
                                   _TestBlockDeviceMappingObject):
    pass

class TestRemoteBlockDeviceMappingObject(test_objects._RemoteTest,
                                         _TestBlockDeviceMappingObject):
    pass

class _TestBlockDeviceMappingListObject(object):
    def fake_bdm(self, bdm_id):
        fake_bdm = fake_block_device.FakeDbBlockDeviceDict({
            'id': bdm_id, 'instance_uuid': 'fake-instance',
            'device_name': '/dev/sda2',
            'source_type': 'snapshot',
            'destination_type': 'volume',
            'connection_info': "{'fake': 'connection_info'}",
            'snapshot_id': 'fake-snapshot-id-1',
            'boot_index': -1,
        })
        return fake_bdm

    @mock.patch.object(db, 'block_device_mapping_get_all_by_instance')
    def test_get_by_instance_uuid(self, get_all_by_inst):
        fakes = [self.fake_bdm(123), self.fake_bdm(456)]
        get_all_by_inst.return_value = fakes
        bdm_list = (
                objects.BlockDeviceMappingList.get_by_instance_uuid(
                    self.context, 'fake_instance_uuid'))
        for faked, got in zip(fakes, bdm_list):
            self.assertIsInstance(got, objects.BlockDeviceMapping)
            self.assertEqual(faked['id'], got.id)

    @mock.patch.object(db, 'block_device_mapping_get_all_by_instance')
    def test_get_by_instance_uuid_no_result(self, get_all_by_inst):
        get_all_by_inst.return_value = None
        bdm_list = (
                objects.BlockDeviceMappingList.get_by_instance_uuid(
                    self.context, 'fake_instance_uuid'))
        self.assertEqual(0, len(bdm_list))

    def test_root_volume_metadata(self):
        fake_volume = {
                'volume_image_metadata': {'vol_test_key': 'vol_test_value'}}

        class FakeVolumeApi(object):
            def get(*args, **kwargs):
                return fake_volume

        block_device_mapping = block_device_obj.block_device_make_list(None, [
            fake_block_device.FakeDbBlockDeviceDict(
                {'id': 1,
                 'boot_index': 0,
                 'source_type': 'volume',
                 'destination_type': 'volume',
                 'volume_id': 'fake_volume_id',
                 'delete_on_termination': False})])

        volume_meta = block_device_mapping.root_metadata(
            self.context, None, FakeVolumeApi())
        self.assertEqual(fake_volume['volume_image_metadata'], volume_meta)

    def test_root_image_metadata(self):
        fake_image = {'properties': {'img_test_key': 'img_test_value'}}

        class FakeImageApi(object):
            def show(*args, **kwargs):
                return fake_image

        block_device_mapping = block_device_obj.block_device_make_list(None, [
            fake_block_device.FakeDbBlockDeviceDict(
                {'id': 1,
                 'boot_index': 0,
                 'source_type': 'image',
                 'destination_type': 'local',
                 'image_id': "fake-image",
                 'delete_on_termination': True})])

        image_meta = block_device_mapping.root_metadata(
            self.context, FakeImageApi(), None)
        self.assertEqual(fake_image['properties'], image_meta)

class TestBlockDeviceMappingListObject(test_objects._LocalTest,
                                       _TestBlockDeviceMappingListObject):
    pass

class TestRemoteBlockDeviceMappingListObject(
        test_objects._RemoteTest, _TestBlockDeviceMappingListObject):
    pass


text:
<?php
/**
 * Created by PhpStorm.
 * User: Alexey
 * Date: 03.02.2016
 * Time: 15:43
 */
namespace Jungle\FileSystem\Adapter {

	/**
	 * Class Local
	 * @package Jungle\FileSystem\Adapter
	 */
	abstract class Local extends Adapter{

		/**
		 * @param $path
		 * @return int
		 */
		public function filesize($path){
			return filesize($this->absolute($path, true));
		}

		/**
		 * @param $path
		 * @return float
		 */
		public function disk_total_space($path){
			return disk_total_space($this->absolute($path, true));
		}

		/**
		 * @param $path
		 * @return float
		 */
		public function disk_free_space($path){
			return disk_free_space($this->absolute($path, true));
		}

		/**
		 * @param string $path
		 * @return bool
		 */
		public function is_link($path){
			return is_link($this->absolute($path, true));
		}

		/**
		 * @param string $path
		 * @return bool
		 */
		public function is_dir($path){
			return is_dir($this->absolute($path, true));
		}

		/**
		 * @param string $path
		 * @return bool
		 */
		public function is_file($path){
			return is_file($this->absolute($path, true));
		}

		/**
		 * @param string $path
		 * @return bool
		 */
		public function is_readable($path){
			return is_readable($this->absolute($path, true));
		}

		/**
		 * @param string $path
		 * @return bool
		 */
		public function is_writable($path){
			return is_writable($this->absolute($path, true));
		}

		/**
		 * @param string $path
		 * @return bool
		 */
		public function is_executable($path){
			return is_executable($this->absolute($path, true));
		}

		/**
		 * @param string $path
		 * @return int
		 */
		public function fileperms($path){
			return fileperms($this->absolute($path, true));
		}

		/**
		 * @param string $path
		 * @return int
		 */
		public function fileowner($path){
			return fileowner($this->absolute($path, true));
		}

		/**
		 * @param string $path
		 * @return bool
		 */
		public function file_exists($path){
			return file_exists($this->absolute($path, true));
		}

		/**
		 * @param $path
		 * @return bool
		 */
		public function mkfile($path){
			if(($fp = fopen($this->absolute($path, true), 'w'))){
				fclose($fp);
				return true;
			}
			return false;
		}

		/**
		 * @param string $path
		 * @return bool
		 */
		public function unlink($path){
			return unlink($this->absolute($path, true));
		}

		/**
		 * @param string $path
		 * @param int $mod
		 * @param bool $recursive
		 * @return bool
		 */
		public function mkdir($path, $mod = 0777, $recursive = false){
			return mkdir($this->absolute($path, true),$mod,$recursive);
		}

		/**
		 * @param string $path
		 * @return bool
		 */
		public function rmdir($path){
			return rmdir($this->absolute($path, true));
		}

		/**
		 * @param string $path
		 * @param int $owner
		 * @return bool
		 */
		public function chown($path, $owner){
			return chown($this->absolute($path, true),$owner);
		}

		/**
		 * @param string $path
		 * @param int $mod
		 * @return bool
		 */
		public function chmod($path, $mod){
			return chmod($this->absolute($path, true),$mod);
		}

		/**
		 * @param $path
		 * @param $group
		 * @return mixed
		 */
		public function chgrp($path, $group){
			return chgrp($this->absolute($path, true), $group);
		}

		/**
		 * @param string $path
		 * @param string $newPath
		 * @return bool
		 */
		public function rename($path, $newPath){
			return rename($this->absolute($path, true), $this->absolute($newPath));
		}

		/**
		 * @param string $path
		 * @param string $destination
		 * @return bool
		 */
		public function copy($path, $destination){
			return copy($this->absolute($path, true), $this->absolute($destination));
		}

		/**
		 * @param $path
		 * @return array
		 */
		public function nodeList($path){
			$a = [];
			foreach(scandir($this->absolute($path, true)) as $path){
				if(!in_array($path,['.','..'],true))$a[]= $path;
			}
			return $a;
		}

		/**
		 * @param $pattern
		 * @return array
		 */
		public function nodeListMatch($pattern){
			return (array)glob($this->absolute($pattern, true));
		}

		/**
		 * @param $path
		 * @param null $modifyTime
		 * @param null $accessTime
		 * @return mixed
		 */
		public function touch($path, $modifyTime = null, $accessTime = null){
			return touch($this->absolute($path, true),$modifyTime,$accessTime);
		}

		/**
		 * @param $path
		 * @return mixed
		 */
		public function fileatime($path){
			return fileatime($this->absolute($path, true));
		}

		/**
		 * @param $path
		 * @return mixed
		 */
		public function filemtime($path){
			return filemtime($this->absolute($path, true));
		}

		/**
		 * @param $path
		 * @return mixed
		 */
		public function filectime($path){
			return filectime($this->absolute($path, true));
		}

		/**
		 * @param string $filePath
		 * @return string
		 */
		public function file_get_contents($filePath){
			return file_get_contents($this->absolute($filePath, true));
		}

		/**
		 * @param string $filePath
		 * @param string $content
		 * @return mixed
		 */
		public function file_put_contents($filePath, $content){
			return file_put_contents($this->absolute($filePath, true), $content);

		}

		/**
		 * @param Adapter $origin
		 * @param $originPath
		 * @param Adapter $destination
		 * @param $destinationPath
		 * @return bool|void
		 */
		public function transfer(
				Adapter $origin,        $originPath,
				Adapter $destination,   $destinationPath
		){
			if($origin instanceof Local && $destination instanceof Local){
				// Local TO Local transfer
				return $this->transferLocalToLocal($origin,$originPath,$destination,$destinationPath);
			}
			if($origin instanceof Local && $destination instanceof Remote){
				// Local TO Remote transfer
				return $this->transferLocalToRemote($origin,$originPath,$destination,$destinationPath);
			}
			if($origin instanceof Remote && $destination instanceof Local){
				// Remote TO Local transfer
				return $this->transferRemoteToLocal($origin,$originPath,$destination,$destinationPath);
			}
			if($origin instanceof Remote && $destination instanceof Remote){
				// Remote TO Remote transfer
				return $this->transferRemoteToRemote($origin,$originPath,$destination,$destinationPath);
			}
			return false;
		}

		/**
		 * @param Local $origin
		 * @param $originPath
		 * @param Local $destination
		 * @param $destinationPath
		 */
		public function transferLocalToLocal(
			Local $origin,        $originPath,
			Local $destination,   $destinationPath
		){

		}

		/**
		 * @param Local $origin
		 * @param $originPath
		 * @param Remote $destination
		 * @param $destinationPath
		 */
		public function transferLocalToRemote(
			Local $origin,        $originPath,
			Remote $destination,   $destinationPath
		){

		}

		/**
		 * @param Remote $origin
		 * @param $originPath
		 * @param Local $destination
		 * @param $destinationPath
		 */
		public function transferRemoteToLocal(
			Remote $origin,        $originPath,
			Local $destination,   $destinationPath
		){

		}

		/**
		 * TODO temporal drive
		 * @param Remote $origin
		 * @param $originPath
		 * @param Remote $destination
		 * @param $destinationPath
		 */
		public function transferRemoteToRemote(
			Remote $origin,        $originPath,
			Remote $destination,   $destinationPath
		){

		}
	}
}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>CryptoAuthLib: hal_win_kit_cdc.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>

<link href="navtree.css" rel="stylesheet" type="text/css"/>

<link href="search/search.css" rel="stylesheet" type="text/css"/>

<link href="doxygen.css" rel="stylesheet" type="text/css" />

CryptoAuthLib

Microchip CryptoAuthentication Library

Data Structures |
Macros |
Typedefs

hal_win_kit_cdc.h File Reference

ATCA Hardware abstraction layer for Windows using kit protocol over a USB CDC device.
More...

#include <Windows.h>

Go to the source code of this file.

Data Structures

struct  	cdc_device

struct  	atcacdc

Macros

#define 	CDC_DEVICES_MAX   10

#define 	CDC_BUFFER_MAX   1024

Typedefs

typedef struct cdc_device 	cdc_device_t

typedef struct atcacdc 	atcacdc_t

Detailed Description

ATCA Hardware abstraction layer for Windows using kit protocol over a USB CDC device.

Copyright

(c) 2015-2018 Microchip Technology Inc. and its subsidiaries.

Macro Definition Documentation

◆ CDC_BUFFER_MAX

          #define CDC_BUFFER_MAX   1024

◆ CDC_DEVICES_MAX

          #define CDC_DEVICES_MAX   10

Typedef Documentation

◆ atcacdc_t

          typedef struct atcacdc  atcacdc_t

◆ cdc_device_t

          typedef struct cdc_device  cdc_device_t

lib

hal

hal_win_kit_cdc.h

Generated by

     1.8.14


text:
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using Baseline.Dates;

namespace Marten.CommandLine.Commands.Projection;

internal class BatchingBlock<T> : IDisposable
{
    private readonly BatchBlock<T> _batchBlock;
    private readonly TimeSpan _timeSpan;
    private readonly Timer _trigger;

    public BatchingBlock(int milliseconds, ITargetBlock<T[]> processor,
        CancellationToken cancellation = default)
        : this(milliseconds.Milliseconds(), processor, cancellation)
    {
    }

    public BatchingBlock(TimeSpan timeSpan, ITargetBlock<T[]> processor,
        CancellationToken cancellation = default)
    {
        _timeSpan = timeSpan;
        _batchBlock = new BatchBlock<T>(100, new GroupingDataflowBlockOptions
        {
            CancellationToken = cancellation,
            BoundedCapacity = DataflowBlockOptions.Unbounded
        });

        _trigger = new Timer(_ =>
        {
            try
            {
                _batchBlock.TriggerBatch();
            }
            catch (Exception)
            {
                // ignored
            }
        }, null, Timeout.Infinite, Timeout.Infinite);

        _batchBlock.LinkTo(processor);
    }

    public int ItemCount => _batchBlock.OutputCount;

    public Task Completion => _batchBlock.Completion;

    public void Dispose()
    {
        _trigger.Dispose();
        _batchBlock.Complete();
    }

    public Task SendAsync(T item)
    {
        try
        {
            _trigger.Change(_timeSpan, Timeout.InfiniteTimeSpan);
        }
        catch (Exception)
        {
            // ignored
        }

        return _batchBlock.SendAsync(item);
    }

    public void Complete()
    {
        _batchBlock.Complete();
    }
}


text:
package org.apache.camel.component.mina2;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Test;

public class Mina2FileTcpTest extends BaseMina2Test {

    @Test
    public void testMinaRoute() throws Exception {
        MockEndpoint endpoint = getMockEndpoint("mock:results");
        endpoint.expectedMessageCount(1);
        endpoint.message(0).body().startsWith("Hello World");

        assertMockEndpointsSatisfied();
    }

    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {

            public void configure() {
                // lets setup a server
                from(String.format("mina2:tcp://localhost:%1$s?sync=false&textline=true", getPort())).to("mock:results");

                from("file:src/test/data?noop=true&fileName=message1.txt").
                    to(String.format("mina2:tcp://localhost:%1$s?sync=false&textline=true", getPort()));
            }
        };
    }
}


text:
using System;
using System.IO;
using System.Threading.Tasks;
using FP.DevSpace2016.PicFlow.Contracts.Dto;
using FP.DevSpace2016.PicFlow.Contracts.FileHandler;

namespace FP.DevSpace2016.PicFlow.ImagePersistor
{
    public class FileWriter
    {
        private readonly string _mongoConnectionString;
        public FileWriter(string mongoConnectionString)
        {
            _mongoConnectionString = mongoConnectionString;
        }

        public async Task PersistImage(string id)
        {
            var handler = new MongoDbFileHandler(_mongoConnectionString);
            var image = await handler.GetMessageObject<DtoImage>(id);

            using (var sourceStream = File.Open($"{Guid.NewGuid()}{Path.GetExtension(image.FileName)}", FileMode.OpenOrCreate))
            {
                sourceStream.Seek(0, SeekOrigin.End);
                await sourceStream.WriteAsync(image.Data, 0, image.Data.Length);
            }
        }
    }
}


text:
package test.nz.ac.massey.cs.guery.benchmark;

import nz.ac.massey.cs.guery.adapters.jungalt.Vertex;

/**
 * Custom vertex class.
 * @author jens dietrich
 */
public class TypeNode extends Vertex<TypeRef> {

	// properties
	// when making this a general purpose query language, we need to remove this
	private String namespace = "";
	private String name = "";
	private boolean isAbstract = false;
	private String type = null;
	private String container = null;
	private String cluster = null;
	private String fullName = null;

	public TypeNode(String id) {
		super(id);
	}
	public TypeNode() {
		super();
	}

	public boolean isAbstract() {
		return isAbstract;
	}
	public String getType() {
		return type;
	}
	public void setAbstract(boolean isAbstract) {
		this.isAbstract = isAbstract;
	}
	public void setType(String type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
		this.fullName = null;
	}
	public String getNamespace() {
		return namespace;
	}
	public void setNamespace(String namespace) {
		this.namespace = namespace;
		this.fullName = null;
	}
	public String getFullname() {
		if (this.fullName==null) {
			if (this.namespace==null||this.namespace.length()==0) {
				this.fullName = name;
			}
			else {
				this.fullName = namespace+'.'+name;
			}
		}
		return fullName;
	}

	public String toString() {
		return new StringBuffer()
			.append(this.getId())
			.append(':')
			.append(this.namespace)
			.append('.')
			.append(this.name)
			.toString();
	}

	public String getContainer() {
		return container;
	}
	public String getCluster() {
		return cluster;
	}
	public void setContainer(String container) {
		this.container = container;
	}
	public void setCluster(String cluster) {
		this.cluster = cluster;
	}
	// checks for inner class relationships
	public boolean isPartOf(TypeNode v) {
		if (!this.namespace.equals(v.namespace)) return false;
		else return (this.name.startsWith(v.name+'$'));
	}
	public void copyValuesTo(TypeNode v) {
		v.setName(name);
		v.setNamespace(namespace);
		v.setContainer(container);
		v.setType(type);
		v.setCluster(cluster);
		v.setAbstract(isAbstract);
	}

}


text: require "table_fu"


text:
@interface MHUITableViewStyleGroupedBugController : MHViewController

@end


text:
const Readable = require('stream').Readable

const readable = Readable({ objectMode: true })

readable.push('a')
readable.push('b')
readable.push({})
readable.push(null)

readable.on('data', data => console.log(data))


text:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">

    <display-name>Grouper App</display-name>

    <servlet>
        <servlet-name>GrouperServlet</servlet-name>
        <servlet-class>hello.GrouperServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>GrouperServlet</servlet-name>
        <url-pattern>/sms</url-pattern>
    </servlet-mapping>

</web-app>


text:
'use strict';

var StripeResource = require('../StripeResource');
var stripeMethod = StripeResource.method;

module.exports = StripeResource.extend({

  path: 'refunds',

  includeBasic: [
    'create', 'list', 'retrieve', 'update'
  ],
});