Convert a hash to flat one.

 @example
   flat_hash(type: 'block', caller: {type: 'send', receiver: 'RSpec'})
     #=> {[:type] => 'block', [:caller, :type] => 'send', [:caller, :receiver] => 'RSpec'}
 @param h [Hash] original hash.
 @return flatten hash.
174537
def flat_hash(h, k = [])
      new_hash = {}
      h.each_pair do |key, val|
        if val.is_a?(Hash)
          new_hash.merge!(flat_hash(val, k + [key]))
        else
          new_hash[k + [key]] = val
        end
      end
      new_hash
    end
753854
def to_h
      @raw.reduce(Hash.new(0)) do |acc, elem|
        acc.merge(elem.date => elem.score)
      end
    end
1231331
def to_hash
      stringified_params = Hash[parameters.map { |key, val| [key.to_s, val] }]
      base_hash.merge(stringified_params)
    end
871213
function(hash, nestingLevel) {
    // reduce nestingLevel to hash size
    nestingLevel = Math.min(hash.length - 1, nestingLevel);

    if (nestingLevel === 0) {
        return hash;
    }

    var hashArr = hash.split('');
    for (var i = 0; i < nestingLevel; i++) {
        hashArr.splice(i * 2 + 1, 0, '/');
    }

    return hashArr.join('');
}
1230386
def to_hash
      hash = {}
      attributes = self.class.attribute_map.sort_by {|key,value| key}
      attributes.each { |attr, param|
        value = self.send(attr)
        next if value.nil?
        if value.is_a?(Array)
          hash[param] = value.compact.map{ |v| _to_hash(v) }
        else
          hash[param] = _to_hash(value)
        end
      }
      hash
    end
889710
def flatten_keys(hash, prev_key=nil, &block)
      hash.each_pair do |key, value|
        curr_key = [prev_key, key].compact.join('.')
        if value.is_a?(Hash)
          flatten_keys(value, curr_key, &block)
        else
          yield curr_key, value
        end
      end
    end
509546
def normalize_hash(hash)
      new_hash = {}

      hash.each do |key,value|
        new_hash[key.to_sym] = normalize(value)
      end

      return new_hash
    end
848046
def to_h(with_errors: false, with_value: true)
      hash = {
        name: name,
        label: label,
        type: type,
        description: description,
        default: default,
        from: from.reject { |k,_| k == :default},
        to: to
      }.merge(type_options).reject { |_,v| v.nil? }
      hash[:skip_if] = skip_if if skip_if
      hash[:only_if] = only_if if only_if
      hash[:errors]  = errors  if with_errors
      if with_value
        if type == 'group'
          hash[:value]   = value.to_h(with_values: true, with_errors: with_errors)
        else
          hash[:value] = value
        end
      end
      hash
    end
611315
def hash_to_liquid(hash)
      hash.map { |key, value| [key.to_s, empty2nil(value)] }.to_h
    end
31477
def to_h
      hash = {}
      @data.each_pair do |key, value|
        hash[key] = value.to_h
      end
      
      hash      
    end
250056
def block_header_to_hex( block_data, prev_hash ):
    
    header_info = {
       "version": block_data['version'],
       "prevhash": prev_hash,
       "merkle_root": block_data['merkleroot'],
       "timestamp": block_data['time'],
       "bits": int(block_data['bits'], 16),
       "nonce": block_data['nonce'],
       "hash": block_data['hash']
    }

    return block_header_serialize(header_info)
789941
def to_hash
      result = {
        name: @name,
        value: @value,
        domain: @domain,
        path: @path,
        created_at: @created_at
      }
      {
        expiry: @expiry,
        secure: (true if @secure),
        http_only: (true if @http_only),
        version: (@version if version != 0),
        comment: @comment,
        comment_url: @comment_url,
        discard: (true if @discard),
        ports: @ports
      }.each do |name, value|
        result[name] = value if value
      end

      result
    end
428685
def to_hash
      ret = {}
      @hash.dup.each_pair do |key, val|
        ret[key] = self.convert_value_from_ostruct(val)
      end
      ret
    end
1359686
def to_h
      keys.map { |k| [k, map { |h| h[k] }] }.to_h
    end
1245168
def headers
      list = @response.header_str.split(/[\r\n]+/).map(&:strip)
      Hash[list.flat_map{ |s| s.scan(/^(\S+): (.+)/) }.map { |pair|
        [pair.first.to_s.camelcase, pair.second]
      }]
    end
305585
def to_h(values_only: false, with_values: false, with_errors: false)
      if values_only
        Hash[*options.flat_map {|opt| [opt.name, opt.type == 'group' ? opt.value.to_h(values_only: true) : opt.value]}]
      else
        Hash[*options.flat_map {|opt| [opt.name, opt.to_h(with_value: with_values, with_errors: with_errors).reject {|k,_| k==:name}]}]
      end
    end
969473
def build_hash_with_entities(entities_name, entity_name, proc, entities)
      Hash[*entities_name.collect { |name| proc.call(name) == entity_name ? [name, entities] : [name, []] }.flatten(1)]
    end