Skip to content

Instantly share code, notes, and snippets.

@judell
judell / find-followers-and-follows-not-on-lists.sql
Created December 6, 2022 02:58
find followers and follows not on lists
with data as (
select
l.title as list,
a.*
from
mastodon_list l
join
mastodon_list_account a
on
l.id = a.list_id
@judell
judell / rendering-html-in-dashboard-tables.md
Last active December 2, 2022 06:58
rendering-html-in-dashboard-tables

Rendering HTML in dashboard tables

The Mastodon API returns HTML which dashboards display raw. The Mastodon plugin deals with that by stripping HTML tags which is minimally OK but not great. Here is rough go at a way to enable HTML to render in table cells.

Code

In ~/steampipe/ui/dashboard/src/components/dashboards/Table/index.tsx:

Add these imports:

@judell
judell / join-on-native-vs-jsonb-column.md
Last active December 2, 2022 02:00
join-on-native-vs-jsonb-column

Joining to a JSONB column vs a native Postgres column

Tables involved are mastodon_notification and mastodon_relationship.

The JSONB column case

Originally the plugin provided only the JSONB column mastodon_notification.account. So the join I was looking for was from a field of that JSONB column, mastodon_notification.account'->>'id', to a corresponding native column mastodon_relationship.id.

This is the query plan.

@judell
judell / deployment-table.md
Last active November 22, 2022 04:16
deployment-table

new method

func listDeployment(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
	conn, err := connect(ctx, d)
	if err != nil {
		plugin.Logger(ctx).Error("vercel_deployment.listDeployment", "connection_error", err)
		return nil, err
	}
@judell
judell / explore-steampipe-cache-ttl.md
Last active November 4, 2022 21:18
explore-steampipe-cache-ttl

A query to cache (or not), should take ~1 (or ~10) secs.

with hn_ids as (
  select generate_series(1, 100) as id
),
hn_urls as (
  select
    'https://hacker-news.firebaseio.com/v0/item/' || h.id || '.json' as hn_api_url
 from
@judell
judell / bulk-download.md
Created September 18, 2022 10:32
bulk-download.md

I want to be able to leverage Steampipe's parallelism to fetch many items from Hacker News (or other plugins). I observed that although Hacker News implements both List and Get, only List is called in a JOIN context, so there's no opportunity to parallelize.

I made a plugin that (I think) works the same way as HN in this respect: https://github.com/judell/steampipe-plugin-hello. And I'm looking at different ways to make Steampipe employ the Get function.

This is the query result I am hoping for:

with ids as (
  select 1 as id union select 2 order by id
)
@judell
judell / gist:60a13d7f848ba08adc2dd1c6b8748bc8
Last active September 4, 2022 04:45
issue 2414 db log
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7f4b08]
runtime stack:
runtime.throw({0x7f4d0285b2d8?, 0x0?})
/opt/hostedtoolcache/go/1.19.0/x64/src/runtime/panic.go:1047 +0x5f fp=0x7ffddfb88268 sp=0x7ffddfb88238 pc=0x7f4d01db66bf
runtime.sigpanic()
/opt/hostedtoolcache/go/1.19.0/x64/src/runtime/signal_unix.go:819 +0x369 fp=0x7ffddfb882b8 sp=0x7ffddfb88268 pc=0x7f4d01dccfc9
goroutine 17 [syscall, locked to thread]:
@judell
judell / s3-dump.sql
Created August 18, 2022 00:40
s3 dump
--
-- PostgreSQL database dump
--
-- Dumped from database version 14.2
-- Dumped by pg_dump version 14.2 (Ubuntu 14.2-1.pgdg20.04+1+b1)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
@judell
judell / hackernews_single_item.go
Last active July 16, 2022 00:05
hackernews_single_item
package hackernews
import (
"context"
"github.com/PaulRosset/go-hacknews"
"github.com/turbot/steampipe-plugin-sdk/v3/plugin"
)
+----------------+---------------------------------------------------------------+------------------------------------->
| twitter_user | url | text >
+----------------+---------------------------------------------------------------+------------------------------------->
| idealoTech | https://twitter.com/idealoTech/status/1524688985649516544 | Are you able to find creative soluti>
| | | >
| | | Join our @codility Order #API Challe>
| | | >
| | | #idealolife #codility #php >
| idealoTech | https://twitter.com/idealoTech/status