Skip to content

Instantly share code, notes, and snippets.

View Gargron's full-sized avatar

Eugen Rochko Gargron

View GitHub Profile
@tateisu
tateisu / deletePosts.md
Last active February 24, 2019 05:40
Removing local copies of unreferenced external posts

Removing local copies of unreferenced external posts

日本語 => https://gist.github.com/tateisu/3d98290f2b72d12ba5f1b977a0d5743c

Summary

SQL exapmle that deletes local copies of external posts flowing from the FTL or relays and that are not referenced long time by local users.

Note: It is "reduction" of data increase , not "to be able to operate infinitely with a fixed disk capacity".

@j-a4
j-a4 / email_mx_validator.rb
Last active May 25, 2018 19:23
Email MX validator for Mastodon
# Validates that MX record exists for domain to prevent typos and also block by MX servers
# Use by adding to app/models/user.rb
# validates_with EmailMXValidator, if: :email_changed?
# frozen_string_literal: true
require 'resolv'
class EmailMXValidator < ActiveModel::Validator
def validate(user)
domain = user.email.split('@', 2).last
mxs = Resolv::DNS.new.getresources(domain, Resolv::DNS::Resource::IN::MX).to_a.map { |e| e.exchange.to_s }
@nolanlawson
nolanlawson / mastodon_backup.sh
Last active December 23, 2022 21:06
Script to back up a Mastodon instance (for non-dockerized installs)
#!/usr/bin/env bash
#
# Make a backup file of a Mastodon instance. The backup file is a TGZ containing
# the Postgres dump as well as the /public/system (media) files and the
# .env.production file. For loading the dump file contents, see:
# https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Migration-guide.md
#
# Usage: ./mastodon_backup.sh my_dump_file.tgz
#
# Advanced usage: MASTODON_LIVE_DIRECTORY=/path/to/live ./mastodon_backup.sh my_dump_file.tgz
@tingley
tingley / README.md
Created April 4, 2017 22:03 — forked from ceejbot/README.md
How I set up a mastodon instance on AWS with ansible on ubuntu trusty
  1. Register a domain name. Buy a cert for it.
  2. Spin up Ubuntu Trusty 14.04 on AWS & point DNS at the instance. Don't bother making user accounts or anything; only somebody with your key should be able to ssh in. Add security group rules allowing https from anywhere, or maybe http if you want to redirect.
  3. Make an EBS volume or raid up some instance stores and mount them on /mnt/mastodon, owned by ubuntu.
  4. Download all the files in this gist to your local controlling host, e.g., your laptop.
  5. Make a file named inventory with [general]\nyour-host.tld in it.
  6. Put all of the *.conf files in this gist into a subdirectory named files.
  7. Put your certs somewhere in the directory & make sure the ansible playbook services.yml is pointing to them.
  8. Run ansible-playbook -i inventory host-setup.yml
  9. Run ansible-playbook -i inventory mastodon.yml
  10. you might get ruby 2.3.3 instead of 2.3.1 in which case you should just edit the Gemfile.

Auto Synchronized Backups with Bittorrent sync & a vps

1. Cloud syncing on the cheap

Two awsome things were released yesterday :

Compare this to the pricing of : dropbox pro

@tonious
tonious / hash.c
Last active February 17, 2023 02:25
A quick hashtable implementation in c.
/* Read this comment first: https://gist.github.com/tonious/1377667#gistcomment-2277101
* 2017-12-05
*
* -- T.
*/
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <stdlib.h>
#include <stdio.h>
@luciferous
luciferous / broadcast.html
Created November 6, 2011 11:13
WebSocket Radio!
<!doctype html>
<html><head>
<script type="text/javascript" src="Microphone/swfobject.js"></script>
<script type="text/javascript" src="ulaw.js"></script>
<script type="text/javascript" src="Microphone/microphone.js"></script>
<script type="text/javascript" src="sockjs-0.1.min.js"></script>
<script type="text/javascript">
Microphone.debug = true;
bsock = new SockJS("/broadcast");
Microphone.initialize({ swfLocation: "Microphone/MicrophoneMain.swf" });
@eculver
eculver / APPNAME
Created July 5, 2011 17:35 — forked from shimondoodkin/APPNAME
init.d script for node.js for debian
#! /bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
@atmos
atmos / lojack-proxy.god.rb
Created November 13, 2010 03:05
god configs for camo.
God.watch do |w|
w.uid = "git"
w.gid = "git"
w.name = "camo"
w.pid_file = "/data/camo/tmp/camo.pid"
w.interval = 30.seconds
w.env = {
"PORT" => '8080',
"CAMO_KEY" => '0x24FEEDFACEDEADBEEFCAFE'