Skip to content

Instantly share code, notes, and snippets.

View patrickdevivo's full-sized avatar

Patrick DeVivo patrickdevivo

View GitHub Profile
{
"__inputs": [
{
"name": "DS_MERGESTAT_INTERNAL",
"label": "MergeStat Internal",
"description": "",
"type": "datasource",
"pluginId": "postgres",
"pluginName": "PostgreSQL"
}
@patrickdevivo
patrickdevivo / yaml_to_json_pg_pl_v8.sql
Created February 25, 2023 02:26
Example of parsing YAML (by converting it to JSONB) in PostgreSQL
-- enable plv8 extension
CREATE EXTENSION plv8;
-- define plv8_yaml_to_json() UDF using implementation from: https://github.com/nodeca/js-yaml
CREATE OR REPLACE FUNCTION plv8_yaml_to_json(yaml_input TEXT) RETURNS JSONB AS $$
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */ function isNothing(e){return null==e}function isObject(e){return"object"==typeof e&&null!==e}function toArray(e){return Array.isArray(e)?e:isNothing(e)?[]:[e]}function extend(e,t){var n,r,o,a;if(t)for(n=0,r=(a=Object.keys(t)).length;n<r;n+=1)e[o=a[n]]=t[o];return e}function repeat(e,t){var n,r="";for(n=0;n<t;n+=1)r+=e;return r}function isNegativeZero(e){return 0===e&&Number.NEGATIVE_INFINITY===1/e}var isNothing_1=isNothing,isObject_1=isObject,toArray_1=toArray,repeat_1=repeat,isNegativeZero_1=isNegativeZero,extend_1=extend,common={isNothing:isNothing_1,isObject:isObject_1,toArray:toArray_1,repeat:repeat_1,isNegativeZero:isNegativeZero_1,extend:extend_1};function formatError(e,t){var n="",r=e.reason||"(unknown reason)";re

Accessing the GitHub API via MySQL

Uses mergestat to access the GitHub API and go-mysql-server.

Currently, only stargazers table is available. GitHub token used is from a "bot" account. Hosted on Fly.

Username: root Password: github

SELECT
name, primary_language,
github_repo_file_content('google', name, 'go.mod') as go_mod
FROM github_org_repos('google')
WHERE primary_language = 'Go'
SELECT
count(*),
substr(author_email, instr(author_email, '@')+1) AS email_domain -- https://sqlite.org/lang_corefunc.html
FROM commits
WHERE parent_count < 2 -- ignore merge commits
GROUP BY email_domain
ORDER BY count(*) DESC
@patrickdevivo
patrickdevivo / README.md
Last active October 7, 2020 12:28
Contributor email domain distributions

Contributors by Email Domain

AskGit is a tool looking for more (interesting) use cases. This gist takes a look at the email domains of contributors to two major open source code bases (Linux and Kubernetes). askgit-query.sql can be piped into the askgit command to produce the output in k8s-SHA.txt and linux-SHA.txt

  • Commit Count is the total number of commits by contributors with an email address from Domain
  • Unique Emails is the number of unique contributors with an email from Domain
  • Domain is the email domain

Using gitqlite, query for percentage of commit count by author (in this case in facebook/react). Limit to top 25, include a "chart"

_nnnn_
dGGGGMMb ,""""""""""""""""""""""""""""".
@p~qp~~qMb | // TODO make this better 🎉 |
M|@||@) M| _;.............................'
@,----.JM| -'
JS^\__/ qKL
dZP qKRb
dZP qKKb
fZP SMMb
HZM MMMM
const names = ["world", "patrick", "deno", "adhoc"]
names.forEach(n => console.log(`hello, ${n}!`))
@patrickdevivo
patrickdevivo / b
Created November 2, 2017 13:55
blockstack verify
Verifying my Blockstack ID is secured with the address 1NKAeaGUag7tpGxpy6unSrAWRZhXJe5JQx https://explorer.blockstack.org/address/1NKAeaGUag7tpGxpy6unSrAWRZhXJe5JQx