Skip to content

Instantly share code, notes, and snippets.

View dznz's full-sized avatar

Daniel Zollinger dznz

  • free agent
  • Auckland, New Zealand
  • X @dznz
View GitHub Profile
@dznz
dznz / The_smollest_issue.md
Last active November 18, 2022 05:00
Incident report regarding smollestbunny @ mastodon.nz

My incident report regarding smollestbunny @ mastodon.nz

As I speak, mastodon.nz is up to 7.5k active accounts. That's bananas, crazy numbers, for a server that a few weeks ago had an order of magnitude fewer folks. I tender my heartfelt congratulations to the admins and moderators of the server; what a wild ride!

It does mean that mastodon.nz is now easily the single biggest host of the NZTwit community, and this confers hefty moderation responsibilities on a team that has expanded quickly to meet its needs. A volunteer team, mind you, motivated not by money or glory but by an interest in growing and supporting a community. Unpaid, and during their free time.

At the best of times, moderation isn't easy. Actually, mostly it sucks. Besides the day-to-day noise of defederating from openly fascistic servers, and dealing with the crappy flotsam that drifts in from the fediverse, there's the community itself. Everyone's always stepping on each others' toes, and often there's not a way to adjudicate i

@dznz
dznz / oti-openapi.yaml
Created January 31, 2019 23:53
DIA OTI Swagger definition draft
openapi: 3.0.0
info:
description: API Spec for OTI
termsOfService: /tos
title: OTI API
version: 0.0.1
components:
securitySchemes:
api_key:
type: http
@dznz
dznz / gist:daab53a4343d4b00c3d361a798201564
Created July 7, 2016 05:31
From the codewars functional list kata - an immutable linked list with efficient operations.
function List() {}
function EmptyList() {}
EmptyList.prototype = new List();
EmptyList.prototype.constructor = EmptyList;
EmptyList.prototype.toString = function() { return "()"; };
EmptyList.prototype.isEmpty = function() { return true; };
EmptyList.prototype.length = function() { console.log('length 0'); return 0; };
EmptyList.prototype.push = function(x) { return new ListNode(x, this); };
@dznz
dznz / gist:64a34466f44d1a335e75
Created October 29, 2015 22:40
Extract the filename from a path in Excel or Google spreadsheet
=TRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",100)),99))
@dznz
dznz / simple_decorator.rb
Created October 27, 2015 03:33
Simple decorator example
require 'delegate'
class SimpleDecorator < SimpleDelegator
attr_reader :context
def initialize(raw, view_context = nil)
@context = view_context if view_context
super raw
end
@dznz
dznz / gist:e890a35259271f89a118
Created May 5, 2015 22:36
Using array operations to simplify conditional complexity
def build_date_filter(earliest_date, latest_date)
return '' if !earliest_date && !latest_date
latest_date_query = "publicationDate > #{earliest_date}" if earliest_date
earliest_date_query = "publicationDate < #{latest_date}" if latest_date
if latest_date_query && earliest_date_query
"(#{latest_date_query} AND #{earliest_date_query})"
else
latest_date_query ? latest_date_query : earliest_date_query
end
end
@dznz
dznz / gist:4e1bcb3068469297cc32
Created December 4, 2014 23:26
Extracting Workflows with DCI - Link Dump
@dznz
dznz / gist:f9dcd594427aa31f6d8f
Created October 10, 2014 01:26
Set up a read-only user in Postgresql
CREATE ROLE readonly LOGIN PASSWORD 'some_pass';
-- Existing objects
GRANT CONNECT ON DATABASE the_db TO readonly;
GRANT USAGE ON SCHEMA public TO readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO readonly;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO readonly;
-- New objects
ALTER DEFAULT PRIVILEGES FOR owner_user IN SCHEMA public GRANT SELECT ON TABLES TO readonly;
ALTER DEFAULT PRIVILEGES FOR owner_user IN SCHEMA public GRANT SELECT ON SEQUENCES TO readonly;
@dznz
dznz / rubocop.yml
Created September 18, 2014 04:04
My preferred Rubocop setup.
AllCops:
Excludes:
- setup_environment.rb
# Prefer a comma at the end of a multiline, to minimise diff changes and
# enable easier rearranging of lines.
TrailingComma:
EnforcedStyleForMultiline: comma
# Experimenting with the idea of having the `private`, `protected`
@dznz
dznz / gist:8552522
Last active December 16, 2020 09:15
Two different ways to plug in a simple Warden failure app to a Rails project.
##
# Simple Warden configuration, complex "controller"
# In config/initializers/warden.rb
Rails.application.config.middleware.use Warden::Manager do |manager|
manager.failure_app = UnauthorizedController
end
# app/controllers/unauthorized_controller.rb
class UnauthorizedController < ActionController::Metal