Skip to content

Instantly share code, notes, and snippets.

@sigmaris
sigmaris / Enabling-LDAP-logins.md
Last active March 3, 2018 19:17
Enabling LDAP logins for Mastodon

Enabling LDAP logins

Follow this guide to use LDAP for external authentication of users. When a user logs in to the Mastodon instance, their username and password will be verified by authenticating (binding) to an LDAP server. If a user exists in the LDAP directory and logs in to the Mastodon instance for the first time, a user account will be auto-created on the Mastodon instance for them.

Installing LDAP support

First, install the gem(s) required for LDAP support, by running bundle install with the LDAP_ENABLED environment variable set to true:

LDAP_ENABLED=true bundle install
@sigmaris
sigmaris / textlint.py
Last active August 18, 2017 12:03
Linter for any plain text files
#!/usr/bin/env python
import argparse
import fnmatch
import os
import re
import sys
MIXED_TABS_SPACES = re.compile(r"^\t* +(\t+)")
TRAILING_WHITESPACE = re.compile(r"(.*)([ \t\r\f\v]+)$")
#!/bin/bash
IF=en0
MAC=`python << EOF
import random
print ":".join("%02X"%x for x in (random.randint(0, 255) for _ in range(6)))
EOF
`
echo "resetting wifi on $IF, rotating mac $MAC"
scselect -n
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -z
@sigmaris
sigmaris / remoteedit.sh
Created January 16, 2014 11:19
Send rmate bash script to a remote server and run it using bash on a file. Usage: remoteedit.sh user@remotehost /remote/file/name
#!/bin/bash
rmate_name="/tmp/rmate-$RANDOM.sh"
ssh "$1" "cat >> $rmate_name" <<'ENDRMATESCRIPT'
# rmate
# Copyright (C) 2011-2013 by Harald Lapp <harald@octris.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@sigmaris
sigmaris / gist:3601965
Created September 2, 2012 17:32
Example (insecure!) Puppet Dashboard nginx config
server {
listen 80;
server_name dashboard.example.com;
passenger_enabled on;
access_log /var/log/nginx/puppet-dashboard_access.log;
error_log /var/log/nginx/puppet-dashboard_error.log;
root /usr/share/puppet-dashboard/public;
@sigmaris
sigmaris / puppetmaster.conf
Created September 2, 2012 15:12
Example Puppetmaster nginx config
server {
listen 8140 ssl;
server_name puppet.example.com;
passenger_enabled on;
passenger_set_cgi_param SSL_CLIENT_S_DN $ssl_client_s_dn;
passenger_set_cgi_param SSL_CLIENT_VERIFY $ssl_client_verify;
access_log /var/log/nginx/puppet_access.log;
error_log /var/log/nginx/puppet_error.log;
@sigmaris
sigmaris / rsyncwatch.py
Created December 23, 2011 17:22
Watch a directory for filesystem events, and rsync individually changed files to a remote path
#!/usr/bin/env python
# requires the "MacFSEvents" package
import fsevents
import time
import sys
import os
import subprocess
observer = fsevents.Observer()
@sigmaris
sigmaris / upgrade_dka.py
Created July 23, 2011 23:02
Upgrade/Install script for devkitARM, libnds, etc
#!/usr/bin/python
import feedparser
import json
import re
import urllib
import tempfile
import subprocess
import os
LIBS = ['libnds','filesystem','libfat','dswifi','maxmod','default_arm7']
@sigmaris
sigmaris / cookie.py
Created March 26, 2011 21:48 — forked from justquick/cookie.py
Use cookies for all session storage in Django. This version uses HMAC to verify the integrity of the cookie, and raises SessionTooBig if the session is too large to fit in a cookie.
>>> def f1(y):
... return set(x for x in y)
...
>>> def f2(y):
... return {x for x in y}
...
>>> dis.dis(f1)
2 0 LOAD_GLOBAL 0 (set)
3 LOAD_CONST 1 (<code object <genexpr> at 0x10abecd30, file "<stdin>", line 2>)
6 MAKE_FUNCTION 0