Reviewed vs. Native Jan 11, 2011
972514
public void reversePath(int pathIndex) {
		_verifyAllStreams();
		int pathCount = getPathCount();
		if (pathIndex >= pathCount)
			throw new IllegalArgumentException();

		int reversedPathStart = getPathStart(pathIndex);
		int reversedPathSize = getPathSize(pathIndex);
		int offset = isClosedPath(pathIndex) ? 1 : 0;

		// TODO: a bug for the non linear segments here.
		// There could be an issue here if someone explicity closes the path
		// with the same start/end point.
		for (int iattr = 0, nattr = m_description.getAttributeCount(); iattr < nattr; iattr++) {
			if (m_vertexAttributes[iattr] != null) {
				int semantics = m_description._getSemanticsImpl(iattr);
				int comp = VertexDescription.getComponentCount(semantics);
				m_vertexAttributes[iattr].reverseRange(comp
						* (reversedPathStart + offset), comp
						* (reversedPathSize - offset), comp);
			}
		}

		notifyModified(DirtyFlags.DirtyCoordinates);
	}
433669
private static boolean ensureVersion(Version existing, Version expected) {
        return existing != Version.UNDEFINED && existing.greaterThanOrEqualTo(expected);
    }
1328138
def native_(s, encoding='latin-1', errors='strict'):
    '''
    
    '''
    if PY3:
        out = s if isinstance(s, text_type) else str(s, encoding, errors)
    else:
        out = s.encode(encoding, errors) if isinstance(s, text_type) else str(s)

    return out
798613
function Input(native) {
    EventEmitter.call(this);
    this.native = native;

    this.id = native.id;
    this.manufacturer = native.manufacturer;
    this.name = native.name;
    this.version = native.version;

    native.onmidimessage = function (event) {
        var data, type, object;

        data = new BufferCursor(new buffer.Buffer(event.data));
        type = data.readUInt8();

        object = parseChannelEvent(
            event.receivedTime,
            type >> 4,
            type & 0xF,
            data
        );

        this.emit('event', object);
    }.bind(this);
}
153371
def create
      @app_review = MnoEnterprise::AppAnswer.new(app_answer_params)

      if @app_review.save
        render :show
      else
        render json: @app_review.errors, status: :bad_request
      end
    end
792093
public static int compareMavenVersions(String v1, String v2) {
		return parseMavenVersion(v1).compareTo(parseMavenVersion(v2));
	}
172392
@SuppressWarnings("deprecation")
    private boolean isAlternativePresent(final String alternative) {
        if (alternatives == null) {
            return false;
        }
        for (String alt : alternatives) {
            if (alt.equals(alternative)) {
                return true;
            }
        }
        return false;
    }
332309
def native(cmd, opts = [], chdir = true, redirect = '', &block)
      validate

      ENV['GIT_DIR'] = @git_dir
      ENV['GIT_INDEX_FILE'] = @git_index_file
      ENV['GIT_WORK_TREE'] = @git_work_dir
      path = @git_work_dir || @git_dir || @path

      opts = [opts].flatten.map {|s| escape(s) }.join(' ')
      git_cmd = "git #{cmd} #{opts} #{redirect} 2>&1"

      out = nil
      if chdir && (Dir.getwd != path)
        Dir.chdir(path) { out = run_command(git_cmd, &block) }
      else
        out = run_command(git_cmd, &block)
      end

      if @logger
        @logger.info(git_cmd)
        @logger.debug(out)
      end

      if $?.exitstatus > 0
        if $?.exitstatus == 1 && out == ''
          return ''
        end
        raise Git::CommandFailed.new(git_cmd, $?.exitstatus, out.to_s)
      end
      out
    end
274254
function (actual, message) {
        YUITest.Assert._increment();
        if (true !== actual) {
            throw new YUITest.ComparisonFailure(YUITest.Assert._formatMessage(message, "Value should be true."), true, actual);
        }

    }
443106
@Override
    public boolean printNative(Appendable app, int indentLevel, FilterValues<S> values)
        throws IOException
    {
        boolean result = false;
        for (QueryExecutor<S> executor : mExecutors) {
            result |= executor.printNative(app, indentLevel, values);
        }
        return result;
    }
991497
public boolean checkAndMaybeUpdate() throws IOException {
    try {
      File nativeLibDir = soSource.soDirectory;
      Context updatedContext =
          applicationContext.createPackageContext(applicationContext.getPackageName(), 0);
      File updatedNativeLibDir = new File(updatedContext.getApplicationInfo().nativeLibraryDir);
      if (!nativeLibDir.equals(updatedNativeLibDir)) {
        Log.d(
            SoLoader.TAG,
            "Native library directory updated from " + nativeLibDir + " to " + updatedNativeLibDir);
        // update flags to resolve dependencies since the system does not properly resolve
        // dependencies when the location has moved
        flags |= DirectorySoSource.RESOLVE_DEPENDENCIES;
        soSource = new DirectorySoSource(updatedNativeLibDir, flags);
        soSource.prepare(flags);
        applicationContext = updatedContext;
        return true;
      }
      return false;
    } catch (PackageManager.NameNotFoundException e) {
      throw new RuntimeException(e);
    }
  }
669983
public function compare(PageVersion $new, PageVersion $old)
    {
        if ($new->getRestoredVersionId()) {
            return new Diff\RestoredVersion($new, $old);
        }

        if ($new->isContentChange()) {
            return new Diff\ChunkChange($new, $old);
        }

        if ($new->getTemplateId() !== $old->getTemplateId()) {
            return new Diff\TemplateChange($new, $old);
        }

        if (strcmp($new->getTitle(), $old->getTitle()) !== 0) {
            return new Diff\TitleChange($new, $old);
        }

        if ($new->isPendingApproval() && !$old->isPendingApproval()) {
            return new Diff\ApprovalRequest($new, $old);
        }

        if ($new->isEmbargoed($new->getEditedTime())) {
            if (!$old->isEmbargoed($old->getEditedTime())) {
                return new Diff\Embargoed($new, $old);
            }

            if ($new->getEmbargoedUntil()->getTimestamp() !== $old->getEmbargoedUntil()->getTimestamp()) {
                return new Diff\EmbargoChanged($new, $old);
            }
        }

        if ($new->isPublished($new->getEditedTime())) {
            if (!$old->isPublished($old->getEditedTime())) {
                return new Diff\Published($new, $old);
            }
        }
    }
842811
private static function preReleaseEquals(PreRelease $v1, PreRelease $v2)
    {
        // If they don't match on the versionable level they can not match
        if (!self::versionableEquals($v1, $v2)) {
            return false;
        }

        // Both other parts need to match
        if ($v1->getGreek() !== $v2->getGreek()) {
            return false;
        }
        if ($v1->getReleaseNumber() !== $v2->getReleaseNumber()) {
            return false;
        }

        return true;
    }
188932
function compareDottedVersion(v1, v2) {
  const parts1 = /([0-9.]+)(.*)$/.exec(v1)
  const parts2 = /([0-9.]+)(.*)$/.exec(v2)
  if (parts1 != null && parts2 != null) {
    const numbers1 = parts1[1]
    const numbers2 = parts2[1]
    const distinguisher1 = parts1[2]
    const distinguisher2 = parts2[2]
    const numlist1 = numbers1.split('.').map(e => +e)
    const numlist2 = numbers2.split('.').map(e => +e)
    const cmp = listCompare(numlist1, numlist2)
    if (cmp !== 0) {
      return cmp
    } else {
      return distinguisher1 < distinguisher2
        ? -1
        : distinguisher1 > distinguisher2
        ? 1
        : 0
    }
  }
  return v1 < v2 ? -1 : v1 > v2 ? 1 : 0
}
1230359
function vv(i, v, inc) {
		var vn = !isNaN(v);
		var nv = vn ? v : v || self.versionMatch[i] || '';
		if (inc && vn) {
			return +nv + 1;
		} else if (inc) {
			// increment the last numeric value sequence
			return nv.replace(regexVerLast, function vvInc(m) {
				return +m + 1;
			});
		}
		return nv;
	}
150227
function compareVersions(installed, required) {

	var a = installed.split('.');
	var b = required.split('.');

	for (var i = 0; i < a.length; ++i) {
		a[i] = Number(a[i]);
	}
	for (var i = 0; i < b.length; ++i) {
		b[i] = Number(b[i]);
	}
	if (a.length == 2) {
		a[2] = 0;
	}

	if (a[0] > b[0]) return true;
	if (a[0] < b[0]) return false;

	if (a[1] > b[1]) return true;
	if (a[1] < b[1]) return false;

	if (a[2] > b[2]) return true;
	if (a[2] < b[2]) return false;

	return true;
}
607243
function updateRating(rating, config, conn) {

  // validate
  if (!rating.uri || rating.uri === '') {
    return 'You must enter a valid uri'
  }
  if (!rating.reviewer || rating.reviewer === '') {
    return 'You must enter a valid reviewer'
  }
  if (isNaN(rating.rating)) {
    return 'You must enter a valid rating'
  }

  // defaults
  config = config || require('../config/config.js')


  // main
  return new Promise((resolve, reject) => {

    if (!conn) {
      var conn = wc_db.getConnection(config.db)
    }

    var sql = 'UPDATE Rating r join User u on u.id = r.reviewer_id set r.rating = :rating where u.uri = :reviewer and r.uri = :uri'

    debug('updateRating', sql, rating)

    conn.query(sql, { replacements: { "uri" : rating.uri, "reviewer" : rating.reviewer, "rating" : rating.rating } }).then(function(ret){
      return resolve({"ret" : ret, "conn" : conn})
    }).catch(function(err) {
      return reject({"err" : err, "conn" : conn})
    })

  })

}