This method is just to evade code duplication in count() and get_content, since they do basically the same thing
972146
def _get_query(self, order=None, filters=None):
        
        order = self._get_order(order)
        return self.posts.all().order_by(order)
573150
public static int count(String regex, CharSequence content) {
		if (null == regex || null == content) {
			return 0;
		}

		// Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
		final Pattern pattern = PatternPool.get(regex, Pattern.DOTALL);
		return count(pattern, content);
	}
1106686
function dup( text, count ) {

    let result = "";

    for ( let i = 1; i <= count; i++ ) result += text;

    return result;

}
968977
public static int count(String str,String target){
		int count=0; 
		int index=0; 
		while(true){ 
			index=str.indexOf(target,index+1); 
			if(index>0){ 
				count++; 
			}else{ 
				break; 
			} 
		} 
		return count; 
	}
334863
async def count(query, clear_limit=False):
    
    clone = query.clone()
    if query._distinct or query._group_by or query._limit or query._offset:
        if clear_limit:
            clone._limit = clone._offset = None
        sql, params = clone.sql()
        wrapped = 'SELECT COUNT(1) FROM (%s) AS wrapped_select' % sql
        raw = query.model.raw(wrapped, *params)
        return (await scalar(raw)) or 0
    else:
        clone._returning = [peewee.fn.Count(peewee.SQL('*'))]
        clone._order_by = None
        return (await scalar(clone)) or 0
492798
def get_squeezed_contents(contents):
    
    line_between_example_code = substitute.Substitution(
        '\n\n    ',
        '\n    ',
        True
    )
    lines_between_examples = substitute.Substitution('\n\n\n', '\n\n', True)
    lines_between_sections = substitute.Substitution(
        '\n\n\n\n', '\n\n\n', True
    )

    result = contents
    result = line_between_example_code.apply_and_get_result(result)
    result = lines_between_examples.apply_and_get_result(result)
    result = lines_between_sections.apply_and_get_result(result)
    return result
1034172
private int getContentLength(Map<String, List<String>> headers)
    {
        try
        {
            return Integer.parseInt(headers.get("Content-Length").get(0));
        }
        catch (Exception e)
        {
            return -1;
        }
    }
1141825
def copy(self, contents=True):
        ''''''
        cp = connection(self._baseiri, self._attr_cls, self._logger)
        if contents: cp.add_many(self._relationships)

        return cp
35115
def get_one(self, qry, tpl):
        '''  '''
        self.cur.execute(qry + ' LIMIT 1', tpl)
        result = self.cur.fetchone()
        # unpack tuple if it has only
        # one element
        # TODO unpack results
        if type(result) is tuple and len(result) == 1:
            result = result[0]
        return result
90012
def get_count(self):
        
        params = self.get_params()
        params["offset"] = self.low_mark
        params["limit"] = 1

        r = self.resource._meta.api.http_resource("GET", self.resource._meta.resource_name, params=params)
        data = self.resource._meta.api.resource_deserialize(r.text)

        number = data["meta"]["total_count"]

        # Apply offset and limit constraints manually, since using limit/offset
        # in the API doesn't change the total_count output.
        number = max(0, number - self.low_mark)
        if self.high_mark is not None:
            number = min(number, self.high_mark - self.low_mark)

        return number
927844
function count(query, callback) {
    self.emit('count', query)
    findByQuery(query, options, function (error, objects) {
      self.emit('received', objects.length)
      callback(undefined, objects.length)
    })
  }
457100
def wrap_count(method):
    
    number = 0
    while hasattr(method, '__aspects_orig'):
        number += 1
        method = method.__aspects_orig
    return number
406127
def count(self):
        
        count = 0
        operation = self._get_operation()
        kwargs = self.kwargs.copy()
        kwargs['select'] = 'COUNT'
        limit = kwargs.get('limit', None)
        while True:
            result = operation(self.model.get_table_name(), **kwargs)
            count += result['Count']
            if limit is not None:
                limit -= result['Count']

            last_evaluated_key = result.get('LastEvaluatedKey', None)
            if not self._prepare_next_fetch(kwargs, last_evaluated_key, limit):
                break
        return count
527902
def count(self, with_limit_and_skip=False):
        ''' 
        '''
        return self.__get_query_result().cursor.count(with_limit_and_skip=with_limit_and_skip)
528434
def _check_count(self, result, func, args):
        #pylint: disable=unused-argument
        
        if result == 0:
            raise ctypes.WinError(ctypes.get_last_error())
        return args
1288892
function getCharCount(e, s) {
  s = s || ",";
  return getInnerText(e).split(s).length;
}
474590
def _fetch(self, count=False):
        if self._result_cache is not None:
            return len(self._result_cache) if count else self._result_cache
        
        options = dict(self._options)  # make a local copy
        if self._where:
            # JSON encode WHERE values
            options['where'] = json.dumps(self._where)
        if self._select_related:
            options['include'] = ','.join(self._select_related)
        if count:
            return self._manager._count(**options)

        self._result_cache = self._manager._fetch(**options)
        return self._result_cache