Skip to content

Instantly share code, notes, and snippets.

Avatar
☁️

Dan Kohn dankohn

☁️
View GitHub Profile
View FizzBuzz
puts 1.upto(100).map { |n| "#{'Fizz' if n%3==0}#{'Buzz' if n%5==0}".presence || n }
View coredns.txt
OOOO
OOOOOOOOOO
ZZOOOOOOOOOOO
ZZZZZOOOOOOOOOOO
ZZZZZZZZZOOOOOOOOOO
ZZZZZZZZZZZOOOOOOOOOOO $$$$$$
ZZZZZZZZZZZZZZZOOOOOOOOOOO $$$$$$$$$
ZZZZZZZZZZZZZZZZZZOOOOOOOOOOO$$$$$$$$$$$$$
ZZZZZZZZZZZZZZZZZZ ~OOOOOOMMM$$$$$$$$$$$$
@dankohn
dankohn / danserve.rb
Last active Dec 19, 2017
Simple key-value server
View danserve.rb
# frozen_string_literal: true
class Server
def get(query)
respond "db: #{@db}"
return unless (value = query['key'])
if (lookup = @db[value])
respond "successful lookup: #{value} => #{lookup}"
else respond "failed lookup: no entry for #{value}"
end
View commits_and_authors.sql
SELECT
repo.name AS repository,
COUNT(repo.name) AS commits,
EXACT_COUNT_DISTINCT(actor.login) AS committers,
EXACT_COUNT_DISTINCT(JSON_EXTRACT(payload, '$.commits[0].author.email')) AS authors
FROM
[githubarchive:year.2016]
WHERE
type IN ("PushEvent")
GROUP BY
View project_commits.sql
SELECT
repo_name AS repository,
EXACT_COUNT_DISTINCT(author.name) AS authors,
EXACT_COUNT_DISTINCT(committer.name) AS committers,
COUNT(*) AS commits
FROM
[bigquery-public-data:github_repos.commits]
WHERE
repo_name IN ( "torvalds/linux",
"facebook/react-native",
View by_commit.sql
SELECT
repo_name AS repository,
EXACT_COUNT_DISTINCT(author.name) AS authors,
EXACT_COUNT_DISTINCT(committer.name) AS committers,
COUNT(*) AS commits
FROM
[bigquery-public-data:github_repos.commits]
WHERE
committer.date >= TIMESTAMP("2016-01-01 00:00:00")
AND committer.date < TIMESTAMP("2017-01-01 00:00:00")
View pull_requests.sql
SELECT
repo.name AS repository,
COUNT(*) AS pull_requests,
EXACT_COUNT_DISTINCT(actor.login) AS contributors
FROM
[githubarchive:year.2016]
WHERE
type IN ( 'PullRequestEvent')
AND JSON_EXTRACT(payload, '$.action') IN ('"opened"')
GROUP BY
View issues.sql
SELECT
repo.name,
ROUND(COUNT(*)/EXACT_COUNT_DISTINCT(actor.login),2) comments_per_author,
EXACT_COUNT_DISTINCT(actor.login ) authors,
COUNT(*) comments
FROM
[githubarchive:year.2016]
WHERE
type IN ('IssueCommentEvent')
AND actor.login NOT IN (
@dankohn
dankohn / over_10_contributors.sql
Last active Feb 26, 2017
More than 10 contributors
View over_10_contributors.sql
SELECT
repo.name AS repository,
COUNT(repo.name) AS commits,
EXACT_COUNT_DISTINCT(actor.login) AS contributors
FROM
[githubarchive:year.2016]
WHERE
type IN ("PushEvent")
GROUP BY
repository
View commits.sql
SELECT
repo.name AS repository,
COUNT(repo.name) AS commits,
EXACT_COUNT_DISTINCT(actor.login) AS contributors
FROM
[githubarchive:year.2016]
WHERE
type IN ("PushEvent")
GROUP BY
repository