Skip to content

Instantly share code, notes, and snippets.

View richvdh's full-sized avatar
💭
I may be slow to respond.

Richard van der Hoff richvdh

💭
I may be slow to respond.
View GitHub Profile
@richvdh
richvdh / sync.json
Last active November 13, 2015 11:26
sync changes
"rooms": {
"joined": {
"!726s6s6q:example.com": {
"state": {
"m.room.member": {
"@alice:example.com": {
"sender": "@alice:example.com",
"type": "m.room.member",
"state_key": "@alice:example.com",
"content": {"membership": "join"},
allOf:
- $ref: 'pet.yaml'
type: object
properties:
laziness:
type: integer
format: int64
#!/usr/bin/env python
import hashlib
import hmac
user = "esouvbh"
password = "souvik"
admin = False
key="shared_secret"
$ tail -c +600000000 synapse/var/homeserver.log | grep aaron:matrix | grep send | cut -f 1,2,17-19 -d ' '
2017-01-31 14:53:45,930 Processed request: 173ms
2017-01-31 15:01:43,250 Processed request: 146ms
2017-01-31 15:12:12,502 Processed request: 28ms
2017-01-31 15:28:53,294 Processed request: 1516ms
2017-01-31 15:54:48,933 Processed request: 32ms
2017-01-31 17:06:45,747 Processed request: 88ms
2017-01-31 17:24:56,666 Processed request: 737ms
2017-01-31 18:22:16,995 Processed request: 20ms
2017-01-31 18:24:33,059 Processed request: 121ms
@richvdh
richvdh / log_config.yaml
Created February 17, 2017 12:34
Example synapse log config
# Example log_config file for synapse. To enable, point `log_config` to it in
# `homeserver.yaml`, and restart synapse.
#
# This configuration will produce similar results to the defaults within
# synapse, but can be edited to give more flexibility.
version: 1
formatters:
fmt:
@defer.inlineCallbacks
def test():
with LoggingContext("TEST") as x:
x.request = "TEST"
yield test_handler()
@defer.inlineCallbacks
def test_handler():
deferreds = [do_stuff(x) for x in ["bob", "chris"]]
yield preserve_context_over_deferred(defer.gatherResults(deferreds))
@richvdh
richvdh / dd.pl
Created October 13, 2017 15:38
Data::Dump modifies its input
use JSON qw(encode_json);
use Data::Dump qw(dd);
my $a = [1];
my $before = encode_json($a);
dd($a);
my $after = encode_json($a);
die "$before ne $after" if $before ne $after;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------
Hash Join (cost=21617.99..45328.86 rows=1 width=29)
Hash Cond: ((m.event_id = c.event_id) AND (m.user_id = c.state_key))
-> Bitmap Heap Scan on room_memberships m (cost=236.36..23882.12 rows=3255 width=94)
Recheck Cond: (room_id = '!mWtzDejxeIoLEirXEV:matrix.org'::text)
Filter: (membership = 'join'::text)
-> Bitmap Index Scan on room_memberships_room_id (cost=0.00..235.54 rows=6264 width=0)
Index Cond: (room_id = '!mWtzDejxeIoLEirXEV:matrix.org'::text)
-> Hash (cost=21288.29..21288.29 rows=6223 width=85)
@richvdh
richvdh / events
Last active January 18, 2018 19:13
matrix=# select to_timestamp(received_ts/1000),type from events where room_id='!PVNuPWbpXKukMcpzUY:t2bot.io' and stream_ordering >= 407442057;
to_timestamp | type
------------------------+----------------
2018-01-18 18:51:51+00 | m.room.message
2018-01-18 18:51:55+00 | m.room.message
2018-01-18 18:52:35+00 | m.room.message
2018-01-18 18:52:40+00 | m.room.message
2018-01-18 18:53:06+00 | m.room.message
2018-01-18 18:54:00+00 | m.room.message
# vim:ft=yaml
# Slave configuration
worker_app: synapse.app.media_repository
# The replication listener on the synapse to talk to.
worker_replication_url: http://127.0.0.1:9092/_synapse/replication
worker_replication_host: 127.0.0.1
worker_replication_port: 9111