Skip to content

Instantly share code, notes, and snippets.

@mikz
Created August 20, 2021 09:38
Show Gist options
  • Save mikz/0fc7b67a076444b5bdd5a628e7b31e9f to your computer and use it in GitHub Desktop.
Save mikz/0fc7b67a076444b5bdd5a628e7b31e9f to your computer and use it in GitHub Desktop.

Revisions

  1. mikz created this gist Aug 20, 2021.
    60 changes: 60 additions & 0 deletions hiring.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    #!/usr/bin/env ruby

    require 'bundler/setup'
    Bundler.require

    require 'pp'

    client = Octokit::Client.new(access_token: ENV.fetch("ACCESS_TOKEN"))

    repositories = []

    module Autowait
    def wait_for_ratelimit
    return unless last_response

    limit = ratelimit

    if limit.remaining < 1
    warn "waiting for #{limit.resets_in}s to refresh rate limit"
    sleep limit.resets_in + 3
    end
    end

    def request(*)
    super
    ensure
    wait_for_ratelimit
    end
    end

    client.extend(Autowait)
    client.auto_paginate = true

    %w[Praha Barcelona Prague].each do |city|
    users = client.search_users(%|location:#{city}|)

    users.items.each do |user|
    repositories = client.repositories(user.id, accept: 'application/vnd.github.mercy-preview+json')

    repositories.select do |repo|
    valid = false

    if repo.name.match(/\bunity/i)
    valid = true
    end

    if repo.topics.grep(/\b(unity)/i).size > 0
    valid = true
    end

    if repo.description&.match(/\b(unity)\b/i)
    valid = true
    end

    if valid
    puts "Found #{repo.html_url} #{'FORK' if repo.fork} (#{repo.stargazers_count} stars, #{repo.watchers_count} watchers, #{repo.forks_count} forks) with topics: #{repo.topics.join(', ')}"
    end
    end
    end
    end