Skip to content

Instantly share code, notes, and snippets.

@jhass
jhass / mod_auth_diaspora.lua
Last active March 15, 2018 13:14
Prosody authentication for Diaspora. Tested with Prosody 0.9.4. See https://wiki.diasporafoundation.org/Integration/XMPP/Prosody
-- Based on Simple SQL Authentication module for Prosody IM
-- Copyright (C) 2011 Tomasz Sterna <tomek@xiaoka.com>
-- Copyright (C) 2011 Waqas Hussain <waqas20@gmail.com>
--
-- 25/05/2014: Modified for Diaspora by Anahuac de Paula Gil - anahuac@anahuac.eu
-- 06/08/2014: Cleaned up and fixed SASL auth by Jonne Haß <me@jhass.eu>
-- 22/11/2014: Allow token authentication by Jonne Haß <me@jhass.eu>
local log = require "util.logger".init("auth_diaspora")
local new_sasl = require "util.sasl".new
{
"Antigua and Barbuda" : 90604,
"United Kingdom" : 63375707,
"China" : 1391193266,
"St. Lucia" : 183292,
"Netherlands" : 16790052,
"Tuvalu" : 9888,
"Iraq" : 34419098,
"Cambodia" : 15312752,
"Canada" : 35417147,
@jhass
jhass / diaspora_spam.rb
Last active February 14, 2022 09:43
Deletes spam comments, posts and local spam accounts. Place into Diasporas root, edit and run. Don't forget to set necessary environment variables.
#!/usr/bin/env ruby
# List of spam accounts
spam_accounts = %w(spamacc@podA spamacc@podB spamacc@mypod)
# Delete comments even if spammer isn't a local user or spam isn't on a
# local users account.
# And delete posts of users in spam_accounts that aren't local.
always_delete = true
@jhass
jhass / scan_pods_for_ssl.rb
Last active January 4, 2016 18:09
Quick'n' dirty script for checking status on SSL deployment in the diaspora* network
#!/usr/bin/env ruby
# Run from Diaspora root
# Requires https://github.com/DinoTools/sslscan/ (this fork) (https://aur.archlinux.org/packages/sslscan-git/)
class Scanner
def initialize host, statistics
@host = host
@statistics = statistics
run
end
@jhass
jhass / Gemfile
Last active August 7, 2017 14:03
Simple rack redirect app
source "https://rubygems.org"
ruby "2.0.0"
gem 'rack'
gem 'puma'
group :development do
gem 'foreman'
end
@jhass
jhass / dump_socket.sh
Last active March 6, 2024 19:32
Capture unix socket to pcap file with socat and tshark
#!/bin/bash
# Parameters
socket="/run/foo.sock"
dump="/tmp/capture.pcap"
# Extract repetition
port=9876
source_socket="$(dirname "${socket}")/$(basename "${socket}").orig"
@jhass
jhass / sidekiq.rake
Last active December 14, 2015 07:29
Sidekiq stats printer
require 'sidekiq/api'
namespace :sidekiq do
def print_stats
stats = Sidekiq::Stats.new
[:processed, :failed, :enqueued, :scheduled_size, :retry_size].each do |stat|
puts "sidekiq.#{stat} #{stats.send(stat)}"
end
puts "sidekiq.busy #{Sidekiq.redis { |con| con.scard("workers") }}"
end
@jhass
jhass / append.sh
Last active April 12, 2021 10:57
My public SSH key
echo -e "\n$(curl -L https://gist.github.com/jhass/66f02fe5044fa720c623/raw/cert-authority.pub)\n" >> ~/.ssh/authorized_keys
@jhass
jhass / me@mrzyx.de.asc.txt
Last active December 10, 2015 11:49
PGP key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2.0.22 (GNU/Linux)
mQENBE7I+ZUBCAC1zez5X2Y4zFbslYAobm4VX3jxV9gfAmN8rF6CM4cvGzcuy4+a
woRDXXu016QH3v/pnSSn9neWGNm4HULNiAl3gxIjhBvZcyiVV5eiDQaxLENZrjYb
BW0YtseVwWBmwD3mEyA7eRz81rzgldvUbQmh9DEEl0ZJf8tsQWGrQQB7g10bdRVp
X2P/KSYsoodDEiF+XDfSPKrzAZoqxa/mSZFCQeyThsvSyTa8baSvDA5iHm/p4MPn
Pa0Aki6QYLgYkGo5wFbrPENV7wToMiNOzg21mYdKouaijAC592CqWi1XSQE8nIEq
NppX+uI2jazH3EqFNviuyFKyw9fGYInHYHWrABEBAAG0GEpvbm5lIEhhw58gPG1l
QG1yenl4LmRlPohGBBARAgAGBQJQ42hSAAoJEOpqsNjng4LhbX8An1qLlq1b/5uA
#!/usr/bin/env ruby
ENV['RAILS_ENV'] ||= "production"
require 'rubygems'
require 'ansi_colors'
require './config/environment'
#user = User.find_by_username("mrzyx")
#handles = user.contacts.collect { |c| c.person.diaspora_handle }
handles = Person.all.collect { |person| person.diaspora_handle }