Skip to content

Instantly share code, notes, and snippets.

@DMRobertson
DMRobertson / parse.py
Created December 17, 2021 18:30
dirty script to ingest synapse request logs into sqlite
#! /usr/bin/env python3
import argparse
import re
import sqlite3
import sys
# Sorry everyone.
# Use nongreedy matches to make this well fast.

The Freenode resignation FAQ, or: "what the fuck is going on?"

IMPORTANT NOTE:

It's come to my attention that some people have been spamming issue trackers with a link to this gist. While it's a good idea to inform people of the situation in principle, please do not do this. By all means spread the word in the communities that you are a part of, after verifying that they are not aware yet, but unsolicited spam is not helpful. It will just frustrate people.

Update 3 (May 24, 2021)

A number of things have happened since the last update.

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
this.EXPORTED_SYMBOLS = [ 'ConversationStatusUtils' ];
const {Services} = ChromeUtils.import("resource:///modules/imServices.jsm");
const CHAT_TAB_HIDDEN_TOPIC = "chat-tab-hidden";
const CHAT_TAB_SHOWN_TOPIC = "chat-tab-shown";
@ara4n
ara4n / perl.md
Last active July 16, 2021 09:49
Everything you need to know about Perl5

I once wrote one of these before for @NegativeMjark but I think I lost it. So here's another.

All you need to know is:

  • $foo is a scalar (i.e. a single dimensional variable)
  • @foo is an array. $foo[n] is the element of an array.
  • %foo is a hash. $foo{'moo'} aka $foo{moo} is the value in the hash for key 'foo'.
  • \ is the reference operator. it returns a scalar which points to the address of the variable (like & in C).
  • (1, 2, 3) is a list. (an array is a variable which contains a list).
  • [1, 2, 3] (rarely: \(1,2,3)) is a reference to a list - aka arrayref
  • $foo->[n] gives an element of an arrayref
@mhoye
mhoye / gist:0babc7ab327551dabab930279da1a4a4
Created April 7, 2017 23:53
A Python routine to build a fake httplib2.Response object out of a Requests object, two bottlecaps and some twine.
def fakeResponse(req):
""" Replacing httplib2 with Requests without rewriting the planet (har har)
means that we need to assemble a fake Response object out of the header set
returned by a Request. Shenanigans ahead. """
import httplib2
info = dict()
info['status'] = 200
fake = httplib2.Response(info)
@amacneil
amacneil / json.py
Last active March 18, 2021 03:24
Safely JSON-encode objects in your Django template
from django.core.serializers.json import DjangoJSONEncoder
from django.template import Library
from json import dumps as json_dumps
register = Library()
@register.filter
def json(data):
"""

CVE-2015-7547 mitigation script

In response to CVE-2015-7547, we are developing this Lua script which should protect your users, at a slight risk of disrupting specific queries which naturally deliver very large responses.

Run the script below by setting: lua-dns-script=stop-cve-2015-7547.lua - or use rec_control reload-lua-script stop-cve-2015-7547.lua at runtime.

Please continue to check this page for updates.

function postresolve ( remoteip, domain, qtype, records, origrcode )
@tylerneylon
tylerneylon / learn.lua
Last active April 28, 2024 22:23
Learn Lua quickly with this short yet comprehensive and friendly script. It's written as both an introduction and a quick reference. It's also a valid Lua script so you can verify that the code does what it says, and learn more by modifying and running this script in your Lua interpreter.
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------
@netj
netj / memusg
Last active January 29, 2024 15:04
memusg -- Measure memory usage of processes
#!/usr/bin/env bash
# memusg -- Measure memory usage of processes
# Usage: memusg COMMAND [ARGS]...
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2010-08-16
############################################################################
# Copyright 2010 Jaeho Shin. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #