Skip to content

Instantly share code, notes, and snippets.

View mackuba's full-sized avatar
🌤️
Playing with Bluesky API

Kuba Suder mackuba

🌤️
Playing with Bluesky API
View GitHub Profile
@mackuba
mackuba / munin-cgi.service
Created June 4, 2024 23:06
Munin CGI configuration to allow zooming in charts
[Unit]
Description=Munin graph CGI
After=network.target syslog.target
[Service]
Type=simple
User=root
ExecStart=/usr/bin/spawn-fcgi -n -s /var/run/munin/fastcgi-graph.sock -u www-data /usr/lib/munin/cgi/munin-cgi-graph
TimeoutSec=15
Restart=on-failure
@mackuba
mackuba / joes_bridgy.rb
Created May 22, 2024 21:53
Find Joe's follows who opted in to Bridgy
#!/usr/bin/env ruby
## gem install minisky
require 'minisky'
sky = Minisky.new('api.bsky.app', nil, progress: '.')
joe_follows = sky.fetch_all('app.bsky.graph.getFollows', { actor: 'mergesort.me', limit: 100 }, field: 'follows')
ap_followers = sky.fetch_all('app.bsky.graph.getFollowers', { actor: 'ap.brid.gy', limit: 100 }, field: 'followers')
@mackuba
mackuba / bluesky_events
Last active January 28, 2024 22:09
Munin configuration files
#!/bin/sh
if [ "$1" = "config" ]; then
echo "graph_title Bluesky firehose events"
echo "graph_category bluesky"
echo "graph_vlabel Events per second"
echo "graph_args --base 1000 -l 0"
echo "events.label Events"
echo "events.type DERIVE"
echo "events.min 0"
@mackuba
mackuba / firehose.rake
Created January 4, 2024 15:46
Downloading bsky firehose events to a file and streaming them from a mock server
require 'skyfall'
AVG_EVENTS_PER_SEC = 50
desc "Download a part of the firehose cache to a file"
task :fetch do
current_head = nil
sky = Skyfall::Stream.new(ENV['FIREHOSE'] || 'bsky.network', :subscribe_repos)
sky.on_message do |m|
@mackuba
mackuba / proper_way.rb
Created November 11, 2023 23:45
Bluesky login with federation
# "proper" way, more future- and federation-proof
handle = form.get('handle')
password = form.get('password')
if dns_record = lookup_dns("_atproto.#{handle}")
did = did_from_dns(dns_record)
elsif res = open_url("https://#{handle}/.well-known/atproto-did")
did = did_from_well_known(res)
else
@mackuba
mackuba / bsky-hashtags.json
Last active June 14, 2024 20:56
Statistics of most popular hashtags on Bluesky in the last 30 days (2.6% of all posts include a hashtag)
{
"#art": 31687,
"#furryart": 21517,
"#furry": 20375,
"#nsfw": 12831,
"#1": 4572,
"#ListenToBlackVoices": 4341,
"#fursuit": 3950,
"#FogosPT": 3921,
"#ttrpg": 3378,
@mackuba
mackuba / bluesky_loader.rb
Last active July 3, 2023 23:01
Ruby script which loads posts from your Bluesky home feed and saves them to a local file
#!/usr/bin/env ruby
# Created by Kuba Suder on 25/04/2023
# Licensed under WTFPL License
require 'json'
require 'net/http'
require 'open-uri'
require 'set'
require 'time'
@mackuba
mackuba / Bluesky.swift
Created April 24, 2023 14:58
Basic Swift code to log in and send a post to Bluesky
//
// Bluesky.swift
// Created by Kuba Suder on 24/04/2023.
// Licensed under WTFPL License
//
import Foundation
struct LoginData: Encodable {
let identifier: String
@mackuba
mackuba / core_data_wwdc.json
Last active May 5, 2024 16:03
List of all WWDC talks about Core Data since 2010
[
{
"id": "wwdc2010-118",
"title": "Mastering Core Data",
"description": "Core Data contains a vast set of advanced features to help you better manage your data and evolve your application over time. Master the techniques for working with data in your application, from being more efficient to doing more in the database and changing how you store your data over time. Take your Core Data knowledge to the next level.",
"links": [
[
"HD",
"https://developer.apple.com/devcenter/download.action?path=/videos/wwdc_2010__hd/session_118__mastering_core_data.mov"
],
@mackuba
mackuba / creating_toolbar_buttons.md
Last active January 21, 2024 13:36
How to create toolbar buttons in AppKit

Creating toolbar buttons

Recently I was writing a post about NSButton styles on my blog, and when I got to the part about toolbar buttons (Textured Rounded), I realized that I actually had no idea how to create a toolbar in AppKit, so I had to do some research first. I found some help in this sample project from Apple and this project on GitHub, and then I did some experiments with different combinations of things to see what works where.

This could probably be a whole separate blog post on its own (and maybe I'll make this into one), but for now I've put it here to not make that main article even longer.

Here's what I've found:

There are a few different kinds of buttons you can put in the toolbar: