Skip to content

Instantly share code, notes, and snippets.

View hrj's full-sized avatar
πŸ”­
observing

hrj hrj

πŸ”­
observing
View GitHub Profile
@hrj
hrj / notes.md
Last active July 7, 2016 09:42
Notes on setting up synapse federation behind a reverse proxy
  • The certificate file used by the reverse proxy should be exactly the same as the one used by synapse. If you use the concatenated certificate chain on the reverse-proxy, it should be the same in synapse.
  • You need to generate and give Diffie Hellman parameters to the reverse proxy. This ensures that the cipher suites required by matrix are available in the reverse proxy.
  • Matrix servers use the 8448 port to talk with each other by default.
  • Either you need to expose this port (8448) in the firewall, or you need to add a SRV record in the DNS pointing to port 443 (https port).
  • This tool can help diagnose problems.
@hrj
hrj / Compute.java
Last active January 26, 2016 19:14
Benchmarks for doppio
public class Compute {
public static void main(String args[]) {
final long start = System.currentTimeMillis();
final long ans = rep(8000);
final long end = System.currentTimeMillis();
System.out.println(ans);
System.out.println("Time taken (ms): " + (end - start));
}
public static long rep(long n) {
@hrj
hrj / list.md
Created November 24, 2015 03:52
gcc optimisations that remain disabled in -O3

list

-fbranch-probabilities
-fbranch-target-load-optimize
-fbranch-target-load-optimize2
-fbtr-bb-exclusive
-fconserve-stack
-fcx-fortran-rules
-fcx-limited-range
-fdata-sections
@hrj
hrj / huffman.scala
Created October 10, 2015 20:03
huffman estimation
// Huffman estimation given symbol counts
val symbolCountsIn = Array(57728,32858,49395,15703,26381,4506,5797,1129,958,392,164,278,61,206,30,193,19,172,9,150,4,91,4,91,1,71,4,44,2,29,1,28,1,32,0,15,0,8,0,12,0,11,0,15,0,6,0,4,0,0,0,2,0,1,0,2)
case class Symbol(count:Int, idx: Int)
sealed trait TreeNode {
def value:Int
}
@hrj
hrj / symbols.md
Last active October 8, 2015 18:24
flif symbols

Static data

nm --size-sort -S -C -r flif | grep "\<[Rr]\>" 
size               name
----------------------------
0000000000002002 R log4k
0000000000000800 R crc32k_tab
@hrj
hrj / resources.md
Created August 26, 2015 11:27
Programming for kids

Languages designed for learning

@hrj
hrj / shserv.py
Created August 12, 2015 05:44
Multi-threaded server using python
#!/usr/bin/python
import SocketServer
import BaseHTTPServer
import SimpleHTTPServer
class ThreadingSimpleServer(SocketServer.ThreadingMixIn,
BaseHTTPServer.HTTPServer):
pass
@hrj
hrj / alias.md
Last active November 29, 2023 09:50
pwd alias hell

TL;DR

When you are in a shell in Linux, you may be led to believe you are in directory xyz but might actually be in directory pqr.


Demonstration

In a terminal,

@hrj
hrj / dbShow.kts
Last active July 20, 2019 17:12
DBF Show
import net.iryndin.jdbf.reader.*
import net.iryndin.jdbf.core.*
val fis = java.io.FileInputStream(args[0])
val reader = DbfReader(fis)
val md = reader.getMetadata()
val fields = md.getFields()
@hrj
hrj / WikipediaAnalysis.md
Last active August 29, 2015 14:16
Analysis of Wikipedia performance issue

Navigating to Wikipedia home page was causing a massive slowdown of the browser. After analysis the problem turned out to be due to a long chain of causes.

A] Whenever mouse is hovered on an element, the element and its descendants are invalidated.

This is a known and important issue, but will take time to fix. Issue #89. See Update below.

B] Invalidation causes re-layouting of the whole DOM tree

As a consequence of A, every mouse move causes the body element to be invalidated, and also its descendants. By itself, this is correct behaviour. (Not really, see update below).

C] Re-layouting of inline-blocks was causing new instances of RInlineBlock to be created.

This is bad but by itself it is not terribly inefficient. However, it causes more trouble...