Skip to content

Instantly share code, notes, and snippets.

View ahachete's full-sized avatar

Álvaro Hernández Tortosa ahachete

View GitHub Profile
@ahachete
ahachete / fetch_unpack_latest_postgres_container_image_dockerhub.sh
Created March 27, 2024 00:18
A simple script to demonstrate how to fetch and unpack a container image from a registry. Used here with the latest version of the Postgres image
#!/bin/sh
TOKEN=$( curl -s "https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/postgres:pull" \
| jq -r .token )
MANIFEST_INDEX=$( curl -s -H "Authorization: Bearer $TOKEN" \
https://registry-1.docker.io/v2/library/postgres/manifests/latest )
AMD64_MANIFEST_DIGEST=$( echo $MANIFEST_INDEX \
|jq -r '.manifests[] | select(.platform.architecture == "amd64") .digest' )

Keybase proof

I hereby claim:

  • I am ahachete on github.
  • I am ahachete (https://keybase.io/ahachete) on keybase.
  • I have a public key ASAuFf6e-VrTMJzofLvVKSpuaLc0eOnPytwGuPzK5XO3gwo

To claim this, I am signing this object:

SELECT repo.name_s, avg(payload.size_i)
FROM github.events AS events
INNER JOIN github.events_repo AS repo ON (events.did = repo.did)
INNER JOIN github.events_payload AS payload ON (events.did=payload.did)
WHERE events.type_s = 'PushEvent' AND payload.size_i > 2
GROUP BY repo.name_s
ORDER BY avg DESC;
WITH distinct_commits AS (
SELECT DISTINCT repo.name_s, actor.login_s
FROM github.events AS events
INNER JOIN github.events_actor AS actor ON (events.did = actor.did)
INNER JOIN github.events_repo AS repo ON (events.did = repo.did)
WHERE events.type_s = 'PushEvent'
)
SELECT name_s, count(*)
FROM distinct_commits
GROUP BY name_s
SELECT action_s, count(*)
FROM github.events_payload
WHERE action_s IS NOT NULL
GROUP BY action_s
ORDER BY count DESC;
SELECT events.type_s, count(*)
FROM github.events AS events
JOIN github.events_actor AS actor ON (events.did = actor.did)
GROUP BY type_s
ORDER BY count DESC;
SELECT type_s, count(*)
FROM github.events
GROUP BY type_s
ORDER BY count desc;
SELECT repo.name_s, count(*)
FROM github.events AS events
INNER JOIN github.events_repo AS repo ON (events.did = repo.did)
INNER JOIN github.events_payload AS payload ON (events.did=payload.did)
WHERE events.type_s = 'IssuesEvent' AND payload.action_s = 'opened'
GROUP BY repo.name_s
ORDER BY count desc;
db.events.aggregate(
[
{ $match: { "type": "PushEvent", "payload.size": { $gt : 2 } } },
{ $group: { _id: "$repo.name", avg: { $avg: "$payload.size" } } },
{ $sort: { avg: -1 } }
],
{ allowDiskUse: true, cursor: { batchSize: 100000000 } }
);
db.events.aggregate(
[
{ $match: { "type": "PushEvent" } },
{ $project: { "repo.name": 1, "actor.login": 1 } },
{ $group:
{
_id: "$repo.name",
actor: { $first: "$actor.login"},
count: { $sum: 1 }
}