TODO: replace with Hash#dig when minimal Ruby version would be 2.3
332330
def hash_dig(hash, *keys)
      keys.inject(hash) { |res, key| res[key] or return nil }
    end
817147
def deconstruct_version_string(version)
      match = version.match(/^(\d+)\.(\d+)(?:\.(\d+))?$/)

      # Match should have 4 parts [0] = input string, [1] = major
      # [2] = minor, [3] = patch (possibly blank)
      if match && match.size == 4
        return [match[1].to_i, match[2].to_i, match[3].to_i || 0]
      else
        return nil
      end
    end
389306
function findByHash(config, hash) {
  const re = new RegExp(injectHashIntoPath(config.sourceMapPath, hash));

  return glob
    .sync('./**')
    .filter(file => re.test(file))
    .map(sourceMapPath => {
      // strip relative path characters
      const sourceMapPathMatch = sourceMapPath.match(re);

      if (sourceMapPathMatch) {
        const minifiedUrl = sourceMapPathMatch[0].replace(
          re,
          injectHashIntoPath(config.minifiedUrl, hash),
        );

        return {
          sourceMapPath,
          minifiedUrl,
        };
      }
    })
    .filter(Boolean);
}
297957
def ls_tree(options, treeish, *paths)
      sha = rev_parse({}, treeish)
      ruby_git.ls_tree(sha, paths.flatten, options.delete(:r))
    rescue Grit::GitRuby::Repository::NoSuchShaFound
      ''
    end
198980
def hash_extractor(name, value)
      value.split(',').reduce({}) do |set, tag|
        k, v = tag.split(':')
        if v.nil?
          log_warn("Invalid hash value for #{name}: #{value}")
          return nil
        end

        set.merge(decode(k).downcase.to_sym => decode(v))
      end
    end
1063933
def rake_merge_option(args, defaults)
      if Hash === args.last
        defaults.update(args.last)
        args.pop
      end
      args.push defaults
      args
    end
1014775
private void reComputeHashCode()
    {
        ivCurHashCode = (ivAppName != null ? ivAppName.hashCode() : 0) // d437828
                        + (ivModJarName != null ? ivModJarName.hashCode() : 0)
                        + (ivPuName != null ? ivPuName.hashCode() : 0);
    }
894508
def strip_hashes(s)
		s = s[num_leading_hashes(s), s.size]
		i = s.size-1
		while i > 0 && (s[i,1] =~ /(#|\s)/); i-=1; end
		s[0, i+1].strip
	end
7198
function toDrupalMajorVersion(version) {
    var regex = /^(\d+)\.\d+\.[x\d+]/;
    var match = version.match(regex)
    if (match) {
      return match[1] + '.x';
    }

    return version;
  }
493188
def search_hash(self, searchterm):
        
        return self.__search(type_attribute=self.__misphashtypes(), value=searchterm)
575880
def hash_for_railsbp(error)
        {
          'linter' => error['message'].gsub(/\((.*)\)/, '').strip.parameterize('_').camelize,
          'severity' => 'warning',
          'reason' => error['message'],
          'column' => 0,
          'line' => error['line_number'].to_i
        }
      end
867385
def yank_version(name, version, options = {})
      ensure_ready!(:authorization)
      url = "gems/#{escape(name)}/versions/#{escape(version)}"
      response = connection.delete(url, options)
      checked_response_body(response)
    end
1044583
def update_from_hash(hash)
      j = self
      #update top line params
      j.update_attributes(:active => hash['active'],
                          :trigger => hash['trigger'])
      (1..5).to_a.each do |s_idx|
        stage_string = hash["stage#{s_idx.to_s}"]
        s = Stage.find_by_path("#{j.path}/stage#{s_idx.to_s}")
        if stage_string.to_s.length==0
          #delete this stage and all stages after
          if s
            j = s.job
            j.stages[(s.idx-1)..-1].each{|ps| ps.delete}
            #just in case
            s.delete
          end
          break
        elsif s.nil?
          #create this stage
          s = Stage.find_or_create_by_path("#{j.path}/stage#{s_idx.to_s}")
        end
        #parse command string, update stage with it
        s_handler, call, param_string = [""*3]
        stage_string.split(" ").ie do |spls|
          s_handler = spls.first.split(".").first
          call = spls.first.split(".").last
          param_string = spls[1..-1].join(" ").strip
        end
        s.update_attributes(:call=>call, :handler=>s_handler, :param_string=>param_string)
      end
      return j.reload
    end
215154
function (version) {
    var vs = version.replace(/[^0-9\\.]/g, '');
    vs = vs.replace(/\./g, '_');
    return vs;
  }
899723
function withRegex(pattern, thunk) {
    var lastIndex = pattern.lastIndex;
    var result = thunk ();
    pattern.lastIndex = lastIndex;
    return result;
  }
504942
def normalize_rules(rules)
      deps          = Hash.new { |h, k| h[k] = [] }
      substitutions = {}

      # replace before with after on oposite direction and build the
      # substitutions dictionary
      rules.each do |middleware_class, middleware_rules|
        deps[middleware_class].concat(middleware_rules[:after])
        middleware_rules[:before].each do |dependent_class|
          deps[dependent_class] << middleware_class
        end
        middleware_rules[:replace].each do |replaced|
          substitutions[replaced] = middleware_class
        end
      end

      # replace the middleware to be substituted
      substitutions.each do |old, new|
        deps[new].concat(deps[old])
        deps.delete(old)
      end

      # ignore deps, that are not present in the stack
      deps.each do |middleware_class, middleware_deps|
        middleware_deps.reject! { |dep| !deps.has_key?(dep) }
      end

      return deps.delete_if {|klass, _| klass.nil? }
    end
336263
def upper_hash_to_lower_hash( upper )
			case upper
			when Hash
        upper.inject({}) do |lower,array|
					key, value = array
          lower[key.downcase] = upper_hash_to_lower_hash( value )
					lower
        end
      else
        upper
      end
    end