returns hash
 [tree-ish] = [[line_no, match], [line_no, match2]]
 [tree-ish] = [[line_no, match], [line_no, match2]]
435181
def grep(string, opts = {})
      opts[:object] ||= 'HEAD'

      grep_opts = ['-n']
      grep_opts << '-i' if opts[:ignore_case]
      grep_opts << '-v' if opts[:invert_match]
      grep_opts << '-e'
      grep_opts << string
      grep_opts << opts[:object] if opts[:object].is_a?(String)
      grep_opts << '--' << opts[:path_limiter] if opts[:path_limiter].is_a? String

      hsh = {}
      command_lines('grep', grep_opts).each do |line|
        if m = /(.*)\:(\d+)\:(.*)/.match(line)
          hsh[m[1]] ||= []
          hsh[m[1]] << [m[2].to_i, m[3]]
        end
      end
      hsh
    end
132274
def to_h
      h = {}
      to_hash(@root_node).each do |k, v|
        key = k.terminate(false).to_string
        h[key] = v
      end
      h
    end
443566
def jsonhash(obj, root=True, exclude=None, hash_func=_jsonhash_sha1):
    '''
    
    '''
    if isinstance(obj, Mapping):
        # assumption: using in against set() is faster than in against list()
        if root and exclude:
            obj = {k: v for k, v in obj.iteritems() if k not in exclude}
        # frozenset's don't guarantee order; use sorted tuples
        # which means different python interpreters can return
        # back frozensets with different hash values even when
        # the content of the object is exactly the same
        result = sorted(
            (k, jsonhash(v, False)) for k, v in obj.iteritems())
    elif isinstance(obj, list):
        # FIXME: should lists be sorted for consistent hashes?
        # when the object is the same, just different list order?
        result = tuple(jsonhash(e, False) for e in obj)
    else:
        result = obj
    if root:
        result = unicode(hash_func(result))
    return result
413570
def to_hash
      {
        response_id: response_id,
        question_id: question_id,
        option_id: option_id,
        question_pipe: question_pipe,
        submitted_at: submitted_at,
        survey_id: survey_id,
        other_text: other_text,
        answer_text: option_id || other_text ? nil : answer_text
      }.reject { |k, v| v.nil? }
    end
451313
def hash(self):
        '''
        
        '''
        hashed = super(Repeat, self).hash()
        return khash(hashed, self._min_times, self._max_times, self._step, self._repeats)
593834
def to_hash
      hash = {}

      instance_variables.each do |v|
        hash[v.to_s[1..-1].to_sym] = instance_variable_get(v)
      end

      hash[:results].each do |c|
        hash[:results][hash[:results].index(c)] = c.to_hash
      end

      hash
    end
718367
def parse_tree_line(line)
      mode, _type, sha, size, *name = line.split(/\s+/)
      BlobEntry.new(sha, name.join(' '), size.to_i, mode.to_i(8))
    end
110836
def to_hash(node)
      node_type = get_node_type node

      case node_type
      when :blank
        {}
      when :branch
        hash = {}

        16.times do |i|
          sub_hash = to_hash decode_to_node(node[i])
          sub_hash.each {|k, v| hash[NibbleKey.new([i]) + k] = v }
        end

        hash[NibbleKey.terminator] = node.last if node.last.true?
        hash
      when *NODE_KV_TYPE
        nibbles = NibbleKey.decode(node[0]).terminate(false)

        sub_hash = node_type == :extension ?
          to_hash(decode_to_node(node[1])) : {NibbleKey.terminator => node[1]}

        {}.tap do |hash|
          sub_hash.each {|k, v| hash[nibbles + k] = v }
        end
      else
        # do nothing
      end
    end
1163092
public static List<String> neighbours(String hash) {
        List<String> list = new ArrayList<String>();
        String left = adjacentHash(hash, Direction.LEFT);
        String right = adjacentHash(hash, Direction.RIGHT);
        list.add(left);
        list.add(right);
        list.add(adjacentHash(hash, Direction.TOP));
        list.add(adjacentHash(hash, Direction.BOTTOM));
        list.add(adjacentHash(left, Direction.TOP));
        list.add(adjacentHash(left, Direction.BOTTOM));
        list.add(adjacentHash(right, Direction.TOP));
        list.add(adjacentHash(right, Direction.BOTTOM));
        return list;
    }
800330
def matches(self, hash_alg, hash_value):
        
        return self.alg == hash_alg and self.value == hash_value
994713
def jobs_hash
      hash = {}
      jobs.each_with_index { |job, idx| hash[idx.to_s] = job }
      hash
    end
767047
def to_h
      hash = {}
      [:bri, :hue, :sat].each do |attr|
        value = send(attr)
        hash[attr] = value if value
      end
      hash
    end
943817
def matches(match_method, *params)
      return [] unless match_method.respond_to?(:yield)
      matches = match_method.yield(*params)
      return [] unless matches.respond_to?(:each)

      # We convert Nokogiri nodes to matches transparently
      matches.map do |m|
        if m.respond_to?(:node_name)
          match(m)
        elsif m.respond_to?(:xpath)
          m.to_a.map { |n| match(n) }
        else
          m
        end
      end.flatten
    end
46810
def flatten_nested_hash(hash_table):
    
    def flatten(hash_table, brackets=True):
        f = {}
        for key, value in hash_table.items():
            _key = '[' + str(key) + ']' if brackets else str(key)
            if isinstance(value, dict):
                for k, v in flatten(value).items():
                    f[_key + k] = v
            elif isinstance(value, list):
                temp_hash = {}
                for i, v in enumerate(value):
                    temp_hash[str(i)] = v
                for k, v in flatten(temp_hash).items():
                    f[_key + k] = v
            else:
                f[_key] = value
        return f
    return flatten(hash_table, False)
801734
def to_hash(options = {})
      options.reverse_merge!(@_options)

      data = root_object

      options[:root_name] = determine_object_root(data, root_name, options[:root])

      result =
        if is_object?(data) || !data # object @user
          Builder.new(data, @_settings, options).to_hash
        elsif is_collection?(data) # collection @users
          MultiBuilder.new(data, @_settings, options).to_a
        end

      result = escape_output(result) if Rabl.configuration.escape_all_output

      result
    end
1213304
def hash(self):
        '''
        
        '''
        hashed = super(Group, self).hash()
        return khash(hashed, frozenset(self._values))
12515
function sfuse(hash){
	var retval = '';

	var cache = [];
	us.each(hash, function(loc_list, str){
	    var locs = dedupe(loc_list);
	    cache.push( str + ' <small>[' + locs.join(', ') + ']</small>');
	});
	if( cache.length > 0 ){
	    retval = cache.join('<br />');	    
	}
	
	return retval;
    }